Skip to content

Remove APR duplication in renderExpiryTable — use enriched rows from compute() #58

@heyitsStylez

Description

@heyitsStylez

What to build

renderExpiryTable in src/js/06-render-table.js currently reads raw trades[] and recomputes APR inline. The APR formula is already computed by compute() on every enriched row as r.annual. This creates two copies of the formula that can silently diverge.

The fix: pipe enriched allRows from compute() through rStats into renderExpiryTable, so it filters from the already-enriched rows and reads r.annual directly.

Three concrete changes:

  1. src/js/08-render.js: pass c.allRows to rStats
  2. src/js/06-render-table.jsrStats signature updated to accept allRows and forward it to renderExpiryTable(allRows)
  3. renderExpiryTable(allRows): filters enriched rows for open options expiring within 7 days (keeping its own sFilter asset check), uses r.annual instead of the inline formula, uses the existing _liveDte(r.expiry) helper instead of recalculating days manually
  4. Remove the dead else renderExpiryTable() fallback in fetchExpiryPricesrender is always defined in the built app; this branch never executes

Acceptance criteria

  • renderExpiryTable no longer contains an inline APR formula
  • renderExpiryTable no longer reads trades[] directly
  • APR values in the Expiring This Week table match those in the Open Positions table for the same trade
  • The dead else renderExpiryTable() branch in fetchExpiryPrices is removed
  • Asset filter (sFilter) still applies correctly in the Expiring This Week section
  • python3 build.py --check passes
  • npm test passes

Blocked by

None — can start immediately.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions