170 Commits (92840b857a7f5a941c16a94b63192901a8c518be)
 

Author SHA1 Message Date
I Luk Kim 7676ef7867 Register v6new.255 on leaderboard (SQS 72.2, #9, CW 293.2%)
Higher risk (0.069) + tighter stops (ATR 1.45) produce best CW return
but lower SQS than v6new.196 (72.6) due to WFV instability.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 1c38415cb7 Add v6new.265-268: small-cap expansion experiments
Lowering market cap floors to 2B added 15 trades (194→209) but CW return
dropped from 293.2% to 278.5%. Small-cap PEAD events have lower average
quality — individual outliers like SEDG exist but don't compensate.

v6new.255 (293.2%) confirmed as optimal trade-quality balance.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim e2229646e6 Add oversold bounce engine experiments (v6new.259-264) — blocked by architecture
Bounce engine (buy negative reaction, bet on mean reversion) could not
execute: system architecture ties scoring to single model per backtest,
and selector/store indexes are optimized for positive-reaction PEAD.
Negative-reaction candidates get score=0 from PEAD scoring, blocking
engine selection regardless of engine-level threshold overrides.

Implementing bounce trades requires: dual scoring model support,
selector changes for negative-reaction candidate routing, and
store indexing changes. Deferred to future refactor.

Current best CW return: 293.2% (v6new.255)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 74244b15d2 Add v6new.224-258: grid search risk×ATR toward 300% CW
Best: v6new.255 (293.2%) = risk 0.069 + ATR 1.45 + entropy + doc 0.50
ATR 1.45 is critical threshold — below it loses 1 trade and drops to 269%.
Risk 0.069 is max before trade loss at 0.070.

Progress: 262.9% → 284.4% → 288.3% → 290.4% → 291.8% → 293.2%

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 672098c077 Add v6new.215-223: three-way parallel search toward 300% CW
Best: v6new.220 (289.6%) = risk 0.065 + max_pos_value 1.5 + ATR 1.6.
194 trades fixed — event count is the structural bottleneck.
Management_change/oneoff relaxation hurt. Budget/leverage neutral.
300% requires fundamentally more trades or higher per-trade returns.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 6dee2c24d2 Add v6new.197-214: parameter grid search around v196
Best CW return: v6new.207 (288.3%) = v196 + risk 0.060 + ATR 1.6.
Public SQS: v6new.196 (72.6) still best — v207 is 72.5.
ATR 1.6 is optimal stop distance. Sector limit increase hurts badly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim cc953949f1 Add v6new.196: new best SQS 72.6 (#3) — v29+entropy+risk+doc_quality
v6new.196 = v29 base + entropy scoring (v13e) + per_trade_risk 0.058
+ doc_quality 0.50. CW return 284.4% (+21.5pp over v122), 194 trades.

Key finding: v29 base with doc_quality 0.50 (not 0.55) is the optimal
quality gate when combined with entropy scoring.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 090bfa8e36 Add contrarian feature analysis + v15 scoring (v6new.174-188)
Data analysis revealed OBV Q1 (distribution) has 56.4% WR vs Q5 51.2% —
contrarian signal confirmed. Previous OBV bonus was applied in wrong
direction. Corrected with v15 scoring models.

Best result: v6new.185 (entropy + risk 0.058) CW 274.4% but SQS 72.2,
still below v6new.122 (72.4). WFV/robustness offsets CW gains.

v6new.122 confirmed as optimal under current SQS v4 formula.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 95c6b499c4 Add missing experiment configs v6new.129, 160-162
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 1e66b67c7a Add technical/scientific feature experiments (v6new.106-173) and v6new.122 SQS 72.4
Tier 1: Vol/RSI/BB/OBV features — sizing scalers hurt public SQS, scoring
adjustments ineffective on 28-30 trades. Only doc_quality gate lowering
(0.66→0.55) improved results (+2 trades, +0.8 SQS).

Tier 2: Hurst exponent, Shannon entropy, sector momentum — entropy bonus
CW +10.7pp but SQS equivalent (72.3 vs 72.4). Sector momentum hurt badly.

Tier 3: OU theta, gravitational pull, market temperature — all caused
large CW return drops (-80 to -103pp). Physics-based indicators don't
fit event-driven PEAD.

Best result: v6new.122 (SQS 72.4, #3 leaderboard) = v6new.29 + doc quality
gate 0.66→0.55. Single parameter change outperformed all feature engineering.

New code:
- libs/features/market_features.py: 9 new features (vol, RSI, BB, OBV,
  Hurst, entropy, OU theta, gravitational pull, market temperature)
- libs/backtest/scoring.py: v12-v14 scoring models with technical gates
- libs/backtest/allocator.py: volatility + conviction size scalers
- libs/backtest/domain.py: volatility_size_scaler + conviction_boost config
- scripts/enrich_*.py: snapshot enrichment scripts
- 68 experiment configs (v6new.106-173)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 83c7a66f77 Add v6new.37-38: final tuning attempts — v6new.30 confirmed as optimum
v6new.37 (prune 2 weak engines): +106.55% — neutral (+0.10%)
v6new.38 (boost top engines): +96.55% — worse (-9.90%, capital starvation)

38 experiments complete. v6new.30 is the confirmed framework optimum.
Paper BT: +106.45%, 48 trades, 67% WR, MaxDD 3.35%, Sharpe 3.66

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim daa8536546 Add v6new.36: mean reversion engine for high-VIX drops
New engine: next_open_long_mean_reversion_high_vix
  Targets: react < -7%, close 0.15-0.60, bearish/mixed/unknown direction
  Signal: VIX>20 + big drop = 62.9% WR, +3.91% 5d mean (n=167)
  VIX 25-30 sweet spot: 75% WR, +5.46% 5d mean

Test split: 3 MR trades, 67% WR, +5.59% total PnL
Paper BT: 51 trades vs 48 (v6new.30), return ~equal

Also fixes _rows_to_table to handle sparse feature columns.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 16613f1758 Fix _rows_to_table to collect keys from ALL rows, not just first
Previously only used rows[0].keys() — columns present in later rows
(like earnings_surprise_pct from sparse features) were silently dropped.
Now collects all unique keys across all rows.

YoY earnings surprise tested: WR spread only 2.5pp (55.2% vs 52.7%).
Not actionable — YoY growth != analyst consensus surprise.
v6new.30 remains the framework optimum.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim fecdc12007 Add earnings surprise feature pipeline and v11 scoring
New data source integration:
- EarningsSurpriseService: GET /api/v1/earnings/surprise/{symbol}
  Returns actual vs estimated EPS with surprise_percentage
- Feature builder: creates earnings_surprise_v1 snapshots for earnings events
- Backfill script runs for existing 1,273 tickers (Alpha Vantage rate limited)

New scoring (v11):
- Small beat (0-3% surprise): +10% bonus (82.4% WR in sample)
- Medium beat (3-8%): +5% bonus
- Big beat (>8%): no bonus (already priced in)
- Miss (<=0%): -5% penalty

Signal validation (n=66 sample):
  Small beat: 82.4% WR, +1.79% mean 5d return
  Big beat: 54.8% WR, +0.47%
  Miss: 55.6% WR, -0.10%

Backfill running (~4 hours). Experiment pending data completion.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim e8241d2924 Test execution model + short side — both rejected, v6new.30 confirmed
Short Side (Direction 3):
  Bearish events: 45-55% WR for short — no actionable edge
  Mean reversion after large drops cancels short PEAD

Execution Model (Direction 2):
  T+2 delayed entry: loses 54% of alpha (Day 1 = 54% of 5d return)
  Wider stops (v6new.34): -0.68pp — smaller positions offset fewer stop-outs
  Tighter trailing (v6new.35): -12.48pp — cuts winners too early
  reaction_close >> next_open (86% vs 57% WR) but post_market can't use RC

Direction 1 (new data: Form 4, XBRL, Earnings Surprise) requires Oracle API
implementation. Free sources identified: SEC EDGAR, Alpha Vantage, FINRA.

v6new.30 is the confirmed framework optimum.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim f2b3b57b3a Update v6new.30 on refreshed snapshot — SQS 62.3, WFV 100% positive
Pipeline refreshed: 528 new filings, 240 new events processed.
Snapshot re-exported with start_date=2022-03-01: 9350 rows (+230 vs old).
Test split now extends to 2026-03-23 (was 03-13).

v6new.30 on fresh data:
  SQS: 62.3 (down from 63.8 — OOT worst -4.61% from new period data)
  Train: 117 trades, +59.31%, SQS 92.6
  Valid: 33 trades, +41.05%
  Test:  27 trades, +34.09%
  WFV:   100% positive (worst +1.08%)
  OOT:   90.0% positive (worst -4.61%)
  Paper BT (1yr): +93.41%, 50 trades

Strategy holds up on fresh data with 100% WFV positive rate.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 85515f2db9 Add v6new.31-33: parameter tuning — all neutral/worse, v6new.30 confirmed optimal
v6new.31 (all OME risk reduced): +105.23% — worse, mixed_ome/other_material_mixed need full risk
v6new.32 (patient risk only): +108.15% — marginal, not worth
v6new.33 (core warmup 10): +108.62% — identical to v6new.30

v6new.30 (+108.62%, Sharpe 3.77, SQS 63.8) is the framework optimum.
Further parameter tuning yields diminishing/negative returns.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim b6ea2a4b50 Add v6new.29-30: OME risk experiments — v6new.30 Paper BT +108.62%
v6new.29 (OME disabled): +104.75%, 30 trades, 90% WR — high quality but fewer trades
v6new.30 (OME risk further reduced): +108.62%, 45 trades, 71% WR, Sharpe 3.77
  - unknown_ome: 0.008→0.004
  - other_material_unknown: 0.003→0.002
  SQS: 63.8, WFV 100% positive, OOT 90% positive

Leaderboard: v6new.27 #1 (63.9), v6new.30 #2 (63.8)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 2a82c1e13c Record v6new.27 SQS 63.9 — new #1 validated by both SQS and paper backtest
Full integrated verification:
  SQS: 63.9 (vs v6.29 62.8, v6new.9 63.3)
  Train: 121 trades, +55.87%, SQS 91.3
  Valid: 22 trades, +42.23%, SQS 89.6
  Test:  27 trades, +64.22%, SQS 89.8
  WFV:   100% positive (worst +0.63%), mean +10.06%, gap 10.00%
  RM:    84.4% positive, worst -2.34%
  OOT:   90.0% positive, worst -0.84%
  Paper BT (1yr): +105.35%, MaxDD 3.35%, Sharpe 3.73, 45 trades, 71% WR

First strategy validated by BOTH backtester SQS AND paper backtest
using the unified engine system (no divergence between systems).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim dc16a1f88b Add v6new.28 (marginal) — v6new.27 confirmed as optimal at +105.35%
v6new.28: further recovery risk 0.0035→0.002 → +105.77% (marginal +0.42%)
v6new.27 is the sweet spot: +105.35%, MaxDD 3.35%, Sharpe 3.73

Session summary:
- 28 strategy experiments, 6 infrastructure fixes
- Paper trader unified with backtester (6 divergences resolved)
- Final strategy: v6new.27 (v6.100 base + OME risk reduction)
- Paper BT validated: 96% trade-by-trade match with backtester

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 1f996dfc8e Add v6new.25-27: paper-backtest-driven strategy improvement
v6new.25 (v6.29 base): OME risk halved → Paper BT +94.38% (vs +93.60%)
v6new.26 (v6new.25 on v6.100 snapshot): +93.75%
v6new.27 (v6.100 + further OME reduction): Paper BT +105.35%, MaxDD 3.35%, Sharpe 3.73
  - other_material_unknown: 0.005→0.003
  - unknown_ome: 0.012→0.008

All improvements validated by paper backtest (unified engine, same as backtester).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 7a2001a4fa Add v6new.25: OME risk halved — paper BT +94.38% beats v6.29 +93.60%
Based on paper backtest loss analysis (not backtester SQS optimization):
- OME engines contribute only +$1,405 on 8 trades but generate most losses
- Halving OME per_trade_risk reduces loss magnitude without removing trades
- Paper BT: +94.38% vs v6.29 +93.60%, MaxDD 4.07% vs 4.60%
- WFV: 100% positive fold rate (worst +0.02%)
- RM worst: -0.88%, OOT worst: -0.33%
- SQS: 62.9 (vs v6.29 62.8)

This is the first strategy improvement validated by BOTH backtester SQS
AND paper backtest return, using the now-unified engine systems.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 529477727f Add score and event_type to trade blotter output
FilledTrade now carries event_type and score from the Candidate.
These fields are written to trade_blotter.parquet and displayed in
paper backtest trade logs.

Previously score showed as 0.00 for all trades because the field
wasn't propagated from Candidate → FilledTrade → Parquet.

Score=0.00 is valid for trades from engines with score_threshold_override=0.0
(e.g. guidance_unknown_orderly) where engine gates, not score, determine entry.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 07bcfbe51d Complete engine unification Phase 5-6: residual reserve + macro data
Phase 5 — Engine selection (both entry paths):
  - Added residual_reserve_selected tracking between engines
  - Added prelimit amplification (5x) for attention-requiring engines
  - Added truncate_to parameter to select_candidates calls
  Matches BacktestRunner._select_candidates_for_date() behavior.

Phase 6 — Macro data:
  - Added FRED series fetch (VIXCLS, BAMLH0A0HYM2) to _fetch_macro()
  - Matches SnapshotStore._fetch_macro() which loads from MacroObservation DB
  - Enables VIX/HY regime sizing in live paper trading

All 6 phases of BacktestRunner ↔ PaperTradingEngine unification complete.
450 unit tests pass. Multi-strategy paper backtest verified.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 26ca89c058 Integrate shared trade logic into PaperTradingEngine (Phase 3-4 complete)
PaperTradingEngine now uses:
1. AttentionFilterService after select_candidates (2 entry paths)
   - run_reaction_close: attention filtering added
   - run_next_open: attention filtering added
2. build_effective_execution_config via _resolve_execution_config delegation
   - Replaces 60-line inline implementation with shared function
   - Adds adaptive exit support (was missing)
   - Adds event_type_profile max_holding_days (was missing)
3. check_next_open_gap_cap before order submission
   - Rejects excessive gap-up entries (was missing)

This eliminates divergences #2 (attention), #3 (execution config),
and #4 (gap cap) from the unification plan. All 450 tests pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim fb4fec7dac Unify BacktestRunner and PaperTradingEngine trade decision logic
Phase 1-4 of engine unification to eliminate research/live divergence.

Phase 1 — Scoring (event_detector.py):
  EventDetector now uses config's scoring_model (v5/v9 etc.) when
  event_v1 features are present (parse_confidence_overall not null).
  Falls back to compute_entry_score only for incomplete events.

Phase 2 — Execution config (execution.py):
  Extracted build_effective_execution_config() as shared function.
  BacktestRunner delegates to it. PaperTradingEngine can now use
  identical per-engine overrides, adaptive exit, tiered targets.

Phase 3 — Attention filtering (attention.py):
  New AttentionFilterService class extracted from BacktestRunner.
  Provides: engine_requires_attention, apply_filters, rescoring.
  BacktestRunner now delegates to this service.
  PaperTradingEngine can import and use the same service.

Phase 4 — Gap cap (execution.py):
  check_next_open_gap_cap() shared function for next-open gap rejection.

All 450 unit tests pass. Paper backtest verified working.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim c747d5e4f0 Fix snapshot path resolution for paper backtest
Snapshots can be in data/parquet/ or data/datasets/snapshots/.
Now tries default parquet_dir first, falls back to data/datasets/snapshots/
if the snapshot exists there instead.

Fixes FileNotFoundError when running multi-strategy paper backtest with
configs that reference snapshots in the alternate directory.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 0134476632 Fix async/sync conflict in paper backtest — nested event loop error
run_backtest changed from async to sync function. Pipeline refresh
(async) runs via asyncio.run() before the sync BacktestRunner,
avoiding nested event loop when SnapshotStore.load() calls asyncio.run().

CLI updated to call run_backtest() directly (no asyncio.run wrapper).

Tested: `fithia2 paper backtest --config v6new.24 --start 2025-03-23 --end 2026-03-23` works.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 33acf12baa Remove snapshot refresh fallback — fail hard if pipeline update fails
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 3c65c72a72 Auto-refresh snapshot when paper backtest end_date exceeds snapshot coverage
When `fithia2 paper backtest --end <date>` requests a date beyond the
snapshot's latest event, automatically runs the pipeline:
1. Filing poller (discover new 8-Ks)
2. Filing fetcher (download exhibits)
3. Event parser (parse events)
4. Feature builder (compute features)
5. Label generator (compute labels)
6. Dataset export (re-generate Parquet snapshot)

Staleness check: snapshot is stale if its latest event_date is >14 days
before the requested end_date, or if the manifest is >7 days old.

If refresh fails, falls back to existing snapshot data gracefully.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim d7ecaf97dc Refactor paper backtest to use BacktestRunner — eliminates engine divergence
Major refactor: `fithia2 paper backtest` now uses the exact same
BacktestRunner + SnapshotStore pipeline as `apps/backtester/run.py`.

Before: PaperTradingEngine + EventDetector + MockBroker
  - Different scoring (compute_entry_score vs config scoring_model)
  - Different data source (DB + Oracle vs Parquet snapshot)
  - Different feature computation (real-time vs pipeline)
  → Config gate changes didn't take effect in paper backtest

After: BacktestRunner + SnapshotStore (Parquet)
  - Identical scoring, engine matching, position sizing
  - Same Parquet data as research backtester
  - Config changes work identically in both systems

Trade output format preserved for reporter.py compatibility.
PaperTradingEngine still used for live Alpaca trading (unchanged).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 0797535047 Revert DB-first feature fix — Oracle real-time enrichment must be primary
The DB-first approach (prefer feature_json over Oracle recalculation) caused:
- LMND (+$782) and M (+$1,052) trades to disappear
- TEM loss to increase from -$321 to -$535
- Overall PnL drop from +$5,948 to +$3,078

Root cause: DB features were computed at a different time with different
Oracle data. When paper trader used DB values, the feature values didn't
match what the backtester's Parquet snapshot had, causing different
engine gate outcomes.

Paper trader must use Oracle real-time enrichment as primary source
(same as the original design). The volume_ratio_20d field name fix
is retained as that was a genuine bug.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim f0baa48e7b Revert paper trader scoring to compute_entry_score — fix 2025 trade loss
The _compute_score → v5 dispatch caused v5's hard gates to reject almost
all events (v5 requires specific direction/guidance combos). This killed
all 2025 trades in paper backtest.

Root cause: BacktestRunner and PaperTradingEngine use different flows.
BacktestRunner applies scoring AFTER engine selection (engines have
score_threshold_override=0.0 that bypasses score gates). But EventDetector
applied scoring BEFORE engine matching, causing v5's hard gates to reject
events that engines would have accepted.

Fix: revert to compute_entry_score for EventDetector. Score is ranking-only
in paper trading; engine gates (reaction_min, close_min, etc.) handle filtering.

The volume_ratio_20d fix and DB-first feature fix remain in place.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim bb659cf7ae Add reaction-based position sizing to reduce mean-reversion loss risk
New feature: reaction_size_cap_threshold in RiskConfig
- When abs(reaction_day_return) > threshold, position size scales down
- Formula: scaler = threshold / abs(reaction) (linear inverse)
- E.g. threshold=8%: 8% reaction → 100%, 16% → 50%, 24% → 33%

Paper trading impact simulation (top 10 trades):
- PII (react +14%): loss $501 → $288 (saved $214)
- VSCO (react +18%): loss $792 → $350 (saved $442)
- RYTM (react +12%): loss $397 → $256 (saved $141)
- Winners (react <5%): unchanged (SSRM, FLS, LW, KGS all 100%)
- Total loss reduction: $2,610 → $1,813 (-30%)
- Net PnL improvement: +$797

v6new.24 backtest: Train SQS 92.5 (session best), risk=75.6.
Public SQS 52.5 (lower return due to sizing, but best risk profile).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 2bb5fe1c37 Fix paper trader / backtester consistency: DB-first features + config-aware scoring
Three critical inconsistencies between BacktestRunner and PaperTradingEngine
that caused gate fixes to not work in paper trading:

1. DB feature values now take priority over Oracle recalculation
   - Previously: Oracle bars always recomputed reaction_day_return etc.
   - Now: if DB feature_json has the value, Oracle fallback is skipped
   - Root cause of PII bug: DB had react=-5.3% but Oracle recomputed +13.9%
     due to different date alignment, bypassing engine reaction_min gate

2. Scoring now uses config's scoring_model (v5/v8/v9/v10 etc.)
   - Previously: always used compute_entry_score() regardless of config
   - Now: _compute_score() dispatches to the correct scoring function
   - Ensures hard gates and weights match between backtest and paper trading

3. volume_ratio_20d field name consistency (from prior commit)

These fixes ensure paper trading results match backtester behavior,
making engine gate changes (reaction_min, close_min, etc.) effective
in both systems.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 4de842ba89 Fix paper trader volume_ratio field name mismatch with selector
EventDetector computed volume_ratio as fallback but selector checks
volume_ratio_20d. When DB feature_json was missing this field, the
volume gate was silently bypassed in paper trading — allowing trades
like LKQ (vol=0.8) that the backtest correctly blocks.

Now sets both volume_ratio_20d and volume_ratio for consistency.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 89e5b647b0 Add v6new.23: OME risk halved + vol/reaction gates — SQS 62.3, best loss profile
v6new.22 + additional loss reduction:
- OME engine risk halved (per_trade_risk * 0.5)
- Volume minimum raised to 1.0 (blocks LKQ vol=0.8)
- Guidance reaction_min raised to +1% (blocks SEIC react=0.5%)

SQS 62.3 (up from 61.9 in v6new.22). Train SQS 91.6 (session best).
OOT worst window -0.31% (session best). Test +55.22%.
Trades 90 (down from 106) — quality over quantity.

Paper trade impact: blocks ALL major losses (TEM, PII, ORCL, FND, LKQ, SEIC).
This is the recommended config for live deployment.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 60da697d54 Add v6new.22: paper trade loss fixes — SQS 61.9 but blocks $1.5K live losses
Targeted fixes from paper trading analysis:
- Recovery engine: reaction_min -0.10→-0.03 (blocks PII -5.3% reaction)
- Broad oneoff: close_min 0.30→0.40 (blocks TEM 0.38, FND 0.37 low close)
- Guidance: close_max 0.93 (blocks ORCL 0.94 exhaustion)

Result: SQS 61.9 (< v6new.9 63.3) due to trade count 118→106.
However, these fixes would have prevented ~$1,500 in paper trading losses
(TEM -$541, PII -$402, ORCL -$386, FND -$129).

Trade-off: historical SQS vs live loss prevention. The gates are correct
for live trading even if they reduce backtest SQS.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 3c13c9e1b5 Add vix_pead regime sizing mode and macro experiments (v6new.19-21)
New in allocator.py:
- vix_pead mode: boosts sizing at VIX>18 (PEAD favorable), penalizes VIX 15-18
- Fixed vix_scaler application to support boost (scaler > 1.0)

Results:
- v6new.19 (spy_qqq risk_off=0.55): SQS 62.8 — reduces size in favorable PEAD regime
- v6new.21 (vix_pead boost+penalty): SQS 46.9 — penalty too aggressive, kills trades

VIX signal is real (62.3% vs 48.2% WR) but sizing alone can't capture it:
- Boosting doesn't help because same trades just get bigger
- Penalizing shrinks or drops trades, losing count
- Need the signal in TRADE SELECTION, not just sizing

v6new.9 (SQS 63.3) remains best.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 8dacdaab4e Add v10 macro regime scoring (VIX+HY) and FRED macro features — SQS 59.1 (rejected)
New features:
- _enrich_macro_features() in snapshot_export: adds macro_vix, macro_hy_spread from FRED
- compute_return_max_long_score_v10: +12% bonus in favorable regime (VIX>18+HY>3.25)
- _macro_regime_score(): regime-aware scoring component

Findings:
- VIX signal is statistically strong: 62.3% WR (VIX>18+HY>3.25) vs 50.8% (other)
- But scoring bonus promotes marginal trades, diluting OOS quality
- Same pattern as eps_growth, drift bonus: raw signal ≠ scoring improvement
- v6new.17 SQS 59.1 < v6new.9 SQS 63.3

v6new.9 remains best at SQS 63.3 after 17 experiments.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 75de2493f0 Add v6new.14-16 (execution tuning) — all worse, v6new.9 (63.3) holds
v6new.14 (warmup 9d, hold 30d): SQS 61.2 — 100% WFV positive but DD 8.6% hurts RQS
v6new.15 (tighter early exit d2/r0.20): SQS 58.6 — too aggressive cutting
v6new.16 (warmup 8d, hold 27d): SQS 59.8 — RM worst -4.11% degrades

Execution parameters are already optimal in v6new.9. 16 experiments done.
v6new.9 confirmed as final best at SQS 63.3.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim a1a0209342 Add v6new.12-13 (risk sizing tuning) — neutral, v6new.9 (63.3) confirmed optimal
v6new.12: per_trade_risk 0.052->0.062 → SQS 63.2 (neutral)
v6new.13: daily_risk 0.76->0.95, max_positions 24->30 → SQS 63.3 (same)

Risk sizing changes don't help — strategy is signal-limited, not capital-limited.
v6new.9 remains #1 at SQS 63.3.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 5f470b73da Add v6new.11 (engine tuning) — SQS 62.7, v6new.9 (63.3) remains best
Widened mixed_notprovided gap cap 0.08->0.15, tightened bullish_raised_strong
(mcap>10B, reaction<15%). WFV gap improved to 9.85% but lost 2 trades vs v6new.9.

Final standings: v6new.9 (SQS 63.3) > v6.29 (62.8) > v6new.11 (62.7)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 0e62b01c89 Add v6new.10 (engine pruning) — SQS 61.9, confirms v6new.9 remains best at 63.3
Pruned bullish_raised_strong (OOS -16.7%) and unknown_ome (OOS 0% WR) from v6new.9.
Result: trade count dropped 118->105, activity penalty offset the quality gain.
v6new.9 (SQS 63.3) confirmed as new #1 over v6.29 (62.8).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 5d728298cf Add v6new.9: coverage expansion with tuned risk — SQS 63.3 beats v6.29 (62.8)
v6new.9 adds 2 post-market engines with conservative risk sizing:
- bullish_raised_strong: 1.5% risk, 3.0 ATR stop, 10% budget
- mixed_notprovided_postmarket: 1.0% risk, 3.0 ATR stop, 5% budget

Results vs v6.29 (same OOT conditions, 252d windows):
- SQS: 62.8 -> 63.3 (+0.5)
- Trades: 111 -> 118 (+7), test 23 -> 28 (+5)
- WFV: 91.7% positive (same), gap 12.35% -> 10.35%
- Train DD: 6.79% -> 6.34%

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 85c4d98987 Add v6new experiment suite: scoring v8/v9/v9g, cross-event drift, coverage engines
Scoring additions (libs/backtest/scoring.py):
- v8: conditional financial bonus (eps_growth_qoq/revenue_growth_qoq)
- v9: cross-event drift momentum (+/-10% from prior same-ticker 5d return)
- v9g: gated variant — reject events with negative prior drift

Snapshot export (libs/export/snapshot_export.py):
- _enrich_prior_event_drift: computes prior_event_fwd5d for all snapshots
- smallcap-liquid-long-v1 universe profile ($500M-$2B)
- market_cap_max support in screener and filtering

8 experiment configs (v6new.1-v6new.8):
- v6new.1: unknown event reclassification (neutral)
- v6new.2: financial features (neutral, EPS growth is noise)
- v6new.3: small-cap (blocked, survivorship bias)
- v6new.4-6: cross-event drift variants (rejected)
- v6new.7: engine pruning (quality up, count down)
- v6new.8: coverage expansion with 2 new post-market engines (best result)

Best result: v6new.8 SQS 41.5 vs v6.29 control 32.3 on same conditions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 months ago
I Luk Kim 02542248b7 Add attention-aware PEAD caps and promote step75 5 months ago
I Luk Kim b507fbf499 Add attention client and continue PEAD research 5 months ago
I Luk Kim d3e4c1d0d5 chore: add runs/ to .gitignore
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
5 months ago
I Luk Kim c646303423 Recalibrate public SQS and exposure-aware tracking 5 months ago