Skip to content

Phase 4: the VRP series — HAR walk-forward, ex-ante vs ex-post, lookahead guard - #6

Merged
NavyBlueCheese merged 1 commit into
mainfrom
phase-4/vrp-series
Jul 9, 2026
Merged

Phase 4: the VRP series — HAR walk-forward, ex-ante vs ex-post, lookahead guard#6
NavyBlueCheese merged 1 commit into
mainfrom
phase-4/vrp-series

Conversation

@NavyBlueCheese

Copy link
Copy Markdown
Owner

What was built

  • lookahead.py — the guard: any information set containing rows after the decision time raises LookaheadError; null timestamps are refused too. Under test, including deliberate contamination.
  • realized/har.py — Corsi (2009) HAR in logs with the two brief-mandated choices: direct 30-day-horizon regression (not iterated one-step) and the lognormal retransformation exp(s^2/2). HAR-RV-CJ via the ABD (2007) continuous/jump split at the BNS 1% level. Walk-forward is expanding-window with a subtlety the tests pin: training rows must have their own forward window closed by the decision date, or the target leaks the future.
  • analysis/vrp.py — both VRP definitions, kept in separate columns forever: ex-post (descriptive only) and ex-ante (the tradeable object). The realised leg now includes weekend/holiday gap returns via new first/last log-mid panel columns (conventions rule 5 was silently unmet before this PR — no single intraday window can see the Friday-to-Sunday gap).
  • analysis/stylized_facts.py — moments and Newey-West inference; a test demonstrates HAC deflates the t-stat by >2.5x on an artificially overlapped series.

Acceptance tests (brief section 5, Phase 4)

  • The lookahead guard raises when fed future data: passing.
  • Walk-forward purity: the forecast for date t is bit-identical (rel 1e-12) when all data after t is deleted: passing.
  • HAR beats the expanding-mean naive forecast in log-MSE on a persistent synthetic DGP; fit recovers known coefficients; retransformation makes level forecasts mean-unbiased where the naive exp(log-forecast) is >25% biased low.

118 tests, coverage 93.3%, mypy --strict clean.

First real output (auto-extends with the backfill)

With EVZ joined to the currently-ingested ticks, the only fully-covered forward windows are early March 2020 - and the ex-post VRP there is negative (mean -0.0145 annualised variance, positive on 1 of 10 days): implied variance going into the COVID month priced far less than materialised. The canonical crash-month loss, produced by the pipeline unprompted. Ex-ante forecasts appear once ~300 training days of closed windows exist (the backfill is working through 2007 now).

Corsi (2009) HAR in logs with direct 30-day-horizon regression and
lognormal retransformation; ABD (2007) continuous/jump split via the
BNS test; expanding-window walk-forward where training sets contain
only rows whose forward window has closed, checked by a lookahead
guard that is itself under test. Panel gains first/last log-mids so
30-day windows include weekend/holiday gap returns (conventions rule
5). Stylized-facts module uses Newey-West inference because the
30-day windows overlap. Purity acceptance test: the forecast at t is
bit-identical when all data after t is deleted.
@NavyBlueCheese
NavyBlueCheese merged commit 4e3b22b into main Jul 9, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant