Extract buildDisplaySeries from rCpnlChart into 05b-pnl.js#65
Merged
Conversation
Moves the inline zero-baseline prepend, period-filter slice, and today-extension logic out of rCpnlChart into a pure, dual-exported function. rCpnlChart is now a single call site. Adds 4 unit tests. Updates architecture diagram. Closes #57. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
Extracts the three inline series-preparation steps from
rCpnlChartin07-render-charts.jsinto a standalone pure functionbuildDisplaySeriesin05b-pnl.js, alongsidecomputePnl.rCpnlChartis now a single call site.The three absorbed steps:
Dead variable removed:
cutoff(Date object),allSeries,lastBefore,inPeriod,todayStr— all absorbed into the function. ThetodayDate object is replaced bytoday()(the existing util that returns an ISO string).Interface:
buildDisplaySeriesadded to the dual-export footer in05b-pnl.jsand to the05b-pnl.jsnode indocs/architecture.md.Test plan
4 new unit tests appended to
test/unit/pnl.test.js:empty input returns empty— guard caseALL prepends zero-baseline and appends today— full happy path1M with no in-range points returns flat [{cutoff,lastVal},{today,lastVal}]— all trades before windowbaseline carry-forward is last point before the cutoff— correct baseline selection when some trades are in-windownpm test— 108/108 passpython3 build.py --check— passesCumulative Realised P&L hero chart renders correctly for all three period toggles (1M / 3M / ALL) — behaviour unchanged, logic only moved
Closes #57
🤖 Generated with Claude Code