Add backtest pipeline, betting_brain filters, score coherence + social v3

betting_brain.py:
- HARD_MIN_SAMPLES=50 floor for calibrator bypass
- ev_edge < 0 + >= 0.20 hard vetoes
- BTTS muted (grid search found no profitable config)
- Per-market optimal envelopes (MS, OU25)
- Score coherence filter: main_pick must agree with score prediction
- HTFT reversal cross-check for MS picks

feature_builder.py / data_loader.py:
- Real home/away_position from data (was hardcoded 10)
- Cup detection wired into UpsetEngine
- _estimate_league_position with 300-day season filter

New scripts:
- diagnostic_backtest.py: per-bet diagnostic backtest with loss patterns
- optimize_filters.py: grid search per-market optimal thresholds
- analyze_backtest_csv.py: root-cause hypothesis testing on CSV
- compare_backtests.py: side-by-side validation with verdict
- test_score_coherence.py: smoke test for coherence filter (20/20 pass)

Reports:
- diagnostic_backtest_20260525_024437 (50-match smoke)
- diagnostic_backtest_20260525_035649 (1000-match in-sample)
- filter_optimization_patch.json (grid search winners per market)

Social poster v3:
- satori + resvg HTML/CSS rendering pipeline
- Twemoji football/basketball + flag SVGs
- caption SEO: 12 curated hashtags per post
- image SEO: descriptive filenames + .json metadata sidecar
- /health, /preview-png, /run-now endpoints

Docs:
- mds/SESSION_HANDOFF.md: full session state for cross-machine continuity
- mds/SOCIAL_POSTER_SETUP.md: API keys + test commands

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-25 20:43:28 +03:00
parent b619c2454a
commit 988ee2f50d
36 changed files with 5268 additions and 46 deletions
@@ -0,0 +1,86 @@
==============================================================================
DIAGNOSTIC BACKTEST REPORT
==============================================================================
Generated: 2026-05-25T03:56:49
Sample window: start=-14d, end=now
Max matches: 1000
Excluded days: ['2026-04-29', '2026-05-03']
OVERALL
------------------------------------------------------------------------------
n_total : 1000
n_playable_settled : 524
wins : 287
losses : 237
hit_rate_pct : 54.77
unit_profit : -17.897
staked : 107.0
roi_pct : -16.73
PER MARKET
------------------------------------------------------------------------------
market n hit% profit roi%
OU25 236 56.78 -6.271 -12.93
BTTS 205 51.22 -8.89 -21.63
MS 76 57.89 -2.396 -14.98
DC 4 100.0 0.26 32.5
OU35 3 0.0 -0.6 -100.0
PER CALIBRATED CONFIDENCE BAND
------------------------------------------------------------------------------
band n hit% roi%
45-50 8 50.0 -20.11
50-55 5 40.0 -49.23
55-60 52 53.85 -6.36
60-65 33 48.48 -24.39
65-70 420 55.48 -16.52
70-80 6 66.67 -33.75
PER ODDS BAND
------------------------------------------------------------------------------
band n hit% roi%
1.3-1.5 241 61.41 -15.12
1.5-1.8 221 52.04 -15.63
1.8-2.2 56 41.07 -22.86
2.2-3.0 5 20.0 -44.15
3.0-5.0 1 0.0 -100.0
LEAGUE vs CUP
------------------------------------------------------------------------------
league n= 524 hit=54.77% roi=-16.73%
LOSS DIAGNOSTICS
------------------------------------------------------------------------------
total losses: 237
total lost units: -48.7
By market: [('OU25', 102), ('BTTS', 100), ('MS', 32), ('OU35', 3)]
Loss patterns (count, % of losses):
high_htft_reversal_prob (>=0.20) 0 (0.0%)
cup_match 0 (0.0%)
low_league_reliability (<0.45) 42 (17.72%)
v27_disagree 60 (25.32%)
trap_market_flagged 81 (34.18%)
low_calibrated_conf (<55) 7 (2.95%)
high_odds_underdog (>=2.5) 4 (1.69%)
low_data_quality (<0.55) 40 (16.88%)
high_risk_level 20 (8.44%)
inferred_features 0 (0.0%)
Top betting_brain issues seen in losses:
triple_value_not_confirmed 230
trap_market_market_overpriced 81
low_reliability_league 40
v25_v27_soft_disagreement 10
engine_consensus_disagree 5
historical_sample_too_low 3
very_low_reliability_league 2
htft_reversal_prob_minor=0.13 1
Top betting_brain vetoes (in losses — i.e. veto fired but bet still went through value-sniper override):
RECOMMENDATIONS
------------------------------------------------------------------------------
• [raise_confidence_threshold]
confidence_band: 65-70
evidence: n=420, roi=-16.52%
suggested_fix: Raise MIN_BET_SCORE or market_min_conf above 65
==============================================================================