Remove APR duplication in renderExpiryTable — use enriched rows from compute()#66
Merged
Merged
Conversation
…compute() renderExpiryTable now receives allRows (enriched by compute) via rStats instead of filtering raw trades[]. Uses r.annual directly and _liveDte for the DTE label, eliminating the duplicate inline APR formula. Removes the dead `else renderExpiryTable()` branch in fetchExpiryPrices. Closes #58. 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
renderExpiryTablewas reading rawtrades[]and recomputing APR inline, creating two copies of the formula that could silently diverge fromr.annualin the Open Positions table. This PR eliminates the duplication.Three concrete changes:
08-render.js— passesc.allRowstorStatsalongsidedisplayRowsrStatssignature — updated torStats(streams, lots, allRows, displayRows), forwardsallRowstorenderExpiryTable(allRows)renderExpiryTable(allRows)— filters enriched rows (not rawtrades[]), readsr.annualdirectly, delegates DTE label to_liveDte(r.expiry). Inline APR formula removed.else renderExpiryTable()infetchExpiryPriceswas unreachable (renderis always defined in the built app); replaced with a directrender()call.Why
allRowsnotdisplayRows:renderExpiryTableapplies its ownsFilterasset check internally, so it needs the full unfiltered set.displayRowsis already filtered.Docs updated:
docs/architecture.md— data flow edge updated toallRows + displayRows → RTCLAUDE.md—rStatsandrenderExpiryTablesignatures updated in the file mapTest plan
Two new integration tests in
test/integration/expiry-table.test.js:APR consistency —
renderExpiryTableAPR matches Open Positions APR for the same trade (column 7 in expiry table vs column 9 in open table). Catches any future formula divergence.Asset filter respected — with BTC + ETH trades, setting ETH filter shows only ETH row in Expiring This Week.
npm test— 110/110 passpython3 build.py --check— passesCloses #58
🤖 Generated with Claude Code