Day 139 — The rebuild, and the test that guards it

Wednesday, 23 December 2026 · Week 20 of 52 · The research harness · Study day · 60 min

Four days of taxonomy are worth nothing until the store enforces them, and the enforcement has to be a test rather than a convention because you will forget the convention by March.

What you should be able to do tonight

  • Rebuild the store so every read path takes an as-of date and a per-source lag, with no path that bypasses either.
  • Have a test that fails if any query returns data whose availability timestamp is after the as-of date.

Tasks 60 min

30 min Refactor qlib/store.py so as_of is a required argument on every public read function rather than a default. Requiring it is the point: a default is a decision you will stop noticing.

30 min Write tests/test_leakage.py with three tests: every read function rejects a call without as_of, a row inserted with a future availability timestamp is invisible, and the point-in-time universe at a past date excludes a security that first listed after it. Run the full suite.

The running strategy

The store’s read interface now requires an as-of date on every path and enforces per-source availability lags, with three tests that fail if a future value becomes visible. This is the foundation the event-driven engine is built on next week.

Resources

Deliverable

A refactored store with as_of required everywhere, and tests/test_leakage.py passing with three distinct leakage tests.

Checkpoint

Describe a unit test that makes look-ahead impossible rather than merely undetected, and say why yours qualifies.

Prepare for tomorrow

Ten minutes tonight so Day 140, Thursday, 24 December 2026 starts clean. This is what the evening email sends you.

Rerun your pairs and trend strategies through the rebuilt store and record the new Sharpe ratios.

Compare against the numbers in milestone 3. They will be lower.

Write down the difference; tomorrow it goes into the report as a correction.