Skip to content

Slice 1: Realised P&L tile + cumulative sparkline (cash-flow lens)#22

Merged
heyitsStylez merged 3 commits into
mainfrom
pnl-revamp
May 5, 2026
Merged

Slice 1: Realised P&L tile + cumulative sparkline (cash-flow lens)#22
heyitsStylez merged 3 commits into
mainfrom
pnl-revamp

Conversation

@heyitsStylez
Copy link
Copy Markdown
Owner

@heyitsStylez heyitsStylez commented May 5, 2026

Summary

First vertical slice of the PnL revamp (#12). Introduces the cash-flow lens for Realised P&L:

  • New pure module src/js/05b-pnl.js exposing computePnl(trades, assetFilter) → { realised, realisedSeries }. Dual-exported for Node tests.
  • Premium P&L Total tab: Net P&L card replaced with a Realised P&L card (+ formula tooltip) sourced from computePnl.
  • Cumulative-hero sparkline now plots true Realised P&L — premiums and capital gains on call-aways. Label and empty-state copy updated.
  • assignedLotNums HOLDING-vs-ASSIGNED special case removed; call-away credit is now symmetric.
  • ADR docs/adr/0003-pnl-cash-flow-lens.md captures the cash-flow / net-cost / hybrid trade-off (numbered 0003 to avoid collision with the existing 0001 release-automation ADR).
  • CONTEXT.md gains a Realised P&L entry; CLAUDE.md file map updated for 05b-pnl.js and 07-render-charts.js.

Unrealised + Total tiles, Monthly-tab column rename, per-lot Net Cost tooltip, and missing-spot fallback all land in Slice 2 (#14).

Closes #13.

Test plan

  • npm test — 24 passing (10 unit on computePnl event table; 4 jsdom integration on tile + hero DOM)
  • python3 build.py --check — clean
  • Manual: open hyperwheel.html, verify Realised tile shows +/- with formula tooltip on hover; cumulative hero header reads "Realised P&L" and includes capital gain after a CALLED event
  • Manual: filter by single asset — Realised tile updates accordingly

🤖 Generated with Claude Code

@vercel
Copy link
Copy Markdown

vercel Bot commented May 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hyperwheel Ready Ready Preview, Comment May 5, 2026 1:28am

heyitsStylez and others added 3 commits May 5, 2026 09:27
- Add pure computePnl(trades, assetFilter) in src/js/05b-pnl.js. Realised path
  only: Σ settled netPrem + Σ (strike − costBasis) × calledSize. Open options
  and open lots contribute zero. HOLDING-originated and ASSIGNED-originated
  lots realise capital gain symmetrically — the assignedLotNums workaround is
  removed.
- Premium P&L Total tab: replace Net P&L card with Realised P&L card driven by
  computePnl, including a hover tooltip explaining the formula.
- Cumulative-P&L hero sparkline now plots Realised P&L; label and empty-state
  copy updated.
- Tests: 9 unit tests in test/unit/pnl.test.js covering the realised event
  table; 3 jsdom integration tests in test/integration/pnl-tiles.test.js
  asserting tile DOM under default and filtered states.
- Docs: docs/adr/0001-pnl-cash-flow-lens.md captures the cash-flow vs net-cost
  vs hybrid trade-off; CONTEXT.md gains a Realised P&L entry and marks
  portfolioPnl internal; CLAUDE.md file map updated.

Issue: #13
PRD: #12
…ignedLotNums

- computePnl now returns realisedSeries (cumulative {date,val} sorted by event
  date, including CALLED capital gains). rCpnlChart consumes it so the hero
  reflects the same number as the Realised tile rather than premium-only.
- Hero label "Premium Income" → "Realised P&L"; empty-state copy updated.
- Realised tile tooltip rewritten to spell out the formula.
- assignedLotNums filter removed from calcStats per slice AC — call-away credit
  is now symmetric across HOLDING- and ASSIGNED-originated lots.
- ADR renumbered 0001 → 0003 to avoid collision with the existing
  0001-label-driven-auto-release ADR. CLAUDE.md + CONTEXT.md references updated.
- jsdom canvas stub gains bezierCurveTo/quadraticCurveTo so the integration
  tests that now hit a 2-point path don't crash.
- New unit test covers realisedSeries; new integration test asserts the hero
  shows premium + capital gain (550, not 50) for HOLDING + CALLED.

Issue: #13
PRD: #12

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Picks up footer + ADR + version-tag changes from main so CI's post-merge
build matches the committed artifacts.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@heyitsStylez heyitsStylez merged commit 85716a5 into main May 5, 2026
4 checks passed
@heyitsStylez heyitsStylez deleted the pnl-revamp branch May 5, 2026 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slice 1: Realised P&L tile + cumulative sparkline + ADR

1 participant