- New: libs/backtest/xsmom_cache.py — disk cache for xsmom ranked-universe
per rebalance date; keyed by snapshot fingerprint + param hash; top_n is
NOT in key so v9.3.1 (top20) and v9.3.2c (top10) share one cache file
- libs/backtest/cross_sectional_momentum.py — add cache= param to
build_candidates(); hit path skips 900-symbol scan; miss path writes ranked
rows post-quality-gate to cache buffer
- libs/backtest/snapshot_store.py — expose snapshot_dir attribute; propagate
through slice_by_date_range() so runner always has the path
- apps/backtester/run.py — wire up XsmomRankCache per engine (lazy init,
flush after simulation loop); cache is no-op when snapshot_dir is None
- configs: add return_max_long_v9.3.2b_fc.json (SQS 93.5 champion,
ER days[2,8]); remove all other v9 sweep variants from .index.json
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
New engines (configurable but not promoted by default):
- libs/backtest/earnings_runup.py: pre-earnings drift entry (T-7 to T-3, attention+volume z-scores)
- libs/backtest/peer_sympathy.py: peer reaction trade after leader earnings, with reaction_close variant
- libs/backtest/vol_breakout_52w.py: 52-week high volume breakout
- libs/backtest/cross_sectional_momentum.py: 12-1 momentum with VIX/SPY-50dma regime filter
Pipeline additions:
- libs/parser/event_type_normalizer.py: normalize Oracle fallback raw vocab to strategy
vocabulary (earnings_result→earnings_release, regulation_fd→guidance_update, etc.).
Wired into apps/pipeline/event_parser/main.py oracle-fallback path.
- libs/labeler/label_generator.py: preserve future entry_dates as label_status='pending'
instead of dropping as 'unavailable'.
- libs/export/snapshot_export.py: include 'pending' labels in snapshot export.
- libs/parser/rule_parser.py: harden 8-K item-code classifier against dirty input strings.
Infrastructure:
- libs/backtest/snapshot_store.py: _PRICE_FEATURE_WARMUP_DAYS 120→400 (needed for
xsmom 12-1 lookback of 273 trading days).
- apps/backtester/run.py + apps/paper_trader/backtest_sim.py: disable auto-refresh
of snapshots (user request — auto-refresh was silently rebuilding snapshots with
current code, making historical backtests irreproducible across DB mutations).
Engine config support:
- libs/backtest/domain.py: add fields for ER/PS/VolBO/xsmom engine configs.
- libs/backtest/execution.py: wire pct-trailing for EarningsRunup.
- libs/backtest/scoring.py: synthetic candidate scoring for new engines.
Configs (POC + sweeps, none promoted as active strategy):
- Phase A-E PEAD baseline comparisons (no PEAD / +ER / +xsmom / +sleeves variants)
- Phase F1-F8 silo allocation sweep (v7.356 + ER/xsmom silos 15-60%)
- xsmom_poc_v1, xsmom_v2_regime_mdd
- v7.356_plus_er_silo_05/10/15/20/25/30 ranges
- earnings_runup_* / peer_sympathy_* / vol_breakout_52w_* POCs
Tests: 16-tests-each for each new engine + event_type_normalizer tests.
Note: backtest reproducibility infrastructure remains broken — see
_backup_2026-05-10/HANDOFF.md for details on the +12,592% reference run that
cannot be reproduced after rebuilds. Followup work needed before trusting any
specific backtest number.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
On the last simulation day, parking was entered at EOD close price
(when _had_event_activity_today=True) and immediately liquidated at
close by end-of-backtest cleanup → entry == exit → PnL = 0.
Fix: force all six parking entry code paths to use "open" price when
date == last_simulation_date, so entry and cleanup-close are always
different prices.
Also adds _parking_cap logic in _extend_store_to_requested_window to
cap _requested_end_date at the last date where QQQM/TQQQ/SGOV all
have Oracle close-price data, preventing the simulation from including
days where macro is incomplete and the exit fallback would fire.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Backtester (run.py):
- cash_available = (self._cash + parking_value) * multiplier caused trades to be
approved even when self._cash ≈ 0 (all money in SGOV/QQQ). Trades executed
by deducting from self._cash → negative cash (phantom money).
- Fix: after simulate_entry, if self._cash < actual trade cost and parking exists,
call _liquidate_parking_for_cash(shortfall) before deducting from cash.
- Verified: 2022-2026 backtest with qqqm_low_dd shows 0 cash_negative events.
Live engine (engine.py):
- Add _parking_liquidate_for_event(): frees parking cash to fund event entries.
SGOV (virtual) reduces entry_value in DB; QQQM/QQQ sells real shares via broker.
- Both entry loops (engines mode + flat/reaction_close mode) now attempt parking
liquidation when plan.skip_reason == "insufficient_cash" before giving up.
Also includes prior session work (accumulated since last commit):
- 6 novel parking gate signals: VRP, Market Temperature, Hurst exponent, Rolling
Kurtosis, Return Autocorrelation, SPY-QQQ Correlation (composite risk score v2)
- QQQM parking symbol support (lower expense ratio vs QQQ)
- Snapshot auto-refresh + bar extension cache (pickle) to avoid 10-min re-fetches
- Bar extension clamps to last market-closed date (ET 4PM check)
- fithia2 refresh command; --no-refresh flag for paper backtest
- Paper backtest macro extension beyond last event date (parking-only periods)
- parking_state DB schema: 7 new columns (peak_price, gate_in_sgov,
committed_target, pending_target, pending_days, sgov_entry_value, sold_today)
- Live engine: target confirmation (2-day), top-up drawdown gate, trailing stop,
SGOV interest accrual, full 6-signal gate evaluation
- New PARKING_PRESETS: qqqm_low_dd, composite_v2, vv_24_vrp8, vt_24_t13, etc.
- Web GUI / CLI result parity fix (Oracle URL via get_settings().stock_oracle_url)
- Force-close uses last_exec_date (has bar data); parking liquidates at last_date
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extends selector with new scoring model support, adds execution
enhancements, and improves snapshot store loading and split handling.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace naive abs(reaction_day_return) fallback with a composite score
from 4 market microstructure features available at entry time:
1. Reaction quality (35%) — moderate positive return (PEAD zone) is
ideal; extreme positives penalized as "priced in"
2. Close strength (30%) — close near session high = buyers won
3. Volume conviction (20%) — 1.2-2x is healthy; >3x is exhaustion
4. Gap quality (15%) — small positive gap = orderly strength
Real data results (14 events, b1868603 snapshot):
- Score filters out 6 of 10 losers (DDOG -11.7%, META -9.1%, etc.)
- With threshold 0.5: return -2.63% → +0.27%, drawdown 4.24% → 0.86%
- Profit factor 0.44 → 1.16 (turns profitable)
- MSFT loss (-8.7%) is macro-driven, not predictable from stock features
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- BacktestRunner.run() now iterates all NYSE trading days (not just candidate
days) via SnapshotStore.all_trading_days() so stop/target/time exits are
checked every day, not only on days with new candidates
- Record initial DailyPortfolioState before simulation loop starts so
total_return_pct is computed relative to the true initial equity (100k),
not the first post-entry equity snapshot
- SnapshotStore._fetch_event_metadata() now synthesises event_timestamp from
event_date + 21:00 UTC when filed_at_utc is NULL (transparent enrichment at
loader boundary, not silent substitution in selector)
- SnapshotStore._async_load() maps event_close → entry_price_est when the
column is absent, and derives score from abs(reaction_day_return) when the
Parquet snapshot has no score column
- Add --snapshot-dir CLI flag to BacktestRunner to override the default
parquet_dir base path (needed for non-standard snapshot locations)
- Fix integration test assertion: total_trading_days >= 2 (was == 2)
- Add configs/experiments/realdata_test_v1.json for real Phase 3 snapshot runs
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>