Files
fxhnt/tests
jgrusewski 030d55e83f perf(paper): incremental risk overlay in backfill (O(N^2)->O(N) book-return + killswitch)
paper_risk_overlay re-derives the WHOLE un-throttled book-return series (paper_book_returns) AND
replays the DrawdownKillSwitch from scratch every date -> O(D) per date -> O(N^2) over a ~1650-date
backfill (~10+ min). Add IncrementalRiskOverlay: since the backfill's acc is append-only and
paper_book_returns is a deterministic strictly-causal forward loop, keep the loop state + one
persistent killswitch RESUMABLE across the date loop and advance them only over the new days.
weights/leverage stay per-date (windowed, O(window)). The snapshot path keeps using stateless
paper_risk_overlay (live==replay). Bit-identical proven by test_incremental_overlay_golden (exact ==
on weights/leverage/killed for every date, incl. a kill+re-enter path). Overlay cost at N=1650: ~2s.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 19:57:00 +02:00
..