feat(backtest): runnable with partial factor coverage + oldest-history default (owner rule)
Owner's rule: backtest must run as soon as there's enough data to estimate an investment — it must NOT be blocked just because some sources lack deep PIT history. Scoring is deliberately flexible (a theme uses whatever subset of factors was knowable that day). - backtest_readiness: readiness = usable window (price + Siamchart + >=1 factor), not all-factors-present. Missing factors still reported (transparency) but no longer block the run. recommended_start = oldest executable price (oldest history the system holds); recommended_end = last complete trading day. - pit_scorer.theme_surprise_report: flexible — skips factors not released by as_of; blocked only when NO factor has a value. pit_meta.partial_pit reflects themes scored from a partial factor subset. - Verified end-to-end: readiness ready=true (recommended 2024-01-03 -> 2026-08-29); POST /api/v1/backtest/run default window returns 201 full result (1M -> final equity 1,117,243.95), no 400 from missing factors. - test_backtest_readiness updated to earliest-runnable semantics; full suite 369 green.
This commit is contained in:
@@ -88,3 +88,24 @@ needs-deeper-capture and left as a decision for the owner.
|
||||
- Note: a **concurrent process** also landed `thai_trade.py` (external-sector
|
||||
exports/imports/current-account) and external_* factors mid-session; its 3
|
||||
initially-broken tests were fixed to reach the 360-green baseline here.
|
||||
|
||||
## Flexible PIT backtest (owner rule — 2026-08-30)
|
||||
Owner clarified the backtest contract: it must run as soon as there is enough
|
||||
data to estimate an investment, NOT only when EVERY factor has PIT history.
|
||||
Some sources may not provide deep history — scoring is deliberately flexible
|
||||
(a theme scores from whatever subset of factors was knowable that day).
|
||||
|
||||
Implemented (commit 2026-08-30):
|
||||
- `backtest_readiness.evaluate_readiness`: readiness is now a *usable* window
|
||||
(price + Siamchart + >=1 released factor), not all-factors-present. Missing
|
||||
factors are still reported in `missing` for transparency but no longer block.
|
||||
`recommended_start` = oldest executable price (the oldest history held);
|
||||
`recommended_end` = last complete trading day (yesterday Bangkok).
|
||||
- `pit_scorer.theme_surprise_report`: flexible — skips any factor with no release
|
||||
by `as_of` (no blanket theme block); `blocked` only when NO factor has a value.
|
||||
`pit_meta.partial_pit` reflects themes that scored from a partial subset.
|
||||
- Verified: `/api/v1/backtest/readiness` → ready=true, recommended 2024-01-03 →
|
||||
2026-08-29. `POST /api/v1/backtest/run` (default window) → 201 full result
|
||||
(final_equity 1,117,243.95 on 1M), no 400 from missing factors.
|
||||
- Tests: test_backtest_readiness updated to earliest-runnable semantics; full
|
||||
suite 369 green.
|
||||
|
||||
Reference in New Issue
Block a user