Slice 1: Realised P&L tile + cumulative sparkline (cash-flow lens)#22
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First vertical slice of the PnL revamp (#12). Introduces the cash-flow lens for Realised P&L:
src/js/05b-pnl.jsexposingcomputePnl(trades, assetFilter) → { realised, realisedSeries }. Dual-exported for Node tests.computePnl.assignedLotNumsHOLDING-vs-ASSIGNED special case removed; call-away credit is now symmetric.docs/adr/0003-pnl-cash-flow-lens.mdcaptures the cash-flow / net-cost / hybrid trade-off (numbered 0003 to avoid collision with the existing 0001 release-automation ADR).CONTEXT.mdgains a Realised P&L entry;CLAUDE.mdfile map updated for05b-pnl.jsand07-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 oncomputePnlevent table; 4 jsdom integration on tile + hero DOM)python3 build.py --check— cleanhyperwheel.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🤖 Generated with Claude Code