Status: DONE (2026-08-15) · Suite: 310 passed, 2 skipped (+6 tests in tests/test_alpaca_monitor.py)
What was built
data/alpaca/monitor.py — one-shot health/status report + drift journal for
the raw store, the signal chain and the executor. CLI:
python -m data.alpaca.monitor [--json-out file].
Checks
| Check | Output |
|---|---|
| store completeness | per (symbol, type, timeframe): day partitions missing in the last 7 days (missing_partitions) |
| freshness | seconds since the newest stored bar/trade/quote per kind (latest_ts, freshness_s) |
| quote staleness | Phase-2 quote_age_s tail value per symbol (or raw-quote fallback); flagged when > 15 min |
| models | per (SYM|TF) loaded h*.json metadata (n_pred, IC, fee hurdles) |
| executor state | open position (qty/entry/exit bar), last signal, trade count, risk halt flag |
| safety | API keys present, canonical symbols only, no-short rule (enforced at the executor/broker boundary), maker/taker fee bps |
StatusReport is a dataclass → stable JSON schema; the CLI also writes
processed_dir/alpaca/monitor/latest.json for dashboards/alerting without
touching the trading process.
Design notes
- Every check is a pure function with injected roots — tests run fully offline against tmp stores (partition holes detected exactly, staleness in seconds, report shape, executor snapshot, safety flags).
- The store-completeness check counts DAY partitions (like the backfiller writes), so a monitor run immediately surfaces a stalled backfill.
- Safety flags are report-only here; enforcement lives in Phase 7's executor/broker boundaries (shorts and non-canonical symbols rejected before any API call).
Deployment checklist (next, outside this phase)
- Full backfill completes → build features → datasets → run Phase-4 pipeline → produce OOS preds → Phase-5 backtests per (symbol, TF, h).
- Calibrate
threshold_bpson OOS, then re-validate on a held-out tail. - Wire
BarExecutor+RiskManagerinto a paper runner againstAlpacaBroker(paper=True); verify orders land and fills match the paper book. - Schedule
monitoron a cron/daemon; alert onquote_age_s > 15min, missing partitions, risk halts.