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,51 @@
match_id,match_date,league_id,score_home,score_away,ht_score_home,ht_score_away,market,pick,odds,stake_units,playable,won,unit_profit,raw_confidence,calibrated_confidence,play_score,ev_edge,bet_grade,is_value_sniper,bb_score,bb_action,bb_vetoes,bb_issues,bb_positives,bb_model_prob,bb_implied_prob,bb_model_market_gap,bb_divergence,bb_trap_market,v27_consensus,data_quality_score,data_quality_flags,risk_level,odds_reliability,htft_reversal_prob,htft_top_pick,league_name,is_cup,model_version,decision_reason
5iam9c9dw3ggz3y1ohr9uh53o,2026-05-24,8nbwkj392b0xzssqpw9jwmzdn,0,0,0,0,,,,1.0,False,,0.0,,,,,,False,,,,,,,,,,False,AGREE,0.33,missing_full_ms_odds;lineup_unavailable;lineup_incomplete;missing_referee;ai_features_inferred_from_history,MEDIUM,,,,,False,v28-pro-max,no_bet_conditions_met
8c90p2ft4zxjdck8wlgq1a61g,2026-05-24,a9vrdkelbgif0gtu3wxsr75xo,2,2,0,0,OU25,Üst,1.41,0.2,True,True,0.082,59.5,65.4,58.4,-0.1557,B,True,26.4,BET,,inferred_statistical_features;trap_market_market_overpriced;triple_value_not_confirmed,base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample,0.5955,0.7092,-0.1137,0.0339,True,DISAGREE,0.74,ai_features_inferred_from_history,MEDIUM,0.6618,,,,False,v28-pro-max,betting_brain_approved
9ljz1grea3a8jajif4e9b7bpw,2026-05-24,2wolc27r8z03itcvwp43e38c5,1,1,1,1,BTTS,KG Var,1.62,0.2,True,True,0.124,53.7,69.9,48.4,-0.1476,B,True,1.6,BET,,inferred_statistical_features;trap_market_market_overpriced;triple_value_not_confirmed,base_model_playable;value_sniper_override;strong_historical_sample,0.5371,0.6173,-0.0802,,True,AGREE,0.74,lineup_probable_not_confirmed;missing_referee;ai_features_inferred_from_history,HIGH,0.5592,,,,False,v28-pro-max,betting_brain_approved
1r7iq0nhg2b674jpcm92ragpg,2026-05-24,1zp1du9n4rj36p1ss9zbxtqfb,4,0,1,0,BTTS,KG Var,1.89,0.2,True,False,-0.2,53.2,69.9,52.9,-0.0832,B,True,0.0,BET,,inferred_statistical_features;trap_market_market_overpriced;triple_value_not_confirmed,base_model_playable;value_sniper_override;strong_historical_sample,0.5317,0.5291,0.0026,,True,AGREE,0.74,lineup_probable_not_confirmed;missing_referee;ai_features_inferred_from_history,HIGH,0.5353,,,,False,v28-pro-max,betting_brain_approved
70dgok3yq76g076vemaps0178,2026-05-24,6lwpjhktjhl9g7x2w7njmzva6,2,1,1,0,BTTS,KG Var,1.74,0.2,True,True,0.148,51.9,68.4,60.4,-0.1255,B,True,15.7,BET,,inferred_statistical_features;trap_market_market_overpriced;triple_value_not_confirmed,base_model_playable;value_sniper_override;strong_historical_sample,0.5192,0.5747,-0.0555,,True,AGREE,0.74,ai_features_inferred_from_history,MEDIUM,0.6164,,,,False,v28-pro-max,betting_brain_approved
72q9d4uimmby6g6bor26taz9w,2026-05-24,6jgwiu2gq3dllmrwt45pfdn2z,2,0,2,0,,,,1.0,False,,0.0,,,,,,False,,,,,,,,,,False,AGREE,0.555,missing_full_ms_odds;lineup_probable_not_confirmed;lineup_projection_low_confidence;lineup_incomplete;missing_referee;ai_features_inferred_from_history,LOW,,,,,False,v28-pro-max,no_bet_conditions_met
67dd2t7043kv0yw1zj1buwdg4,2026-05-24,8n9w0n3i9kk05echhtmstn6o9,1,1,0,0,,,,1.0,False,,0.0,,,,,,False,,,,,,,,,,False,AGREE,0.698,missing_full_ms_odds;lineup_probable_not_confirmed;missing_referee;ai_features_inferred_from_history,MEDIUM,,,,,False,v28-pro-max,no_bet_conditions_met
ejdwfph35q57phtfz7jr8st1w,2026-05-24,8ey0ww2zsosdmwr8ehsorh6t7,0,2,0,0,BTTS,KG Var,1.82,0.2,True,False,-0.2,53.2,69.9,63.5,-0.1097,B,True,12.1,BET,,inferred_statistical_features;trap_market_market_overpriced;triple_value_not_confirmed,base_model_playable;value_sniper_override;strong_historical_sample,0.5317,0.5495,-0.0178,,True,DISAGREE,0.74,live_match_pre_match_features;ai_features_inferred_from_history,MEDIUM,0.51,,X/X,,False,v28-pro-max,betting_brain_approved
68y8tlfnilw5trs1oqi4dhfkk,2026-05-24,8n9w0n3i9kk05echhtmstn6o9,2,2,1,1,,,,1.0,False,,0.0,,,,,,False,,,,,,,,,,False,DISAGREE,0.535,missing_full_ms_odds;lineup_probable_not_confirmed;lineup_projection_low_confidence;lineup_incomplete;missing_referee;ai_features_inferred_from_history,MEDIUM,,,,,False,v28-pro-max,no_bet_conditions_met
68fghiwdtwspk1m0ft5mspzx0,2026-05-24,8n9w0n3i9kk05echhtmstn6o9,1,2,1,2,,,,1.0,False,,0.0,,,,,,False,,,,,,,,,,False,DISAGREE,0.602,missing_full_ms_odds;lineup_probable_not_confirmed;lineup_projection_low_confidence;lineup_incomplete;missing_referee;ai_features_inferred_from_history,MEDIUM,,,,,False,v28-pro-max,no_bet_conditions_met
a1kqq0ggywfl6sl4srntxy2hg,2026-05-24,3ww12jab49q8q8mk9avdwjqgk,1,1,1,0,OU25,Üst,1.62,0.2,True,False,-0.2,61.4,65.4,60.6,-0.148,B,True,27.0,BET,,inferred_statistical_features;trap_market_market_overpriced;triple_value_not_confirmed,base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample,0.6144,0.6173,-0.0029,0.0854,True,AGREE,0.74,live_match_pre_match_features;ai_features_inferred_from_history,MEDIUM,0.5961,,,,False,v28-pro-max,betting_brain_approved
a1vpp4i6t61v7qm3dfy6iuj2s,2026-05-24,3ww12jab49q8q8mk9avdwjqgk,2,1,0,0,,,,1.0,False,,0.0,,,,,,False,,,,,,,,,,False,AGREE,0.74,missing_full_ms_odds;live_match_pre_match_features;ai_features_inferred_from_history,LOW,,,,,False,v28-pro-max,no_bet_conditions_met
28rk26zqah60qj7h78qh5beac,2026-05-24,663a54fmymndjeev47qm7d3nf,2,2,2,1,OU25,Üst,1.39,0.2,True,True,0.078,61.1,65.4,57.5,-0.2039,B,True,13.3,BET,,low_reliability_league;inferred_statistical_features;trap_market_market_overpriced;triple_value_not_confirmed,base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample,0.6107,0.7194,-0.1087,0.0577,True,AGREE,0.74,lineup_probable_not_confirmed;missing_referee;ai_features_inferred_from_history,MEDIUM,0.3522,,,,False,v28-pro-max,betting_brain_approved
a26stt54g5ju5ecodpcbcqxw4,2026-05-24,3ww12jab49q8q8mk9avdwjqgk,2,2,1,1,BTTS,KG Var,2.05,0.2,True,True,0.21,53.7,69.9,70.6,0.0354,B,True,33.5,BET,,inferred_statistical_features;triple_value_not_confirmed,base_model_playable;value_sniper_override;usable_historical_sample,0.5371,0.4878,0.0493,,False,AGREE,0.74,live_match_pre_match_features;ai_features_inferred_from_history,MEDIUM,0.5961,,,,False,v28-pro-max,betting_brain_approved
318rrnl9b1vlenjd9hwahpvro,2026-05-24,9z5643nd06afqu01ea2wt8y4g,1,0,0,0,DC,1X,1.12,0.0,False,True,0.0,73.5,73.5,72.9,-0.0553,PASS,True,41.8,WATCH_NO_VALUE,odds_below_minimum,base_model_not_playable;inferred_statistical_features,value_sniper_override;v25_v27_aligned;triple_value_confirmed;usable_historical_sample,0.7351,0.8929,-0.1578,0.031,False,AGREE,0.51,lineup_unavailable;lineup_incomplete;missing_referee;ai_features_inferred_from_history,MEDIUM,0.8734,,,,False,v28-pro-max,betting_brain_no_value_odds_below_minimum
65tlfs3m6sc70261z37i90jys,2026-05-24,89ovpy1rarewwzqvi30bfdr8b,4,3,1,1,OU25,Üst,1.36,0.2,True,True,0.072,60.2,65.4,53.5,-0.2107,B,True,24.8,BET,,inferred_statistical_features;trap_market_market_overpriced;triple_value_not_confirmed,base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample,0.6018,0.7353,-0.1335,0.0982,True,AGREE,0.74,live_match_pre_match_features;ai_features_inferred_from_history,MEDIUM,0.7068,,,,False,v28-pro-max,betting_brain_approved
ei6nilo5074tnb17kvv37oy6s,2026-05-24,3j81qr7yc4gdnakfwnxf95ovh,1,1,1,1,MS,2,1.11,0.0,False,False,0.0,75.5,90.9,66.9,-0.0497,PASS,True,0.0,WATCH_NO_VALUE,odds_below_minimum,base_model_not_playable;inferred_statistical_features;v25_v27_soft_disagreement;triple_value_not_confirmed,value_sniper_override;strong_historical_sample,0.7554,0.9009,-0.1455,0.204,False,AGREE,0.51,lineup_probable_not_confirmed;lineup_projection_low_confidence;lineup_incomplete;missing_referee;ai_features_inferred_from_history,MEDIUM,0.8771,0.0,,,False,v28-pro-max,betting_brain_no_value_odds_below_minimum
cx8nb7w3nmell38mta1umh2qc,2026-05-24,54c65mhi143utomzvvv3q2avh,0,2,0,0,,,,1.0,False,,0.0,,,,,,False,,,,,,,,,,False,AGREE,0.726,missing_full_ms_odds;lineup_probable_not_confirmed;missing_referee;ai_features_inferred_from_history,MEDIUM,,,,,False,v28-pro-max,no_bet_conditions_met
53348iqniod61z7xurb4tx250,2026-05-24,477yyajzheg2z8u7uick0e13e,2,0,0,0,OU25,Üst,1.93,0.2,True,False,-0.2,59.5,65.4,71.3,0.0414,B,True,45.8,BET,,inferred_statistical_features;triple_value_not_confirmed,base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample,0.5955,0.5181,0.0774,0.1084,False,AGREE,0.74,lineup_probable_not_confirmed;ai_features_inferred_from_history,MEDIUM,0.4706,,,,False,v28-pro-max,betting_brain_approved
2hw717s7fxi2v2w53kdsplhqs,2026-05-24,8najqkluatpaxvqws78b9s17c,1,1,0,0,DC,12,1.24,0.0,False,False,0.0,70.0,70.0,61.2,-0.12,PASS,True,0.0,WATCH_NO_VALUE,odds_below_minimum,base_model_not_playable;inferred_statistical_features;trap_market_market_overpriced;triple_value_not_confirmed,value_sniper_override;v25_v27_aligned;strong_historical_sample,0.7001,0.8065,-0.1064,0.0075,True,AGREE,0.51,lineup_unavailable;lineup_incomplete;missing_referee;ai_features_inferred_from_history,HIGH,0.5082,,,,False,v28-pro-max,betting_brain_no_value_odds_below_minimum
1q1s55dy4d4z4gs34qk6vx9n8,2026-05-24,cegl2ivkc25blcatxp4jmk1ec,1,0,1,0,OU25,Üst,2.03,0.2,True,False,-0.2,50.0,57.7,54.3,0.0546,B,True,35.7,BET,,inferred_statistical_features;triple_value_not_confirmed,base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample,0.5,0.4926,0.0074,0.0555,False,AGREE,0.74,lineup_probable_not_confirmed;missing_referee;ai_features_inferred_from_history,HIGH,0.5993,,,,False,v28-pro-max,betting_brain_approved
648u8zd49cwcxpspmvinlmexg,2026-05-24,1eruend45vd20g9hbrpiggs5u,1,0,0,0,MS,1,1.32,0.2,True,True,0.064,63.1,65.5,55.7,-0.0828,B,True,39.4,BET,,inferred_statistical_features;triple_value_not_confirmed,base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample,0.6313,0.7576,-0.1263,0.0683,False,AGREE,0.74,lineup_probable_not_confirmed;missing_referee;ai_features_inferred_from_history,MEDIUM,0.8083,0.0,,,False,v28-pro-max,betting_brain_approved
1psnufak57w8dfs9e5cvbmgwk,2026-05-24,cegl2ivkc25blcatxp4jmk1ec,3,0,2,0,BTTS,KG Var,1.94,0.2,True,False,-0.2,53.7,69.9,53.1,-0.0765,B,True,5.3,BET,,inferred_statistical_features;trap_market_market_overpriced;triple_value_not_confirmed,base_model_playable;value_sniper_override;strong_historical_sample,0.5371,0.5155,0.0216,,True,AGREE,0.74,lineup_probable_not_confirmed;missing_referee;ai_features_inferred_from_history,HIGH,0.5993,,,,False,v28-pro-max,betting_brain_approved
921kqaviappxt0w1kfmq1ek2c,2026-05-24,byu00jvt1j6csyv4y1lkt2fm2,1,0,1,0,DC,X2,1.18,0.0,False,False,0.0,75.8,75.8,74.9,-0.1267,PASS,True,0.0,WATCH_NO_VALUE,odds_below_minimum,inferred_statistical_features;v25_v27_soft_disagreement;trap_market_market_overpriced;triple_value_not_confirmed;engine_consensus_disagree,base_model_playable;value_sniper_override;strong_historical_sample,0.7584,0.8475,-0.0891,0.1783,True,DISAGREE,0.74,ai_features_inferred_from_history,MEDIUM,0.5359,,,,False,v28-pro-max,betting_brain_no_value_odds_below_minimum
3m11hvh2fzailt3ykd0uhzz84,2026-05-24,54c65mhi143utomzvvv3q2avh,0,0,0,0,,,,1.0,False,,0.0,,,,,,False,,,,,,,,,,False,AGREE,0.591,missing_full_ms_odds;lineup_probable_not_confirmed;lineup_projection_low_confidence;lineup_incomplete;missing_referee;ai_features_inferred_from_history,MEDIUM,,,,,False,v28-pro-max,no_bet_conditions_met
7kvvf6blnps2xk15100ccdedw,2026-05-24,4zwgbb66rif2spcoeeol2motx,5,0,3,0,BTTS,KG Var,1.33,0.2,True,False,-0.2,57.1,69.9,62.3,-0.1512,B,True,29.1,BET,,inferred_statistical_features;triple_value_not_confirmed,base_model_playable;value_sniper_override;strong_historical_sample,0.5707,0.7519,-0.1812,,False,AGREE,0.74,live_match_pre_match_features;ai_features_inferred_from_history,MEDIUM,0.6995,,1/1,,False,v28-pro-max,betting_brain_approved
7liir8zj32o7m2udr7cknb8d0,2026-05-24,4zwgbb66rif2spcoeeol2motx,3,0,2,0,OU25,Üst,1.33,0.2,True,True,0.066,61.4,65.4,58.3,-0.1437,B,True,27.0,BET,,inferred_statistical_features;trap_market_market_overpriced;triple_value_not_confirmed,base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample,0.6144,0.7519,-0.1375,0.0279,True,AGREE,0.74,live_match_pre_match_features;ai_features_inferred_from_history,MEDIUM,0.6995,,1/1,,False,v28-pro-max,betting_brain_approved
7l74ilyz7olljclexvn8tbjtg,2026-05-24,4zwgbb66rif2spcoeeol2motx,5,1,4,0,BTTS,KG Var,1.55,0.2,True,True,0.11,57.1,69.9,68.2,-0.0873,B,True,32.7,BET,,inferred_statistical_features;triple_value_not_confirmed,base_model_playable;value_sniper_override;strong_historical_sample,0.5707,0.6452,-0.0745,,False,AGREE,0.74,live_match_pre_match_features;ai_features_inferred_from_history,MEDIUM,0.6995,,1/1,,False,v28-pro-max,betting_brain_approved
8f6gex4eh119d2hh9y2zb5clw,2026-05-24,3is4bkgf3loxv9qfg3hm8zfqb,2,0,2,0,OU25,Üst,1.49,0.2,True,False,-0.2,66.5,65.4,77.9,0.0081,B,True,50.1,BET,,inferred_statistical_features;triple_value_not_confirmed,base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample,0.6651,0.6711,-0.006,0.1144,False,AGREE,0.74,live_match_pre_match_features;ai_features_inferred_from_history,LOW,0.5033,,1/1,,False,v28-pro-max,betting_brain_approved
8ee7ipt4u6kyk6baueedsdafo,2026-05-24,3is4bkgf3loxv9qfg3hm8zfqb,0,2,0,2,BTTS,KG Var,1.69,0.2,True,False,-0.2,54.3,69.9,64.7,-0.0792,B,True,27.6,BET,,inferred_statistical_features;triple_value_not_confirmed,base_model_playable;value_sniper_override;strong_historical_sample,0.5433,0.5917,-0.0484,,False,AGREE,0.74,live_match_pre_match_features;ai_features_inferred_from_history,MEDIUM,0.5033,,2/2,,False,v28-pro-max,betting_brain_approved
8fydg367drpc25r1bobxqj3f8,2026-05-24,3is4bkgf3loxv9qfg3hm8zfqb,3,1,2,1,OU25,Üst,1.61,0.2,True,True,0.122,50.1,57.7,50.7,-0.1072,B,True,35.0,BET,,inferred_statistical_features;triple_value_not_confirmed,base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample,0.5009,0.6211,-0.1202,0.0553,False,AGREE,0.74,live_match_pre_match_features;ai_features_inferred_from_history,MEDIUM,0.5033,,,,False,v28-pro-max,betting_brain_approved
8fkdhce1peguwgnsunwoln3f8,2026-05-24,3is4bkgf3loxv9qfg3hm8zfqb,0,2,0,2,OU25,Üst,1.24,0.0,False,False,0.0,61.4,65.4,61.1,-0.1548,PASS,True,16.8,WATCH_NO_VALUE,odds_below_minimum,inferred_statistical_features;triple_value_not_confirmed;historical_sample_too_low,base_model_playable;value_sniper_override;v25_v27_aligned,0.6144,0.8065,-0.1921,0.0942,False,AGREE,0.74,live_match_pre_match_features;ai_features_inferred_from_history,LOW,0.5033,,,,False,v28-pro-max,betting_brain_no_value_odds_below_minimum
9g5hqtjja6ceqhkpghwmoy6ms,2026-05-24,2y8bntiif3a9y6gtmauv30gt,2,0,1,0,OU25,Üst,1.71,0.2,True,False,-0.2,50.1,57.7,52.6,-0.0794,B,True,36.5,BET,,inferred_statistical_features;triple_value_not_confirmed,base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample,0.5009,0.5848,-0.0839,0.0481,False,DISAGREE,0.74,ai_features_inferred_from_history,MEDIUM,0.4782,,,,False,v28-pro-max,betting_brain_approved
8h6429zr5ijqcxc8gjxygjtw4,2026-05-24,3is4bkgf3loxv9qfg3hm8zfqb,3,0,1,0,MS,1,1.33,0.2,True,True,0.066,66.1,65.5,66.7,-0.1155,B,True,0.0,BET,,inferred_statistical_features;v25_v27_soft_disagreement;trap_market_market_overpriced;triple_value_not_confirmed;htft_reversal_prob_minor=0.11,base_model_playable;value_sniper_override;strong_historical_sample,0.6614,0.7519,-0.0905,0.2583,True,AGREE,0.74,live_match_pre_match_features;ai_features_inferred_from_history,MEDIUM,0.5033,0.0814,1/1,,False,v28-pro-max,betting_brain_approved
77knm2ibdtb7akzrbltwz7axg,2026-05-24,bly7ema5au6j40i0grhl0pnub,1,1,1,0,,,,1.0,False,,0.0,,,,,,False,,,,,,,,,,False,AGREE,0.726,missing_full_ms_odds;lineup_probable_not_confirmed;missing_referee;ai_features_inferred_from_history,MEDIUM,,,,,False,v28-pro-max,no_bet_conditions_met
8es4680yd87gtmomg2jk3isyc,2026-05-24,3is4bkgf3loxv9qfg3hm8zfqb,0,1,0,0,OU25,Üst,1.53,0.2,True,False,-0.2,59.5,65.4,67.8,-0.0259,B,True,42.4,BET,,inferred_statistical_features;triple_value_not_confirmed,base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample,0.5955,0.6536,-0.0581,0.0713,False,DISAGREE,0.74,live_match_pre_match_features;ai_features_inferred_from_history,MEDIUM,0.5033,,2/2,,False,v28-pro-max,betting_brain_approved
8dmcz3k1u4ze53nvrsoz7eoes,2026-05-24,3is4bkgf3loxv9qfg3hm8zfqb,1,1,1,0,BTTS,KG Var,1.26,0.0,False,True,0.0,54.9,69.9,57.6,-0.2005,PASS,True,3.3,WATCH_NO_VALUE,odds_below_minimum,inferred_statistical_features;triple_value_not_confirmed;historical_sample_too_low,base_model_playable;value_sniper_override,0.5488,0.7937,-0.2449,,False,AGREE,0.74,live_match_pre_match_features;ai_features_inferred_from_history,LOW,0.5033,,1/1,,False,v28-pro-max,betting_brain_no_value_odds_below_minimum
8gcbai6m7v7o8piqfram4qe50,2026-05-24,3is4bkgf3loxv9qfg3hm8zfqb,3,1,2,0,HTFT,1/1,4.59,0.0,False,True,0.0,27.3,27.3,24.6,0.1657,PASS,True,0.0,REJECT,calibrated_confidence_too_low;play_score_too_low;volatile_market_requires_exceptional_evidence,inferred_statistical_features;historical_sample_too_low,base_model_playable,0.2734,0.2179,0.0555,,False,DISAGREE,0.74,live_match_pre_match_features;ai_features_inferred_from_history,MEDIUM,0.5033,,1/1,,False,v28-pro-max,betting_brain_no_safe_pick
3azy3enp78au0zfugc3l1yf4k,2026-05-24,54c65mhi143utomzvvv3q2avh,2,0,1,0,,,,1.0,False,,0.0,,,,,,False,,,,,,,,,,False,AGREE,0.532,missing_full_ms_odds;lineup_probable_not_confirmed;lineup_projection_low_confidence;lineup_incomplete;missing_referee;ai_features_inferred_from_history,MEDIUM,,,,,False,v28-pro-max,no_bet_conditions_met
1d2fb7bt5f8xy5on24w1kj1g4,2026-05-24,54c65mhi143utomzvvv3q2avh,1,0,0,0,,,,1.0,False,,0.0,,,,,,False,,,,,,,,,,False,AGREE,0.532,missing_full_ms_odds;lineup_probable_not_confirmed;lineup_projection_low_confidence;lineup_incomplete;missing_referee;ai_features_inferred_from_history,LOW,,,,,False,v28-pro-max,no_bet_conditions_met
pw01xm8v3jlz13fpi3zq0ftg,2026-05-24,3umprqta6ipyann6qjjh07biz,1,1,0,0,,,,1.0,False,,0.0,,,,,,False,,,,,,,,,,False,AGREE,0.33,missing_full_ms_odds;lineup_unavailable;lineup_incomplete;missing_referee;ai_features_inferred_from_history,MEDIUM,,,,,False,v28-pro-max,no_bet_conditions_met
mjo9k4zr1x884vjlwea2y1hw,2026-05-24,3umprqta6ipyann6qjjh07biz,1,0,1,0,,,,1.0,False,,0.0,,,,,,False,,,,,,,,,,False,AGREE,0.33,missing_full_ms_odds;lineup_unavailable;lineup_incomplete;missing_referee;ai_features_inferred_from_history,MEDIUM,,,,,False,v28-pro-max,no_bet_conditions_met
8d8fm7wli7tfx8hm9w5l8nuhg,2026-05-24,3is4bkgf3loxv9qfg3hm8zfqb,1,1,1,0,BTTS,KG Var,1.72,0.2,True,True,0.144,53.7,69.9,65.2,-0.0712,B,True,28.0,BET,,inferred_statistical_features;triple_value_not_confirmed,base_model_playable;value_sniper_override;strong_historical_sample,0.5371,0.5814,-0.0443,,False,AGREE,0.74,live_match_pre_match_features;ai_features_inferred_from_history,MEDIUM,0.5033,,,,False,v28-pro-max,betting_brain_approved
oqsq3f0kvic8xfed8dp302z8,2026-05-24,3umprqta6ipyann6qjjh07biz,3,2,0,0,,,,1.0,False,,0.0,,,,,,False,,,,,,,,,,False,AGREE,0.33,missing_full_ms_odds;lineup_unavailable;lineup_incomplete;missing_referee;ai_features_inferred_from_history,MEDIUM,,,,,False,v28-pro-max,no_bet_conditions_met
o7tn4si7fxvq9c2mg0xs48wk,2026-05-24,3umprqta6ipyann6qjjh07biz,0,1,0,0,,,,1.0,False,,0.0,,,,,,False,,,,,,,,,,False,AGREE,0.33,missing_full_ms_odds;lineup_unavailable;lineup_incomplete;missing_referee;ai_features_inferred_from_history,MEDIUM,,,,,False,v28-pro-max,no_bet_conditions_met
eh9jfegscokidyczxfq691990,2026-05-24,3j81qr7yc4gdnakfwnxf95ovh,2,3,0,1,OU25,Üst,1.44,0.2,True,True,0.088,50.1,57.7,32.9,-0.2537,B,True,17.0,BET,,inferred_statistical_features;trap_market_market_overpriced;triple_value_not_confirmed,base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample,0.5009,0.6944,-0.1935,0.0596,True,AGREE,0.51,lineup_unavailable;lineup_incomplete;missing_referee;ai_features_inferred_from_history,MEDIUM,0.8771,,,,False,v28-pro-max,betting_brain_approved
dkhhkbwnxwl47e8hybv89mwb8,2026-05-24,5jd0k2txwnq69frs79eulba8j,1,2,0,1,OU25,Üst,1.23,0.0,False,True,0.0,61.4,65.4,61.2,-0.1185,PASS,True,11.4,WATCH_NO_VALUE,odds_below_minimum,base_model_not_playable;inferred_statistical_features;triple_value_not_confirmed,value_sniper_override;v25_v27_aligned;strong_historical_sample,0.6144,0.813,-0.1986,0.0179,False,AGREE,0.74,ai_features_inferred_from_history,LOW,0.9233,,1/1,,False,v28-pro-max,betting_brain_no_value_odds_below_minimum
1lknqdz9vmb3hnqu144zkkefo,2026-05-24,1r097lpxe0xn03ihb7wi98kao,1,0,1,0,BTTS,KG Var,1.78,0.2,True,False,-0.2,50.0,61.7,55.6,-0.088,B,True,29.3,BET,,inferred_statistical_features;triple_value_not_confirmed,base_model_playable;value_sniper_override;strong_historical_sample,0.5,0.5618,-0.0618,,False,AGREE,0.74,live_match_pre_match_features;ai_features_inferred_from_history,MEDIUM,0.7391,,1/1,,False,v28-pro-max,betting_brain_approved
3oazp9kfbyyiatn246k4to6xg,2026-05-24,9ynnnx1qmkizq1o3qr3v0nsuk,1,2,0,1,BTTS,KG Var,1.36,0.2,True,True,0.072,53.7,69.9,61.2,-0.1571,B,True,33.7,BET,,inferred_statistical_features;triple_value_not_confirmed,base_model_playable;value_sniper_override;strong_historical_sample,0.5371,0.7353,-0.1982,,False,AGREE,0.74,live_match_pre_match_features;ai_features_inferred_from_history,LOW,0.554,,2/2,,False,v28-pro-max,betting_brain_approved
8cr8t6qh0r6g0mv6ftq0ic1sk,2026-05-24,a9vrdkelbgif0gtu3wxsr75xo,2,1,0,1,OU25,Üst,1.46,0.2,True,True,0.092,61.4,65.4,68.1,-0.0182,B,True,47.8,BET,,inferred_statistical_features;triple_value_not_confirmed,base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample,0.6144,0.6849,-0.0705,0.0535,False,AGREE,0.74,ai_features_inferred_from_history,MEDIUM,0.6618,,,,False,v28-pro-max,betting_brain_approved
1 match_id match_date league_id score_home score_away ht_score_home ht_score_away market pick odds stake_units playable won unit_profit raw_confidence calibrated_confidence play_score ev_edge bet_grade is_value_sniper bb_score bb_action bb_vetoes bb_issues bb_positives bb_model_prob bb_implied_prob bb_model_market_gap bb_divergence bb_trap_market v27_consensus data_quality_score data_quality_flags risk_level odds_reliability htft_reversal_prob htft_top_pick league_name is_cup model_version decision_reason
2 5iam9c9dw3ggz3y1ohr9uh53o 2026-05-24 8nbwkj392b0xzssqpw9jwmzdn 0 0 0 0 1.0 False 0.0 False False AGREE 0.33 missing_full_ms_odds;lineup_unavailable;lineup_incomplete;missing_referee;ai_features_inferred_from_history MEDIUM False v28-pro-max no_bet_conditions_met
3 8c90p2ft4zxjdck8wlgq1a61g 2026-05-24 a9vrdkelbgif0gtu3wxsr75xo 2 2 0 0 OU25 Üst 1.41 0.2 True True 0.082 59.5 65.4 58.4 -0.1557 B True 26.4 BET inferred_statistical_features;trap_market_market_overpriced;triple_value_not_confirmed base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample 0.5955 0.7092 -0.1137 0.0339 True DISAGREE 0.74 ai_features_inferred_from_history MEDIUM 0.6618 False v28-pro-max betting_brain_approved
4 9ljz1grea3a8jajif4e9b7bpw 2026-05-24 2wolc27r8z03itcvwp43e38c5 1 1 1 1 BTTS KG Var 1.62 0.2 True True 0.124 53.7 69.9 48.4 -0.1476 B True 1.6 BET inferred_statistical_features;trap_market_market_overpriced;triple_value_not_confirmed base_model_playable;value_sniper_override;strong_historical_sample 0.5371 0.6173 -0.0802 True AGREE 0.74 lineup_probable_not_confirmed;missing_referee;ai_features_inferred_from_history HIGH 0.5592 False v28-pro-max betting_brain_approved
5 1r7iq0nhg2b674jpcm92ragpg 2026-05-24 1zp1du9n4rj36p1ss9zbxtqfb 4 0 1 0 BTTS KG Var 1.89 0.2 True False -0.2 53.2 69.9 52.9 -0.0832 B True 0.0 BET inferred_statistical_features;trap_market_market_overpriced;triple_value_not_confirmed base_model_playable;value_sniper_override;strong_historical_sample 0.5317 0.5291 0.0026 True AGREE 0.74 lineup_probable_not_confirmed;missing_referee;ai_features_inferred_from_history HIGH 0.5353 False v28-pro-max betting_brain_approved
6 70dgok3yq76g076vemaps0178 2026-05-24 6lwpjhktjhl9g7x2w7njmzva6 2 1 1 0 BTTS KG Var 1.74 0.2 True True 0.148 51.9 68.4 60.4 -0.1255 B True 15.7 BET inferred_statistical_features;trap_market_market_overpriced;triple_value_not_confirmed base_model_playable;value_sniper_override;strong_historical_sample 0.5192 0.5747 -0.0555 True AGREE 0.74 ai_features_inferred_from_history MEDIUM 0.6164 False v28-pro-max betting_brain_approved
7 72q9d4uimmby6g6bor26taz9w 2026-05-24 6jgwiu2gq3dllmrwt45pfdn2z 2 0 2 0 1.0 False 0.0 False False AGREE 0.555 missing_full_ms_odds;lineup_probable_not_confirmed;lineup_projection_low_confidence;lineup_incomplete;missing_referee;ai_features_inferred_from_history LOW False v28-pro-max no_bet_conditions_met
8 67dd2t7043kv0yw1zj1buwdg4 2026-05-24 8n9w0n3i9kk05echhtmstn6o9 1 1 0 0 1.0 False 0.0 False False AGREE 0.698 missing_full_ms_odds;lineup_probable_not_confirmed;missing_referee;ai_features_inferred_from_history MEDIUM False v28-pro-max no_bet_conditions_met
9 ejdwfph35q57phtfz7jr8st1w 2026-05-24 8ey0ww2zsosdmwr8ehsorh6t7 0 2 0 0 BTTS KG Var 1.82 0.2 True False -0.2 53.2 69.9 63.5 -0.1097 B True 12.1 BET inferred_statistical_features;trap_market_market_overpriced;triple_value_not_confirmed base_model_playable;value_sniper_override;strong_historical_sample 0.5317 0.5495 -0.0178 True DISAGREE 0.74 live_match_pre_match_features;ai_features_inferred_from_history MEDIUM 0.51 X/X False v28-pro-max betting_brain_approved
10 68y8tlfnilw5trs1oqi4dhfkk 2026-05-24 8n9w0n3i9kk05echhtmstn6o9 2 2 1 1 1.0 False 0.0 False False DISAGREE 0.535 missing_full_ms_odds;lineup_probable_not_confirmed;lineup_projection_low_confidence;lineup_incomplete;missing_referee;ai_features_inferred_from_history MEDIUM False v28-pro-max no_bet_conditions_met
11 68fghiwdtwspk1m0ft5mspzx0 2026-05-24 8n9w0n3i9kk05echhtmstn6o9 1 2 1 2 1.0 False 0.0 False False DISAGREE 0.602 missing_full_ms_odds;lineup_probable_not_confirmed;lineup_projection_low_confidence;lineup_incomplete;missing_referee;ai_features_inferred_from_history MEDIUM False v28-pro-max no_bet_conditions_met
12 a1kqq0ggywfl6sl4srntxy2hg 2026-05-24 3ww12jab49q8q8mk9avdwjqgk 1 1 1 0 OU25 Üst 1.62 0.2 True False -0.2 61.4 65.4 60.6 -0.148 B True 27.0 BET inferred_statistical_features;trap_market_market_overpriced;triple_value_not_confirmed base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample 0.6144 0.6173 -0.0029 0.0854 True AGREE 0.74 live_match_pre_match_features;ai_features_inferred_from_history MEDIUM 0.5961 False v28-pro-max betting_brain_approved
13 a1vpp4i6t61v7qm3dfy6iuj2s 2026-05-24 3ww12jab49q8q8mk9avdwjqgk 2 1 0 0 1.0 False 0.0 False False AGREE 0.74 missing_full_ms_odds;live_match_pre_match_features;ai_features_inferred_from_history LOW False v28-pro-max no_bet_conditions_met
14 28rk26zqah60qj7h78qh5beac 2026-05-24 663a54fmymndjeev47qm7d3nf 2 2 2 1 OU25 Üst 1.39 0.2 True True 0.078 61.1 65.4 57.5 -0.2039 B True 13.3 BET low_reliability_league;inferred_statistical_features;trap_market_market_overpriced;triple_value_not_confirmed base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample 0.6107 0.7194 -0.1087 0.0577 True AGREE 0.74 lineup_probable_not_confirmed;missing_referee;ai_features_inferred_from_history MEDIUM 0.3522 False v28-pro-max betting_brain_approved
15 a26stt54g5ju5ecodpcbcqxw4 2026-05-24 3ww12jab49q8q8mk9avdwjqgk 2 2 1 1 BTTS KG Var 2.05 0.2 True True 0.21 53.7 69.9 70.6 0.0354 B True 33.5 BET inferred_statistical_features;triple_value_not_confirmed base_model_playable;value_sniper_override;usable_historical_sample 0.5371 0.4878 0.0493 False AGREE 0.74 live_match_pre_match_features;ai_features_inferred_from_history MEDIUM 0.5961 False v28-pro-max betting_brain_approved
16 318rrnl9b1vlenjd9hwahpvro 2026-05-24 9z5643nd06afqu01ea2wt8y4g 1 0 0 0 DC 1X 1.12 0.0 False True 0.0 73.5 73.5 72.9 -0.0553 PASS True 41.8 WATCH_NO_VALUE odds_below_minimum base_model_not_playable;inferred_statistical_features value_sniper_override;v25_v27_aligned;triple_value_confirmed;usable_historical_sample 0.7351 0.8929 -0.1578 0.031 False AGREE 0.51 lineup_unavailable;lineup_incomplete;missing_referee;ai_features_inferred_from_history MEDIUM 0.8734 False v28-pro-max betting_brain_no_value_odds_below_minimum
17 65tlfs3m6sc70261z37i90jys 2026-05-24 89ovpy1rarewwzqvi30bfdr8b 4 3 1 1 OU25 Üst 1.36 0.2 True True 0.072 60.2 65.4 53.5 -0.2107 B True 24.8 BET inferred_statistical_features;trap_market_market_overpriced;triple_value_not_confirmed base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample 0.6018 0.7353 -0.1335 0.0982 True AGREE 0.74 live_match_pre_match_features;ai_features_inferred_from_history MEDIUM 0.7068 False v28-pro-max betting_brain_approved
18 ei6nilo5074tnb17kvv37oy6s 2026-05-24 3j81qr7yc4gdnakfwnxf95ovh 1 1 1 1 MS 2 1.11 0.0 False False 0.0 75.5 90.9 66.9 -0.0497 PASS True 0.0 WATCH_NO_VALUE odds_below_minimum base_model_not_playable;inferred_statistical_features;v25_v27_soft_disagreement;triple_value_not_confirmed value_sniper_override;strong_historical_sample 0.7554 0.9009 -0.1455 0.204 False AGREE 0.51 lineup_probable_not_confirmed;lineup_projection_low_confidence;lineup_incomplete;missing_referee;ai_features_inferred_from_history MEDIUM 0.8771 0.0 False v28-pro-max betting_brain_no_value_odds_below_minimum
19 cx8nb7w3nmell38mta1umh2qc 2026-05-24 54c65mhi143utomzvvv3q2avh 0 2 0 0 1.0 False 0.0 False False AGREE 0.726 missing_full_ms_odds;lineup_probable_not_confirmed;missing_referee;ai_features_inferred_from_history MEDIUM False v28-pro-max no_bet_conditions_met
20 53348iqniod61z7xurb4tx250 2026-05-24 477yyajzheg2z8u7uick0e13e 2 0 0 0 OU25 Üst 1.93 0.2 True False -0.2 59.5 65.4 71.3 0.0414 B True 45.8 BET inferred_statistical_features;triple_value_not_confirmed base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample 0.5955 0.5181 0.0774 0.1084 False AGREE 0.74 lineup_probable_not_confirmed;ai_features_inferred_from_history MEDIUM 0.4706 False v28-pro-max betting_brain_approved
21 2hw717s7fxi2v2w53kdsplhqs 2026-05-24 8najqkluatpaxvqws78b9s17c 1 1 0 0 DC 12 1.24 0.0 False False 0.0 70.0 70.0 61.2 -0.12 PASS True 0.0 WATCH_NO_VALUE odds_below_minimum base_model_not_playable;inferred_statistical_features;trap_market_market_overpriced;triple_value_not_confirmed value_sniper_override;v25_v27_aligned;strong_historical_sample 0.7001 0.8065 -0.1064 0.0075 True AGREE 0.51 lineup_unavailable;lineup_incomplete;missing_referee;ai_features_inferred_from_history HIGH 0.5082 False v28-pro-max betting_brain_no_value_odds_below_minimum
22 1q1s55dy4d4z4gs34qk6vx9n8 2026-05-24 cegl2ivkc25blcatxp4jmk1ec 1 0 1 0 OU25 Üst 2.03 0.2 True False -0.2 50.0 57.7 54.3 0.0546 B True 35.7 BET inferred_statistical_features;triple_value_not_confirmed base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample 0.5 0.4926 0.0074 0.0555 False AGREE 0.74 lineup_probable_not_confirmed;missing_referee;ai_features_inferred_from_history HIGH 0.5993 False v28-pro-max betting_brain_approved
23 648u8zd49cwcxpspmvinlmexg 2026-05-24 1eruend45vd20g9hbrpiggs5u 1 0 0 0 MS 1 1.32 0.2 True True 0.064 63.1 65.5 55.7 -0.0828 B True 39.4 BET inferred_statistical_features;triple_value_not_confirmed base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample 0.6313 0.7576 -0.1263 0.0683 False AGREE 0.74 lineup_probable_not_confirmed;missing_referee;ai_features_inferred_from_history MEDIUM 0.8083 0.0 False v28-pro-max betting_brain_approved
24 1psnufak57w8dfs9e5cvbmgwk 2026-05-24 cegl2ivkc25blcatxp4jmk1ec 3 0 2 0 BTTS KG Var 1.94 0.2 True False -0.2 53.7 69.9 53.1 -0.0765 B True 5.3 BET inferred_statistical_features;trap_market_market_overpriced;triple_value_not_confirmed base_model_playable;value_sniper_override;strong_historical_sample 0.5371 0.5155 0.0216 True AGREE 0.74 lineup_probable_not_confirmed;missing_referee;ai_features_inferred_from_history HIGH 0.5993 False v28-pro-max betting_brain_approved
25 921kqaviappxt0w1kfmq1ek2c 2026-05-24 byu00jvt1j6csyv4y1lkt2fm2 1 0 1 0 DC X2 1.18 0.0 False False 0.0 75.8 75.8 74.9 -0.1267 PASS True 0.0 WATCH_NO_VALUE odds_below_minimum inferred_statistical_features;v25_v27_soft_disagreement;trap_market_market_overpriced;triple_value_not_confirmed;engine_consensus_disagree base_model_playable;value_sniper_override;strong_historical_sample 0.7584 0.8475 -0.0891 0.1783 True DISAGREE 0.74 ai_features_inferred_from_history MEDIUM 0.5359 False v28-pro-max betting_brain_no_value_odds_below_minimum
26 3m11hvh2fzailt3ykd0uhzz84 2026-05-24 54c65mhi143utomzvvv3q2avh 0 0 0 0 1.0 False 0.0 False False AGREE 0.591 missing_full_ms_odds;lineup_probable_not_confirmed;lineup_projection_low_confidence;lineup_incomplete;missing_referee;ai_features_inferred_from_history MEDIUM False v28-pro-max no_bet_conditions_met
27 7kvvf6blnps2xk15100ccdedw 2026-05-24 4zwgbb66rif2spcoeeol2motx 5 0 3 0 BTTS KG Var 1.33 0.2 True False -0.2 57.1 69.9 62.3 -0.1512 B True 29.1 BET inferred_statistical_features;triple_value_not_confirmed base_model_playable;value_sniper_override;strong_historical_sample 0.5707 0.7519 -0.1812 False AGREE 0.74 live_match_pre_match_features;ai_features_inferred_from_history MEDIUM 0.6995 1/1 False v28-pro-max betting_brain_approved
28 7liir8zj32o7m2udr7cknb8d0 2026-05-24 4zwgbb66rif2spcoeeol2motx 3 0 2 0 OU25 Üst 1.33 0.2 True True 0.066 61.4 65.4 58.3 -0.1437 B True 27.0 BET inferred_statistical_features;trap_market_market_overpriced;triple_value_not_confirmed base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample 0.6144 0.7519 -0.1375 0.0279 True AGREE 0.74 live_match_pre_match_features;ai_features_inferred_from_history MEDIUM 0.6995 1/1 False v28-pro-max betting_brain_approved
29 7l74ilyz7olljclexvn8tbjtg 2026-05-24 4zwgbb66rif2spcoeeol2motx 5 1 4 0 BTTS KG Var 1.55 0.2 True True 0.11 57.1 69.9 68.2 -0.0873 B True 32.7 BET inferred_statistical_features;triple_value_not_confirmed base_model_playable;value_sniper_override;strong_historical_sample 0.5707 0.6452 -0.0745 False AGREE 0.74 live_match_pre_match_features;ai_features_inferred_from_history MEDIUM 0.6995 1/1 False v28-pro-max betting_brain_approved
30 8f6gex4eh119d2hh9y2zb5clw 2026-05-24 3is4bkgf3loxv9qfg3hm8zfqb 2 0 2 0 OU25 Üst 1.49 0.2 True False -0.2 66.5 65.4 77.9 0.0081 B True 50.1 BET inferred_statistical_features;triple_value_not_confirmed base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample 0.6651 0.6711 -0.006 0.1144 False AGREE 0.74 live_match_pre_match_features;ai_features_inferred_from_history LOW 0.5033 1/1 False v28-pro-max betting_brain_approved
31 8ee7ipt4u6kyk6baueedsdafo 2026-05-24 3is4bkgf3loxv9qfg3hm8zfqb 0 2 0 2 BTTS KG Var 1.69 0.2 True False -0.2 54.3 69.9 64.7 -0.0792 B True 27.6 BET inferred_statistical_features;triple_value_not_confirmed base_model_playable;value_sniper_override;strong_historical_sample 0.5433 0.5917 -0.0484 False AGREE 0.74 live_match_pre_match_features;ai_features_inferred_from_history MEDIUM 0.5033 2/2 False v28-pro-max betting_brain_approved
32 8fydg367drpc25r1bobxqj3f8 2026-05-24 3is4bkgf3loxv9qfg3hm8zfqb 3 1 2 1 OU25 Üst 1.61 0.2 True True 0.122 50.1 57.7 50.7 -0.1072 B True 35.0 BET inferred_statistical_features;triple_value_not_confirmed base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample 0.5009 0.6211 -0.1202 0.0553 False AGREE 0.74 live_match_pre_match_features;ai_features_inferred_from_history MEDIUM 0.5033 False v28-pro-max betting_brain_approved
33 8fkdhce1peguwgnsunwoln3f8 2026-05-24 3is4bkgf3loxv9qfg3hm8zfqb 0 2 0 2 OU25 Üst 1.24 0.0 False False 0.0 61.4 65.4 61.1 -0.1548 PASS True 16.8 WATCH_NO_VALUE odds_below_minimum inferred_statistical_features;triple_value_not_confirmed;historical_sample_too_low base_model_playable;value_sniper_override;v25_v27_aligned 0.6144 0.8065 -0.1921 0.0942 False AGREE 0.74 live_match_pre_match_features;ai_features_inferred_from_history LOW 0.5033 False v28-pro-max betting_brain_no_value_odds_below_minimum
34 9g5hqtjja6ceqhkpghwmoy6ms 2026-05-24 2y8bntiif3a9y6gtmauv30gt 2 0 1 0 OU25 Üst 1.71 0.2 True False -0.2 50.1 57.7 52.6 -0.0794 B True 36.5 BET inferred_statistical_features;triple_value_not_confirmed base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample 0.5009 0.5848 -0.0839 0.0481 False DISAGREE 0.74 ai_features_inferred_from_history MEDIUM 0.4782 False v28-pro-max betting_brain_approved
35 8h6429zr5ijqcxc8gjxygjtw4 2026-05-24 3is4bkgf3loxv9qfg3hm8zfqb 3 0 1 0 MS 1 1.33 0.2 True True 0.066 66.1 65.5 66.7 -0.1155 B True 0.0 BET inferred_statistical_features;v25_v27_soft_disagreement;trap_market_market_overpriced;triple_value_not_confirmed;htft_reversal_prob_minor=0.11 base_model_playable;value_sniper_override;strong_historical_sample 0.6614 0.7519 -0.0905 0.2583 True AGREE 0.74 live_match_pre_match_features;ai_features_inferred_from_history MEDIUM 0.5033 0.0814 1/1 False v28-pro-max betting_brain_approved
36 77knm2ibdtb7akzrbltwz7axg 2026-05-24 bly7ema5au6j40i0grhl0pnub 1 1 1 0 1.0 False 0.0 False False AGREE 0.726 missing_full_ms_odds;lineup_probable_not_confirmed;missing_referee;ai_features_inferred_from_history MEDIUM False v28-pro-max no_bet_conditions_met
37 8es4680yd87gtmomg2jk3isyc 2026-05-24 3is4bkgf3loxv9qfg3hm8zfqb 0 1 0 0 OU25 Üst 1.53 0.2 True False -0.2 59.5 65.4 67.8 -0.0259 B True 42.4 BET inferred_statistical_features;triple_value_not_confirmed base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample 0.5955 0.6536 -0.0581 0.0713 False DISAGREE 0.74 live_match_pre_match_features;ai_features_inferred_from_history MEDIUM 0.5033 2/2 False v28-pro-max betting_brain_approved
38 8dmcz3k1u4ze53nvrsoz7eoes 2026-05-24 3is4bkgf3loxv9qfg3hm8zfqb 1 1 1 0 BTTS KG Var 1.26 0.0 False True 0.0 54.9 69.9 57.6 -0.2005 PASS True 3.3 WATCH_NO_VALUE odds_below_minimum inferred_statistical_features;triple_value_not_confirmed;historical_sample_too_low base_model_playable;value_sniper_override 0.5488 0.7937 -0.2449 False AGREE 0.74 live_match_pre_match_features;ai_features_inferred_from_history LOW 0.5033 1/1 False v28-pro-max betting_brain_no_value_odds_below_minimum
39 8gcbai6m7v7o8piqfram4qe50 2026-05-24 3is4bkgf3loxv9qfg3hm8zfqb 3 1 2 0 HTFT 1/1 4.59 0.0 False True 0.0 27.3 27.3 24.6 0.1657 PASS True 0.0 REJECT calibrated_confidence_too_low;play_score_too_low;volatile_market_requires_exceptional_evidence inferred_statistical_features;historical_sample_too_low base_model_playable 0.2734 0.2179 0.0555 False DISAGREE 0.74 live_match_pre_match_features;ai_features_inferred_from_history MEDIUM 0.5033 1/1 False v28-pro-max betting_brain_no_safe_pick
40 3azy3enp78au0zfugc3l1yf4k 2026-05-24 54c65mhi143utomzvvv3q2avh 2 0 1 0 1.0 False 0.0 False False AGREE 0.532 missing_full_ms_odds;lineup_probable_not_confirmed;lineup_projection_low_confidence;lineup_incomplete;missing_referee;ai_features_inferred_from_history MEDIUM False v28-pro-max no_bet_conditions_met
41 1d2fb7bt5f8xy5on24w1kj1g4 2026-05-24 54c65mhi143utomzvvv3q2avh 1 0 0 0 1.0 False 0.0 False False AGREE 0.532 missing_full_ms_odds;lineup_probable_not_confirmed;lineup_projection_low_confidence;lineup_incomplete;missing_referee;ai_features_inferred_from_history LOW False v28-pro-max no_bet_conditions_met
42 pw01xm8v3jlz13fpi3zq0ftg 2026-05-24 3umprqta6ipyann6qjjh07biz 1 1 0 0 1.0 False 0.0 False False AGREE 0.33 missing_full_ms_odds;lineup_unavailable;lineup_incomplete;missing_referee;ai_features_inferred_from_history MEDIUM False v28-pro-max no_bet_conditions_met
43 mjo9k4zr1x884vjlwea2y1hw 2026-05-24 3umprqta6ipyann6qjjh07biz 1 0 1 0 1.0 False 0.0 False False AGREE 0.33 missing_full_ms_odds;lineup_unavailable;lineup_incomplete;missing_referee;ai_features_inferred_from_history MEDIUM False v28-pro-max no_bet_conditions_met
44 8d8fm7wli7tfx8hm9w5l8nuhg 2026-05-24 3is4bkgf3loxv9qfg3hm8zfqb 1 1 1 0 BTTS KG Var 1.72 0.2 True True 0.144 53.7 69.9 65.2 -0.0712 B True 28.0 BET inferred_statistical_features;triple_value_not_confirmed base_model_playable;value_sniper_override;strong_historical_sample 0.5371 0.5814 -0.0443 False AGREE 0.74 live_match_pre_match_features;ai_features_inferred_from_history MEDIUM 0.5033 False v28-pro-max betting_brain_approved
45 oqsq3f0kvic8xfed8dp302z8 2026-05-24 3umprqta6ipyann6qjjh07biz 3 2 0 0 1.0 False 0.0 False False AGREE 0.33 missing_full_ms_odds;lineup_unavailable;lineup_incomplete;missing_referee;ai_features_inferred_from_history MEDIUM False v28-pro-max no_bet_conditions_met
46 o7tn4si7fxvq9c2mg0xs48wk 2026-05-24 3umprqta6ipyann6qjjh07biz 0 1 0 0 1.0 False 0.0 False False AGREE 0.33 missing_full_ms_odds;lineup_unavailable;lineup_incomplete;missing_referee;ai_features_inferred_from_history MEDIUM False v28-pro-max no_bet_conditions_met
47 eh9jfegscokidyczxfq691990 2026-05-24 3j81qr7yc4gdnakfwnxf95ovh 2 3 0 1 OU25 Üst 1.44 0.2 True True 0.088 50.1 57.7 32.9 -0.2537 B True 17.0 BET inferred_statistical_features;trap_market_market_overpriced;triple_value_not_confirmed base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample 0.5009 0.6944 -0.1935 0.0596 True AGREE 0.51 lineup_unavailable;lineup_incomplete;missing_referee;ai_features_inferred_from_history MEDIUM 0.8771 False v28-pro-max betting_brain_approved
48 dkhhkbwnxwl47e8hybv89mwb8 2026-05-24 5jd0k2txwnq69frs79eulba8j 1 2 0 1 OU25 Üst 1.23 0.0 False True 0.0 61.4 65.4 61.2 -0.1185 PASS True 11.4 WATCH_NO_VALUE odds_below_minimum base_model_not_playable;inferred_statistical_features;triple_value_not_confirmed value_sniper_override;v25_v27_aligned;strong_historical_sample 0.6144 0.813 -0.1986 0.0179 False AGREE 0.74 ai_features_inferred_from_history LOW 0.9233 1/1 False v28-pro-max betting_brain_no_value_odds_below_minimum
49 1lknqdz9vmb3hnqu144zkkefo 2026-05-24 1r097lpxe0xn03ihb7wi98kao 1 0 1 0 BTTS KG Var 1.78 0.2 True False -0.2 50.0 61.7 55.6 -0.088 B True 29.3 BET inferred_statistical_features;triple_value_not_confirmed base_model_playable;value_sniper_override;strong_historical_sample 0.5 0.5618 -0.0618 False AGREE 0.74 live_match_pre_match_features;ai_features_inferred_from_history MEDIUM 0.7391 1/1 False v28-pro-max betting_brain_approved
50 3oazp9kfbyyiatn246k4to6xg 2026-05-24 9ynnnx1qmkizq1o3qr3v0nsuk 1 2 0 1 BTTS KG Var 1.36 0.2 True True 0.072 53.7 69.9 61.2 -0.1571 B True 33.7 BET inferred_statistical_features;triple_value_not_confirmed base_model_playable;value_sniper_override;strong_historical_sample 0.5371 0.7353 -0.1982 False AGREE 0.74 live_match_pre_match_features;ai_features_inferred_from_history LOW 0.554 2/2 False v28-pro-max betting_brain_approved
51 8cr8t6qh0r6g0mv6ftq0ic1sk 2026-05-24 a9vrdkelbgif0gtu3wxsr75xo 2 1 0 1 OU25 Üst 1.46 0.2 True True 0.092 61.4 65.4 68.1 -0.0182 B True 47.8 BET inferred_statistical_features;triple_value_not_confirmed base_model_playable;value_sniper_override;v25_v27_aligned;strong_historical_sample 0.6144 0.6849 -0.0705 0.0535 False AGREE 0.74 ai_features_inferred_from_history MEDIUM 0.6618 False v28-pro-max betting_brain_approved
@@ -0,0 +1,220 @@
{
"args": {
"days": 3,
"max_matches": 50,
"start": null,
"end": null,
"progress_interval": 50
},
"aggregate": {
"overall": {
"n_total": 50,
"n_playable_settled": 27,
"wins": 15,
"losses": 12,
"hit_rate_pct": 55.56,
"unit_profit": -0.862,
"staked": 5.4,
"roi_pct": -15.96
},
"by_market": {
"OU25": {
"n_total": 13,
"n_playable_settled": 13,
"wins": 7,
"losses": 6,
"hit_rate_pct": 53.85,
"unit_profit": -0.6,
"staked": 2.6,
"roi_pct": -23.08
},
"BTTS": {
"n_total": 12,
"n_playable_settled": 12,
"wins": 6,
"losses": 6,
"hit_rate_pct": 50.0,
"unit_profit": -0.392,
"staked": 2.4,
"roi_pct": -16.33
},
"MS": {
"n_total": 2,
"n_playable_settled": 2,
"wins": 2,
"losses": 0,
"hit_rate_pct": 100.0,
"unit_profit": 0.13,
"staked": 0.4,
"roi_pct": 32.5
}
},
"by_confidence": {
"65-70": {
"n_total": 22,
"n_playable_settled": 22,
"wins": 13,
"losses": 9,
"hit_rate_pct": 59.09,
"unit_profit": -0.472,
"staked": 4.4,
"roi_pct": -10.73
},
"55-60": {
"n_total": 4,
"n_playable_settled": 4,
"wins": 2,
"losses": 2,
"hit_rate_pct": 50.0,
"unit_profit": -0.19,
"staked": 0.8,
"roi_pct": -23.75
},
"60-65": {
"n_total": 1,
"n_playable_settled": 1,
"wins": 0,
"losses": 1,
"hit_rate_pct": 0.0,
"unit_profit": -0.2,
"staked": 0.2,
"roi_pct": -100.0
}
},
"by_odds": {
"1.3-1.5": {
"n_total": 11,
"n_playable_settled": 11,
"wins": 9,
"losses": 2,
"hit_rate_pct": 81.82,
"unit_profit": 0.28,
"staked": 2.2,
"roi_pct": 12.73
},
"1.5-1.8": {
"n_total": 10,
"n_playable_settled": 10,
"wins": 5,
"losses": 5,
"hit_rate_pct": 50.0,
"unit_profit": -0.352,
"staked": 2.0,
"roi_pct": -17.6
},
"1.8-2.2": {
"n_total": 6,
"n_playable_settled": 6,
"wins": 1,
"losses": 5,
"hit_rate_pct": 16.67,
"unit_profit": -0.79,
"staked": 1.2,
"roi_pct": -65.83
}
},
"by_grade": {
"B": {
"n_total": 27,
"n_playable_settled": 27,
"wins": 15,
"losses": 12,
"hit_rate_pct": 55.56,
"unit_profit": -0.862,
"staked": 5.4,
"roi_pct": -15.96
}
},
"by_competition": {
"league": {
"n_total": 27,
"n_playable_settled": 27,
"wins": 15,
"losses": 12,
"hit_rate_pct": 55.56,
"unit_profit": -0.862,
"staked": 5.4,
"roi_pct": -15.96
}
}
},
"loss_diagnostics": {
"n_losses": 12,
"total_loss_units": -2.4,
"patterns": {
"high_htft_reversal_prob (>=0.20)": [
0,
0.0
],
"cup_match": [
0,
0.0
],
"low_league_reliability (<0.45)": [
0,
0.0
],
"v27_disagree": [
3,
25.0
],
"trap_market_flagged": [
4,
33.33
],
"low_calibrated_conf (<55)": [
0,
0.0
],
"high_odds_underdog (>=2.5)": [
0,
0.0
],
"low_data_quality (<0.55)": [
0,
0.0
],
"high_risk_level": [
3,
25.0
],
"inferred_features": [
12,
100.0
]
},
"by_market": [
[
"BTTS",
6
],
[
"OU25",
6
]
],
"by_league": [
[
null,
12
]
],
"top_bb_issues_in_losses": [
[
"inferred_statistical_features",
12
],
[
"triple_value_not_confirmed",
12
],
[
"trap_market_market_overpriced",
4
]
],
"top_bb_vetoes_in_losses": []
},
"recommendations": [],
"errors_sample": []
}
@@ -0,0 +1,71 @@
==============================================================================
DIAGNOSTIC BACKTEST REPORT
==============================================================================
Generated: 2026-05-25T02:44:37
Sample window: start=-3d, end=now
Max matches: 50
Excluded days: ['2026-04-29', '2026-05-03']
OVERALL
------------------------------------------------------------------------------
n_total : 50
n_playable_settled : 27
wins : 15
losses : 12
hit_rate_pct : 55.56
unit_profit : -0.862
staked : 5.4
roi_pct : -15.96
PER MARKET
------------------------------------------------------------------------------
market n hit% profit roi%
OU25 13 53.85 -0.6 -23.08
BTTS 12 50.0 -0.392 -16.33
MS 2 100.0 0.13 32.5
PER CALIBRATED CONFIDENCE BAND
------------------------------------------------------------------------------
band n hit% roi%
55-60 4 50.0 -23.75
60-65 1 0.0 -100.0
65-70 22 59.09 -10.73
PER ODDS BAND
------------------------------------------------------------------------------
band n hit% roi%
1.3-1.5 11 81.82 12.73
1.5-1.8 10 50.0 -17.6
1.8-2.2 6 16.67 -65.83
LEAGUE vs CUP
------------------------------------------------------------------------------
league n= 27 hit=55.56% roi=-15.96%
LOSS DIAGNOSTICS
------------------------------------------------------------------------------
total losses: 12
total lost units: -2.4
By market: [('BTTS', 6), ('OU25', 6)]
Loss patterns (count, % of losses):
high_htft_reversal_prob (>=0.20) 0 (0.0%)
cup_match 0 (0.0%)
low_league_reliability (<0.45) 0 (0.0%)
v27_disagree 3 (25.0%)
trap_market_flagged 4 (33.33%)
low_calibrated_conf (<55) 0 (0.0%)
high_odds_underdog (>=2.5) 0 (0.0%)
low_data_quality (<0.55) 0 (0.0%)
high_risk_level 3 (25.0%)
inferred_features 12 (100.0%)
Top betting_brain issues seen in losses:
inferred_statistical_features 12
triple_value_not_confirmed 12
trap_market_market_overpriced 4
Top betting_brain vetoes (in losses — i.e. veto fired but bet still went through value-sniper override):
RECOMMENDATIONS
------------------------------------------------------------------------------
(none surfaced — sample too small or no clear pattern)
==============================================================================
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,335 @@
{
"args": {
"days": 14,
"max_matches": 1000,
"start": null,
"end": null,
"progress_interval": 50
},
"aggregate": {
"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
},
"by_market": {
"OU25": {
"n_total": 236,
"n_playable_settled": 236,
"wins": 134,
"losses": 102,
"hit_rate_pct": 56.78,
"unit_profit": -6.271,
"staked": 48.5,
"roi_pct": -12.93
},
"BTTS": {
"n_total": 205,
"n_playable_settled": 205,
"wins": 105,
"losses": 100,
"hit_rate_pct": 51.22,
"unit_profit": -8.89,
"staked": 41.1,
"roi_pct": -21.63
},
"MS": {
"n_total": 76,
"n_playable_settled": 76,
"wins": 44,
"losses": 32,
"hit_rate_pct": 57.89,
"unit_profit": -2.396,
"staked": 16.0,
"roi_pct": -14.98
},
"OU35": {
"n_total": 3,
"n_playable_settled": 3,
"wins": 0,
"losses": 3,
"hit_rate_pct": 0.0,
"unit_profit": -0.6,
"staked": 0.6,
"roi_pct": -100.0
},
"DC": {
"n_total": 4,
"n_playable_settled": 4,
"wins": 4,
"losses": 0,
"hit_rate_pct": 100.0,
"unit_profit": 0.26,
"staked": 0.8,
"roi_pct": 32.5
}
},
"by_confidence": {
"65-70": {
"n_total": 420,
"n_playable_settled": 420,
"wins": 233,
"losses": 187,
"hit_rate_pct": 55.48,
"unit_profit": -14.057,
"staked": 85.1,
"roi_pct": -16.52
},
"60-65": {
"n_total": 33,
"n_playable_settled": 33,
"wins": 16,
"losses": 17,
"hit_rate_pct": 48.48,
"unit_profit": -1.61,
"staked": 6.6,
"roi_pct": -24.39
},
"55-60": {
"n_total": 52,
"n_playable_settled": 52,
"wins": 28,
"losses": 24,
"hit_rate_pct": 53.85,
"unit_profit": -0.668,
"staked": 10.5,
"roi_pct": -6.36
},
"50-55": {
"n_total": 5,
"n_playable_settled": 5,
"wins": 2,
"losses": 3,
"hit_rate_pct": 40.0,
"unit_profit": -0.64,
"staked": 1.3,
"roi_pct": -49.23
},
"45-50": {
"n_total": 8,
"n_playable_settled": 8,
"wins": 4,
"losses": 4,
"hit_rate_pct": 50.0,
"unit_profit": -0.382,
"staked": 1.9,
"roi_pct": -20.11
},
"70-80": {
"n_total": 6,
"n_playable_settled": 6,
"wins": 4,
"losses": 2,
"hit_rate_pct": 66.67,
"unit_profit": -0.54,
"staked": 1.6,
"roi_pct": -33.75
}
},
"by_odds": {
"1.3-1.5": {
"n_total": 241,
"n_playable_settled": 241,
"wins": 148,
"losses": 93,
"hit_rate_pct": 61.41,
"unit_profit": -7.408,
"staked": 49.0,
"roi_pct": -15.12
},
"1.5-1.8": {
"n_total": 221,
"n_playable_settled": 221,
"wins": 115,
"losses": 106,
"hit_rate_pct": 52.04,
"unit_profit": -6.926,
"staked": 44.3,
"roi_pct": -15.63
},
"1.8-2.2": {
"n_total": 56,
"n_playable_settled": 56,
"wins": 23,
"losses": 33,
"hit_rate_pct": 41.07,
"unit_profit": -2.789,
"staked": 12.2,
"roi_pct": -22.86
},
"2.2-3.0": {
"n_total": 5,
"n_playable_settled": 5,
"wins": 1,
"losses": 4,
"hit_rate_pct": 20.0,
"unit_profit": -0.574,
"staked": 1.3,
"roi_pct": -44.15
},
"3.0-5.0": {
"n_total": 1,
"n_playable_settled": 1,
"wins": 0,
"losses": 1,
"hit_rate_pct": 0.0,
"unit_profit": -0.2,
"staked": 0.2,
"roi_pct": -100.0
}
},
"by_grade": {
"B": {
"n_total": 518,
"n_playable_settled": 518,
"wins": 285,
"losses": 233,
"hit_rate_pct": 55.02,
"unit_profit": -16.931,
"staked": 105.3,
"roi_pct": -16.08
},
"A": {
"n_total": 6,
"n_playable_settled": 6,
"wins": 2,
"losses": 4,
"hit_rate_pct": 33.33,
"unit_profit": -0.966,
"staked": 1.7,
"roi_pct": -56.82
}
},
"by_competition": {
"league": {
"n_total": 524,
"n_playable_settled": 524,
"wins": 287,
"losses": 237,
"hit_rate_pct": 54.77,
"unit_profit": -17.897,
"staked": 107.0,
"roi_pct": -16.73
}
}
},
"loss_diagnostics": {
"n_losses": 237,
"total_loss_units": -48.7,
"patterns": {
"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
]
},
"by_market": [
[
"OU25",
102
],
[
"BTTS",
100
],
[
"MS",
32
],
[
"OU35",
3
]
],
"by_league": [
[
null,
237
]
],
"top_bb_issues_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_bb_vetoes_in_losses": []
},
"recommendations": [
{
"type": "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"
}
],
"errors_sample": []
}
@@ -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
==============================================================================
@@ -0,0 +1,38 @@
{
"BTTS": {
"min_calibrated_confidence": 65,
"min_ev_edge": -1.0,
"max_ev_edge": 0.1,
"min_odds": 1.4,
"max_odds": 10.0,
"min_odds_reliability": 0.55,
"require_v27_agree": true,
"expected_n_bets": 54,
"expected_hit_pct": 55.56,
"expected_roi_pct": -10.96
},
"MS": {
"min_calibrated_confidence": 0,
"min_ev_edge": -0.05,
"max_ev_edge": 0.15,
"min_odds": 1.2,
"max_odds": 10.0,
"min_odds_reliability": 0.0,
"require_v27_agree": true,
"expected_n_bets": 21,
"expected_hit_pct": 61.9,
"expected_roi_pct": 8.23
},
"OU25": {
"min_calibrated_confidence": 0,
"min_ev_edge": -1.0,
"max_ev_edge": 0.15,
"min_odds": 1.8,
"max_odds": 10.0,
"min_odds_reliability": 0.0,
"require_v27_agree": false,
"expected_n_bets": 20,
"expected_hit_pct": 65.0,
"expected_roi_pct": 28.91
}
}
+227
View File
@@ -0,0 +1,227 @@
"""
Deep root-cause analysis on diagnostic_backtest CSV.
Tests specific hypotheses with hard numbers and proposes actionable
filter rules with estimated impact (units saved, ROI shift).
"""
import sys, os, glob
import pandas as pd
import numpy as np
REPORTS_DIR = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "reports")
def latest_csv():
files = sorted(glob.glob(os.path.join(REPORTS_DIR, "diagnostic_backtest_*.csv")),
key=os.path.getmtime, reverse=True)
return files[0] if files else None
def fmt_pct(x):
return f"{x:>6.2f}%" if pd.notna(x) else " ----"
def cell(df, label, mask):
sub = df[mask]
n = len(sub)
if n == 0:
return f" {label:<60} n=0"
wins = (sub["won"] == True).sum()
losses = (sub["won"] == False).sum()
settled = wins + losses
hr = 100.0 * wins / settled if settled else 0
profit = sub["unit_profit"].sum()
staked = sub["stake_units"].sum()
roi = 100.0 * profit / staked if staked else 0
return (f" {label:<60} n={n:>4} hit={hr:>6.2f}% "
f"profit={profit:>+7.2f}u roi={roi:>+7.2f}%")
def hypothesis_block(title, rows):
print(f"\n{'' * 78}")
print(f" {title}")
print(f"{'' * 78}")
for row in rows:
print(row)
def main():
csv_path = latest_csv()
if not csv_path:
print("No backtest CSV found")
return
print(f"Reading {csv_path}")
df = pd.read_csv(csv_path)
print(f"Loaded {len(df)} rows")
# Filter only playable + settled
pdf = df[(df["playable"] == True) & (df["won"].notna())].copy()
pdf["won"] = pdf["won"].astype(bool)
print(f"Playable + settled: {len(pdf)}")
overall_hr = (pdf["won"].sum() / len(pdf)) * 100
overall_roi = 100.0 * pdf["unit_profit"].sum() / pdf["stake_units"].sum()
print(f"\nOVERALL: hit={overall_hr:.2f}% roi={overall_roi:.2f}%")
# ─────────────────────────────────────────────────────────────────────
# H1: TRIPLE VALUE CONFIRMATION
# ─────────────────────────────────────────────────────────────────────
triple_confirmed_mask = ~pdf["bb_issues"].fillna("").str.contains(
"triple_value_not_confirmed", na=False
)
hypothesis_block(
"H1: TRIPLE VALUE CONFIRMED vs NOT CONFIRMED",
[
cell(pdf, "triple_value CONFIRMED", triple_confirmed_mask),
cell(pdf, "triple_value NOT CONFIRMED", ~triple_confirmed_mask),
]
)
# ─────────────────────────────────────────────────────────────────────
# H2: TRAP MARKET FLAG
# ─────────────────────────────────────────────────────────────────────
trap_mask = pdf["bb_trap_market"] == True
hypothesis_block(
"H2: TRAP MARKET FLAG (model says band rate < implied → market overpriced)",
[
cell(pdf, "trap_market_flag = TRUE (model warned)", trap_mask),
cell(pdf, "trap_market_flag = FALSE", ~trap_mask),
]
)
# ─────────────────────────────────────────────────────────────────────
# H3: V25/V27 CONSENSUS
# ─────────────────────────────────────────────────────────────────────
agree_mask = pdf["v27_consensus"] == "AGREE"
disagree_mask = pdf["v27_consensus"] == "DISAGREE"
hypothesis_block(
"H3: V25 ↔ V27 CONSENSUS",
[
cell(pdf, "AGREE", agree_mask),
cell(pdf, "DISAGREE", disagree_mask),
cell(pdf, "neither/null", ~(agree_mask | disagree_mask)),
]
)
# ─────────────────────────────────────────────────────────────────────
# H4: ODDS RELIABILITY (league quality)
# ─────────────────────────────────────────────────────────────────────
pdf["rel_band"] = pd.cut(
pdf["odds_reliability"].fillna(0.35),
[0, 0.30, 0.45, 0.55, 1.0],
labels=["<0.30 verylow", "0.30-0.45 low", "0.45-0.55 mid", ">=0.55 high"]
)
hypothesis_block(
"H4: LEAGUE ODDS RELIABILITY",
[cell(pdf, str(b), pdf["rel_band"] == b) for b in pdf["rel_band"].cat.categories]
)
# ─────────────────────────────────────────────────────────────────────
# H5: CALIBRATOR IMPACT (raw vs calibrated)
# ─────────────────────────────────────────────────────────────────────
pdf["calib_delta"] = pdf["calibrated_confidence"] - pdf["raw_confidence"]
pdf["delta_band"] = pd.cut(
pdf["calib_delta"].fillna(0),
[-100, -10, -3, 3, 10, 100],
labels=["cal<<raw (-10+)", "cal<raw (-3..-10)", "≈equal (±3)",
"cal>raw (3..10)", "cal>>raw (+10+)"]
)
hypothesis_block(
"H5: CALIBRATOR DELTA (calibrated_conf - raw_conf)",
[cell(pdf, str(b), pdf["delta_band"] == b) for b in pdf["delta_band"].cat.categories]
)
# ─────────────────────────────────────────────────────────────────────
# H6: EV EDGE
# ─────────────────────────────────────────────────────────────────────
pdf["edge_band"] = pd.cut(
pdf["ev_edge"].fillna(0),
[-10, -0.05, 0.0, 0.05, 0.10, 0.20, 10],
labels=["edge<-5%", "-5%-0%", "0-5%", "5-10%", "10-20%", ">20%"]
)
hypothesis_block(
"H6: EV EDGE (model_prob - implied_prob)",
[cell(pdf, str(b), pdf["edge_band"] == b) for b in pdf["edge_band"].cat.categories]
)
# ─────────────────────────────────────────────────────────────────────
# H7: ODDS x MARKET cross
# ─────────────────────────────────────────────────────────────────────
pdf["odds_band"] = pd.cut(
pdf["odds"].fillna(0),
[0, 1.30, 1.50, 1.80, 2.20, 3.00, 100],
labels=["<1.30", "1.30-1.50", "1.50-1.80", "1.80-2.20", "2.20-3.00", ">3.00"]
)
print(f"\n{'' * 78}")
print(f" H7: ODDS BAND × MARKET (per cell hit% / roi% / n)")
print(f"{'' * 78}")
pivot_n = pdf.pivot_table(index="market", columns="odds_band",
values="match_id", aggfunc="count", fill_value=0,
observed=False)
pivot_roi = pdf.pivot_table(index="market", columns="odds_band",
values="unit_profit", aggfunc="sum", fill_value=0,
observed=False)
pivot_stake = pdf.pivot_table(index="market", columns="odds_band",
values="stake_units", aggfunc="sum", fill_value=0,
observed=False)
pivot_roi_pct = (100.0 * pivot_roi / pivot_stake.replace(0, np.nan)).round(1)
print("\n Bet count per cell:")
print(pivot_n.to_string())
print("\n ROI% per cell:")
print(pivot_roi_pct.to_string())
# ─────────────────────────────────────────────────────────────────────
# H8: COMBINED FILTER SIMULATION
# ─────────────────────────────────────────────────────────────────────
print(f"\n{'' * 78}")
print(" H8: COMBINED FILTER SIMULATION (what if we add rules)")
print(f"{'' * 78}")
def simulate(filter_name, keep_mask):
kept = pdf[keep_mask]
rejected = pdf[~keep_mask]
if len(kept) == 0:
return f" {filter_name:<55} → 0 bet remain"
kept_hr = 100.0 * kept["won"].sum() / len(kept)
kept_profit = kept["unit_profit"].sum()
kept_staked = kept["stake_units"].sum()
kept_roi = 100.0 * kept_profit / kept_staked if kept_staked else 0
saved = -rejected["unit_profit"].sum() # money we WOULD HAVE LOST
return (f" {filter_name:<55} keep={len(kept):>3} hit={kept_hr:>5.1f}% "
f"roi={kept_roi:>+6.2f}% saved={saved:>+6.2f}u")
print(simulate("BASELINE (no extra filter)", pd.Series([True] * len(pdf), index=pdf.index)))
print(simulate("REJECT triple_value_not_confirmed",
~pdf["bb_issues"].fillna("").str.contains("triple_value_not_confirmed")))
print(simulate("REJECT trap_market_flag",
~(pdf["bb_trap_market"] == True)))
print(simulate("REJECT v27 DISAGREE",
pdf["v27_consensus"] != "DISAGREE"))
print(simulate("REJECT odds_reliability < 0.45",
pdf["odds_reliability"].fillna(1.0) >= 0.45))
print(simulate("REJECT odds in 1.80-2.20",
(pdf["odds"].fillna(0) < 1.80) | (pdf["odds"].fillna(0) >= 2.20)))
print(simulate("REJECT ev_edge < 0",
pdf["ev_edge"].fillna(0) >= 0))
print(simulate("REJECT ev_edge < 0.05",
pdf["ev_edge"].fillna(0) >= 0.05))
print()
print(" COMBINED rules:")
# Stack 1: drop triple_not_confirmed + trap_market + DISAGREE
s1 = (
~pdf["bb_issues"].fillna("").str.contains("triple_value_not_confirmed")
& ~(pdf["bb_trap_market"] == True)
& (pdf["v27_consensus"] != "DISAGREE")
)
print(simulate("STACK1: !triple_not_conf & !trap & !disagree", s1))
# Stack 2: + edge>=0
s2 = s1 & (pdf["ev_edge"].fillna(0) >= 0)
print(simulate("STACK2: STACK1 + edge >= 0", s2))
# Stack 3: + reliability>=0.45
s3 = s2 & (pdf["odds_reliability"].fillna(1.0) >= 0.45)
print(simulate("STACK3: STACK2 + reliability >= 0.45", s3))
# Stack 4: + odds outside 1.80-2.20
s4 = s3 & ((pdf["odds"].fillna(0) < 1.80) | (pdf["odds"].fillna(0) >= 2.20))
print(simulate("STACK4: STACK3 + odds NOT in 1.80-2.20", s4))
print(f"\n{'' * 78}")
print("DONE.")
if __name__ == "__main__":
main()
+134
View File
@@ -0,0 +1,134 @@
"""
Compare two diagnostic_backtest CSV outputs side-by-side.
Used to validate that a filter change actually improved ROI vs the
baseline run — and to detect overfitting (in-sample success but
out-of-sample collapse).
Usage:
python scripts/compare_backtests.py <baseline.csv> <validation.csv>
python scripts/compare_backtests.py (auto-picks 2 most recent CSVs)
"""
import sys, os, glob
import pandas as pd
from typing import Dict
REPORTS_DIR = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "reports")
def load(path: str) -> pd.DataFrame:
df = pd.read_csv(path)
df["won_bool"] = df["won"].map(
{True: True, False: False, "True": True, "False": False, 1: True, 0: False}
)
return df
def stats(df: pd.DataFrame, mask=None) -> Dict:
if mask is not None:
df = df[mask]
playable = df[(df["playable"] == True) & (df["won_bool"].notna())]
if len(playable) == 0:
return {"n_total": len(df), "n_playable": 0, "hit": 0, "profit": 0,
"staked": 0, "roi": 0}
wins = playable["won_bool"].sum()
profit = playable["unit_profit"].sum()
staked = playable["stake_units"].sum()
return {
"n_total": int(len(df)),
"n_playable": int(len(playable)),
"wins": int(wins),
"losses": int(len(playable) - wins),
"hit": round(100.0 * wins / len(playable), 2),
"profit": round(profit, 2),
"staked": round(staked, 2),
"roi": round(100.0 * profit / staked, 2) if staked else 0,
}
def line(label: str, a: Dict, b: Dict, suffix: str = ""):
fields = ["n_total", "n_playable", "hit", "profit", "staked", "roi"]
parts = [f"{label:<28}"]
for f in fields:
va = a.get(f, "-")
vb = b.get(f, "-")
parts.append(f"{f}: {str(va):>8}{str(vb):>8}")
print(" " + " | ".join(parts) + suffix)
def main():
if len(sys.argv) == 3:
a_path, b_path = sys.argv[1], sys.argv[2]
else:
files = sorted(glob.glob(os.path.join(REPORTS_DIR, "diagnostic_backtest_*.csv")),
key=os.path.getmtime, reverse=True)
if len(files) < 2:
print("Need at least 2 backtest CSVs in reports/. Pass paths manually.")
return
b_path, a_path = files[0], files[1] # newest first as "validation"
print(f"Baseline A: {os.path.basename(a_path)}")
print(f"Validation B: {os.path.basename(b_path)}")
a = load(a_path)
b = load(b_path)
print(f"\n{'=' * 100}")
print(f" OVERALL")
print(f"{'=' * 100}")
line("ALL", stats(a), stats(b))
print(f"\n{'' * 100}")
print(f" PER MARKET")
print(f"{'' * 100}")
markets = sorted(set(a["market"].dropna().unique()) | set(b["market"].dropna().unique()))
for m in markets:
line(f"market={m}",
stats(a, a["market"] == m),
stats(b, b["market"] == m))
# New veto family check — did MUTED_MARKETS actually mute?
print(f"\n{'' * 100}")
print(f" NEW VETO IMPACT (look for new veto names in betting_brain.vetoes)")
print(f"{'' * 100}")
new_vetoes = ["market_muted_by_backtest", "negative_ev_edge", "ev_edge_too_high_trap",
"outside_envelope_edge_low", "outside_envelope_edge_high",
"outside_envelope_odds_low", "outside_envelope_v27_must_agree"]
for veto in new_vetoes:
a_hits = a["bb_vetoes"].fillna("").str.contains(veto).sum()
b_hits = b["bb_vetoes"].fillna("").str.contains(veto).sum()
print(f" {veto:<45} A={a_hits:>4} B={b_hits:>4}")
# Top issue tags
print(f"\n{'' * 100}")
print(f" BTTS MUTE CHECK — should be ~0 playable in validation")
print(f"{'' * 100}")
a_btts_play = ((a["market"] == "BTTS") & (a["playable"] == True)).sum()
b_btts_play = ((b["market"] == "BTTS") & (b["playable"] == True)).sum()
print(f" BTTS playable bets: A={a_btts_play} → B={b_btts_play} "
f"(should be 0 in B if MUTE works)")
# Verdict
print(f"\n{'=' * 100}")
a_s = stats(a)
b_s = stats(b)
roi_delta = b_s["roi"] - a_s["roi"]
if b_s["n_playable"] < 20:
verdict = "TOO FEW BETS — sample insufficient"
elif roi_delta > 5 and b_s["roi"] > 0:
verdict = "✅ FILTERS WORK — ROI improved AND positive"
elif roi_delta > 5:
verdict = "🟡 PARTIAL — ROI improved but still negative"
elif roi_delta > 0:
verdict = "🟡 SLIGHT IMPROVEMENT"
elif roi_delta < -5:
verdict = "❌ OVERFITTING — validation ROI collapsed"
else:
verdict = "❌ NO MATERIAL CHANGE"
print(f" VERDICT: {verdict}")
print(f" ROI: {a_s['roi']}% → {b_s['roi']}% (Δ {roi_delta:+.2f}pp)")
print(f"{'=' * 100}")
if __name__ == "__main__":
main()
+674
View File
@@ -0,0 +1,674 @@
"""
Diagnostic Backtest
===================
Run the full V28 orchestrator (in-process — no HTTP) on a window of completed
matches, capture the recommendation + key signal features + the actual outcome,
and produce a *diagnostic* report: not just "what was the hit rate" but
"which feature clusters drive the losing bets".
Outputs:
- reports/diagnostic_backtest_YYYYMMDD.csv (per-bet detail)
- reports/diagnostic_backtest_YYYYMMDD.json (aggregate metrics)
- reports/diagnostic_backtest_YYYYMMDD.txt (human-readable summary)
Usage:
python scripts/diagnostic_backtest.py --days 14 --max-matches 2000
python scripts/diagnostic_backtest.py --start 2026-05-10 --end 2026-05-24
"""
from __future__ import annotations
import argparse
import json
import os
import sys
import time
import traceback
from collections import defaultdict, Counter
from datetime import datetime, timedelta, timezone
from typing import Any, Dict, List, Optional, Tuple
import psycopg2
from psycopg2.extras import RealDictCursor
# Path bootstrap so we can import the ai-engine package from anywhere
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
AI_ENGINE_DIR = os.path.dirname(SCRIPT_DIR)
sys.path.insert(0, AI_ENGINE_DIR)
from data.db import get_clean_dsn
from services.single_match_orchestrator import get_single_match_orchestrator
REPORTS_DIR = os.path.join(AI_ENGINE_DIR, "reports")
os.makedirs(REPORTS_DIR, exist_ok=True)
# Days with confirmed feeder gaps — exclude from sample
EXCLUDED_DATES = {"2026-05-03", "2026-04-29"}
# ── Outcome resolution ────────────────────────────────────────────────
def _norm_pick(pick: Optional[str]) -> str:
return str(pick or "").strip().casefold()
def resolve_outcome(market: str, pick: str, sh: int, sa: int,
htsh: Optional[int], htsa: Optional[int]) -> Optional[bool]:
"""Mirror of prediction-settlement.market-resolver.ts (TS side).
Returns True/False on settle, None if cannot resolve."""
m = (market or "").upper().replace(" ", "").replace("-", "_")
p = _norm_pick(pick)
if m in ("MS", "ML", "1X2"):
outcome = "1" if sh > sa else "2" if sa > sh else "x"
return p in {outcome, outcome.upper(), outcome.lower(), "0" if outcome == "x" else outcome}
if m in ("HT", "IY"):
if htsh is None or htsa is None:
return None
outcome = "1" if htsh > htsa else "2" if htsa > htsh else "x"
return p in {outcome, "0" if outcome == "x" else outcome}
if m in ("OU05", "OU15", "OU25", "OU35", "OU45", "TOTAL"):
line = {"OU05": 0.5, "OU15": 1.5, "OU25": 2.5, "OU35": 3.5,
"OU45": 4.5, "TOTAL": 2.5}[m]
total = sh + sa
if total == line:
return None
is_over = total > line
if "over" in p or "üst" in p or "ust" in p:
return is_over
if "alt" in p or "under" in p:
return not is_over
return None
if m in ("OU05_HT", "OU15_HT", "OU25_HT", "HT_OU05", "HT_OU15", "HT_OU25"):
if htsh is None or htsa is None:
return None
line = {"OU05_HT": 0.5, "OU15_HT": 1.5, "OU25_HT": 2.5,
"HT_OU05": 0.5, "HT_OU15": 1.5, "HT_OU25": 2.5}[m]
total = htsh + htsa
if total == line:
return None
is_over = total > line
if "over" in p or "üst" in p or "ust" in p:
return is_over
if "alt" in p or "under" in p:
return not is_over
return None
if m in ("BTTS", "KG"):
both = sh > 0 and sa > 0
if "yes" in p or "var" in p:
return both
if "no" in p or "yok" in p:
return not both
return None
if m in ("HTFT", "IYMS"):
if htsh is None or htsa is None or "/" not in p:
return None
ht_p, ft_p = p.split("/", 1)
ht_actual = "1" if htsh > htsa else "2" if htsa > htsh else "x"
ft_actual = "1" if sh > sa else "2" if sa > sh else "x"
return ht_p.strip() == ht_actual and ft_p.strip() == ft_actual
if m in ("DC", "CIFTE_SANS"):
ft = "1" if sh > sa else "2" if sa > sh else "X"
raw = p.upper().replace("-", "").replace("/", "")
if raw in ("1X", "X1"):
pair = ["1", "X"]
elif raw in ("X2", "2X"):
pair = ["X", "2"]
elif raw in ("12", "21"):
pair = ["1", "2"]
else:
return None
return ft in pair
if m in ("OE", "TEKCIFT"):
is_odd = (sh + sa) % 2 == 1
if "tek" in p or "odd" in p:
return is_odd
if "cift" in p or "çift" in p or "even" in p:
return not is_odd
return None
return None
def compute_unit_profit(won: Optional[bool], stake: float, odds: Optional[float]) -> float:
if won is None:
return 0.0
if not won:
return -abs(stake) if stake else -1.0
if not odds or odds <= 1.0:
return 0.0
return round(stake * (odds - 1.0), 4)
# ── Data fetch ────────────────────────────────────────────────────────
def fetch_match_window(args) -> List[Dict]:
dsn = get_clean_dsn()
if "?schema=" in dsn:
dsn = dsn.split("?schema=")[0]
if args.start and args.end:
start = datetime.strptime(args.start, "%Y-%m-%d")
end = datetime.strptime(args.end, "%Y-%m-%d") + timedelta(days=1)
else:
end = datetime.now(timezone.utc).replace(tzinfo=None)
start = end - timedelta(days=args.days)
start_ms = int(start.timestamp() * 1000)
end_ms = int(end.timestamp() * 1000)
excluded = sorted(EXCLUDED_DATES)
excluded_clause = ""
if excluded:
ex_csv = ",".join(f"'{d}'" for d in excluded)
excluded_clause = (
f" AND to_timestamp(mst_utc/1000)::date "
f"NOT IN ({ex_csv})"
)
with psycopg2.connect(dsn) as conn:
with conn.cursor(cursor_factory=RealDictCursor) as cur:
cur.execute(
f"""
SELECT id AS match_id,
score_home, score_away,
ht_score_home, ht_score_away,
league_id,
to_timestamp(mst_utc/1000)::date AS match_date
FROM matches
WHERE sport='football'
AND status='FT'
AND score_home IS NOT NULL
AND score_away IS NOT NULL
AND mst_utc >= %s
AND mst_utc < %s
{excluded_clause}
ORDER BY mst_utc DESC
LIMIT %s
""",
(start_ms, end_ms, args.max_matches),
)
return cur.fetchall()
# ── Per-bet capture ───────────────────────────────────────────────────
def capture_bet_row(match: Dict, package: Dict) -> Dict[str, Any]:
"""Distill orchestrator response + ground truth into one analytic row."""
main = package.get("main_pick") or {}
bb = main.get("betting_brain") or {}
advice = package.get("bet_advice") or {}
v27 = package.get("v27_engine") or {}
triple = (v27.get("triple_value") or {})
risk = package.get("risk") or {}
quality = package.get("data_quality") or {}
htft_payload = ((package.get("market_board") or {}).get("HTFT") or {})
htft_probs = htft_payload.get("probs") or {}
sh, sa = match["score_home"], match["score_away"]
htsh, htsa = match["ht_score_home"], match["ht_score_away"]
market = main.get("market")
pick = main.get("pick")
odds_val = _f(main.get("odds"))
stake = _f(main.get("stake_units"), 1.0)
playable = bool(main.get("playable")) and bool(advice.get("playable"))
won = resolve_outcome(market, pick, sh, sa, htsh, htsa) if market and pick else None
profit = compute_unit_profit(won, stake, odds_val) if playable else 0.0
# Reversal context (only meaningful for MS picks)
rev_prob = None
if market == "MS" and pick in ("1", "2"):
if pick == "1":
rev_prob = _f(htft_probs.get("1/2"), 0.0) + _f(htft_probs.get("1/X"), 0.0)
else:
rev_prob = _f(htft_probs.get("2/1"), 0.0) + _f(htft_probs.get("2/X"), 0.0)
return {
"match_id": match["match_id"],
"match_date": str(match["match_date"]),
"league_id": match.get("league_id"),
"score_home": sh,
"score_away": sa,
"ht_score_home": htsh,
"ht_score_away": htsa,
"market": market,
"pick": pick,
"odds": odds_val,
"stake_units": stake,
"playable": playable,
"won": won,
"unit_profit": profit,
"raw_confidence": _f(main.get("raw_confidence")),
"calibrated_confidence": _f(main.get("calibrated_confidence")),
"play_score": _f(main.get("play_score")),
"ev_edge": _f(main.get("ev_edge")),
"bet_grade": main.get("bet_grade"),
"is_value_sniper": bool(main.get("is_value_sniper")),
"bb_score": _f(bb.get("score")),
"bb_action": bb.get("action"),
"bb_vetoes": ";".join(bb.get("vetoes") or []),
"bb_issues": ";".join(bb.get("issues") or []),
"bb_positives": ";".join(bb.get("positives") or []),
"bb_model_prob": _f(bb.get("model_prob")),
"bb_implied_prob": _f(bb.get("implied_prob")),
"bb_model_market_gap": _f(bb.get("model_market_gap")),
"bb_divergence": _f(bb.get("divergence")),
"bb_trap_market": bool(bb.get("trap_market_flag")),
"v27_consensus": v27.get("consensus"),
"data_quality_score": _f(quality.get("score")),
"data_quality_flags": ";".join(quality.get("flags") or []),
"risk_level": (risk.get("level") if isinstance(risk, dict) else None),
"odds_reliability": _f(main.get("odds_reliability")),
"htft_reversal_prob": rev_prob,
"htft_top_pick": _argmax(htft_probs),
"league_name": (package.get("match_info") or {}).get("league_name"),
"is_cup": _is_cup((package.get("match_info") or {}).get("league_name") or ""),
"model_version": package.get("model_version"),
"decision_reason": main.get("pick_reason") or advice.get("reason"),
}
def _f(x: Any, default: Optional[float] = None) -> Optional[float]:
try:
return float(x) if x is not None else default
except (TypeError, ValueError):
return default
def _argmax(d: Dict[str, Any]) -> Optional[str]:
best, val = None, -1.0
for k, v in d.items():
fv = _f(v, 0.0) or 0.0
if fv > val:
best, val = k, fv
return best
_CUP_KEYWORDS = ("kupa", "cup", "coupe", "copa", "coppa", "pokal", "trophy",
"shield", "ziraat", "süper kupa", "super cup", "beker", "taça", "taca")
def _is_cup(name: str) -> bool:
n = (name or "").lower()
return any(kw in n for kw in _CUP_KEYWORDS)
# ── Aggregation helpers ────────────────────────────────────────────────
def _bucket(value: Optional[float], edges: List[float]) -> Optional[str]:
if value is None:
return None
for i, edge in enumerate(edges):
if value < edge:
if i == 0:
return f"<{edge}"
return f"{edges[i-1]}-{edge}"
return f">={edges[-1]}"
def _summary_stats(rows: List[Dict]) -> Dict[str, Any]:
if not rows:
return {"n": 0}
settled = [r for r in rows if r["playable"] and r["won"] is not None]
won = sum(1 for r in settled if r["won"])
lost = sum(1 for r in settled if not r["won"])
profit = sum(float(r["unit_profit"]) for r in settled)
staked = sum(float(r["stake_units"]) for r in settled)
return {
"n_total": len(rows),
"n_playable_settled": len(settled),
"wins": won,
"losses": lost,
"hit_rate_pct": round(100.0 * won / len(settled), 2) if settled else None,
"unit_profit": round(profit, 3),
"staked": round(staked, 3),
"roi_pct": round(100.0 * profit / staked, 2) if staked else None,
}
def aggregate(rows: List[Dict]) -> Dict[str, Any]:
out: Dict[str, Any] = {"overall": _summary_stats(rows)}
by = lambda key_fn: defaultdict(list)
market_buckets = by(None)
conf_buckets = by(None)
odds_buckets = by(None)
grade_buckets = by(None)
cup_buckets = by(None)
motivation_buckets = by(None)
for r in rows:
if r["playable"]:
market_buckets[r["market"] or "?"].append(r)
conf_buckets[_bucket(r["calibrated_confidence"],
[45, 50, 55, 60, 65, 70, 80])].append(r)
odds_buckets[_bucket(r["odds"], [1.3, 1.5, 1.8, 2.2, 3.0, 5.0])].append(r)
grade_buckets[r["bet_grade"] or "?"].append(r)
cup_buckets["cup" if r["is_cup"] else "league"].append(r)
out["by_market"] = {k: _summary_stats(v) for k, v in market_buckets.items()}
out["by_confidence"] = {k: _summary_stats(v) for k, v in conf_buckets.items() if k}
out["by_odds"] = {k: _summary_stats(v) for k, v in odds_buckets.items() if k}
out["by_grade"] = {k: _summary_stats(v) for k, v in grade_buckets.items()}
out["by_competition"] = {k: _summary_stats(v) for k, v in cup_buckets.items()}
return out
def loss_diagnostics(rows: List[Dict]) -> Dict[str, Any]:
losses = [r for r in rows if r["playable"] and r["won"] is False]
if not losses:
return {"n_losses": 0}
n = len(losses)
def share(predicate) -> Tuple[int, float]:
c = sum(1 for r in losses if predicate(r))
return c, round(100.0 * c / n, 2)
diagnostics = {
"n_losses": n,
"total_loss_units": round(sum(float(r["unit_profit"]) for r in losses), 3),
"patterns": {
"high_htft_reversal_prob (>=0.20)": share(
lambda r: (r.get("htft_reversal_prob") or 0) >= 0.20
),
"cup_match": share(lambda r: r["is_cup"]),
"low_league_reliability (<0.45)": share(
lambda r: (r.get("odds_reliability") or 1) < 0.45
),
"v27_disagree": share(lambda r: r.get("v27_consensus") == "DISAGREE"),
"trap_market_flagged": share(lambda r: r.get("bb_trap_market")),
"low_calibrated_conf (<55)": share(
lambda r: (r.get("calibrated_confidence") or 0) < 55
),
"high_odds_underdog (>=2.5)": share(
lambda r: (r.get("odds") or 0) >= 2.5
),
"low_data_quality (<0.55)": share(
lambda r: (r.get("data_quality_score") or 1) < 0.55
),
"high_risk_level": share(
lambda r: r.get("risk_level") in ("HIGH", "EXTREME")
),
"inferred_features": share(
lambda r: "ai_features_inferred_from_history" in (r.get("data_quality_flags") or "")
),
},
"by_market": Counter(r["market"] for r in losses).most_common(),
"by_league": Counter(r.get("league_name") for r in losses).most_common(10),
}
# Top issue tags from betting_brain across losses
issue_counter = Counter()
veto_counter = Counter()
for r in losses:
for tag in (r.get("bb_issues") or "").split(";"):
if tag:
issue_counter[tag] += 1
for tag in (r.get("bb_vetoes") or "").split(";"):
if tag:
veto_counter[tag] += 1
diagnostics["top_bb_issues_in_losses"] = issue_counter.most_common(15)
diagnostics["top_bb_vetoes_in_losses"] = veto_counter.most_common(15)
return diagnostics
# ── Recommendations ────────────────────────────────────────────────────
def make_recommendations(rows: List[Dict], agg: Dict[str, Any],
diag: Dict[str, Any]) -> List[Dict[str, Any]]:
recs: List[Dict[str, Any]] = []
overall = agg.get("overall") or {}
if not overall.get("n_playable_settled"):
return recs
# Cross-reference market hit rate vs overall — flag chronic losers.
overall_hit = overall.get("hit_rate_pct") or 0.0
for market, stats in (agg.get("by_market") or {}).items():
n = stats.get("n_playable_settled") or 0
hit = stats.get("hit_rate_pct")
roi = stats.get("roi_pct")
if n < 30:
continue
if hit is not None and roi is not None and roi < -10 and hit < overall_hit - 10:
recs.append({
"type": "drop_market",
"market": market,
"evidence": f"hit={hit}%, roi={roi}%, n={n} — chronic loser",
"suggested_fix": f"Add veto in betting_brain when market=={market} unless overwhelming evidence",
"estimated_loss_prevented_units": round(-(stats.get("unit_profit") or 0), 2),
})
# Confidence band tuning — flag bands where ROI < 0 despite passing eşik
for band, stats in (agg.get("by_confidence") or {}).items():
n = stats.get("n_playable_settled") or 0
roi = stats.get("roi_pct")
if n >= 40 and roi is not None and roi < -8:
recs.append({
"type": "raise_confidence_threshold",
"confidence_band": band,
"evidence": f"n={n}, roi={roi}%",
"suggested_fix": f"Raise MIN_BET_SCORE or market_min_conf above {band.split('-')[0]}",
})
# Loss diagnostic — if cup matches dominate losses, recommend cup-aware filter
patterns = (diag.get("patterns") or {})
cup_share = patterns.get("cup_match", (0, 0))[1]
if cup_share >= 25:
recs.append({
"type": "cup_match_filter",
"evidence": f"{cup_share}% of losses are cup matches",
"suggested_fix": "Tighten betting_brain thresholds for is_cup_match=True picks",
})
rev_share = patterns.get("high_htft_reversal_prob (>=0.20)", (0, 0))[1]
if rev_share >= 15:
recs.append({
"type": "tighten_reversal_check",
"evidence": f"{rev_share}% of losses had HTFT reversal prob >=0.20 (already partial fix)",
"suggested_fix": "Lower reversal threshold in betting_brain from 0.25 to 0.20 for veto trigger",
})
rel_share = patterns.get("low_league_reliability (<0.45)", (0, 0))[1]
if rel_share >= 20:
recs.append({
"type": "league_reliability_filter",
"evidence": f"{rel_share}% of losses in low-reliability leagues (<0.45)",
"suggested_fix": "Add hard veto when odds_reliability<0.45 for non-value-sniper picks",
})
return recs
# ── CSV / report writers ───────────────────────────────────────────────
def write_csv(rows: List[Dict], path: str):
if not rows:
return
import csv
fields = list(rows[0].keys())
with open(path, "w", newline="", encoding="utf-8") as f:
w = csv.DictWriter(f, fieldnames=fields)
w.writeheader()
for r in rows:
w.writerow(r)
def write_text_summary(rows: List[Dict], agg: Dict, diag: Dict,
recs: List[Dict], path: str, args):
lines: List[str] = []
push = lines.append
push("=" * 78)
push("DIAGNOSTIC BACKTEST REPORT")
push("=" * 78)
push(f"Generated: {datetime.now().isoformat(timespec='seconds')}")
push(f"Sample window: start={args.start or f'-{args.days}d'}, end={args.end or 'now'}")
push(f"Max matches: {args.max_matches}")
push(f"Excluded days: {sorted(EXCLUDED_DATES)}")
push("")
push("OVERALL")
push("-" * 78)
overall = agg.get("overall") or {}
for k in ("n_total", "n_playable_settled", "wins", "losses",
"hit_rate_pct", "unit_profit", "staked", "roi_pct"):
push(f" {k:25}: {overall.get(k)}")
push("")
push("PER MARKET")
push("-" * 78)
push(f" {'market':<8} {'n':>6} {'hit%':>7} {'profit':>9} {'roi%':>7}")
for market, s in sorted((agg.get("by_market") or {}).items(),
key=lambda kv: -(kv[1].get("n_playable_settled") or 0)):
push(f" {market:<8} {s.get('n_playable_settled',0):>6} "
f"{str(s.get('hit_rate_pct','')):>7} "
f"{str(s.get('unit_profit','')):>9} "
f"{str(s.get('roi_pct','')):>7}")
push("")
push("PER CALIBRATED CONFIDENCE BAND")
push("-" * 78)
push(f" {'band':<10} {'n':>6} {'hit%':>7} {'roi%':>7}")
for band, s in sorted((agg.get("by_confidence") or {}).items()):
push(f" {band:<10} {s.get('n_playable_settled',0):>6} "
f"{str(s.get('hit_rate_pct','')):>7} "
f"{str(s.get('roi_pct','')):>7}")
push("")
push("PER ODDS BAND")
push("-" * 78)
push(f" {'band':<10} {'n':>6} {'hit%':>7} {'roi%':>7}")
for band, s in sorted((agg.get("by_odds") or {}).items()):
push(f" {band:<10} {s.get('n_playable_settled',0):>6} "
f"{str(s.get('hit_rate_pct','')):>7} "
f"{str(s.get('roi_pct','')):>7}")
push("")
push("LEAGUE vs CUP")
push("-" * 78)
for k, s in (agg.get("by_competition") or {}).items():
push(f" {k:<8} n={s.get('n_playable_settled',0):>4} "
f"hit={s.get('hit_rate_pct','-')}% roi={s.get('roi_pct','-')}%")
push("")
push("LOSS DIAGNOSTICS")
push("-" * 78)
push(f" total losses: {diag.get('n_losses')}")
push(f" total lost units: {diag.get('total_loss_units')}")
push(f" By market: {diag.get('by_market')}")
push(" Loss patterns (count, % of losses):")
for pattern, (c, pct) in (diag.get("patterns") or {}).items():
push(f" {pattern:<55} {c:>4} ({pct}%)")
push(" Top betting_brain issues seen in losses:")
for issue, c in (diag.get("top_bb_issues_in_losses") or []):
push(f" {issue:<55} {c}")
push(" Top betting_brain vetoes (in losses — i.e. veto fired but bet still went through value-sniper override):")
for veto, c in (diag.get("top_bb_vetoes_in_losses") or []):
push(f" {veto:<55} {c}")
push("")
push("RECOMMENDATIONS")
push("-" * 78)
if not recs:
push(" (none surfaced — sample too small or no clear pattern)")
for r in recs:
push(f" • [{r['type']}]")
for k, v in r.items():
if k == "type":
continue
push(f" {k}: {v}")
push("")
push("=" * 78)
with open(path, "w", encoding="utf-8") as f:
f.write("\n".join(lines))
# ── Main loop ─────────────────────────────────────────────────────────
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--days", type=int, default=14,
help="Backwards window from now (default 14)")
parser.add_argument("--max-matches", type=int, default=2000,
help="Hard cap on matches processed (default 2000)")
parser.add_argument("--start", help="Start date YYYY-MM-DD (overrides --days)")
parser.add_argument("--end", help="End date YYYY-MM-DD")
parser.add_argument("--progress-interval", type=int, default=50)
args = parser.parse_args()
print("=" * 70)
print("DIAGNOSTIC BACKTEST")
print("=" * 70)
print(f"Loading orchestrator...")
orch = get_single_match_orchestrator()
# Warm V25 + V27 + basketball loaders so the first match doesn't pay it
try:
orch._get_v25_predictor()
except Exception as e:
print(f" v25 warmup: {e}")
try:
orch._get_v27_predictor()
except Exception as e:
print(f" v27 warmup: {e}")
print(f"Fetching match window...")
matches = fetch_match_window(args)
n = len(matches)
print(f" {n} matches selected")
if not matches:
print("No matches to process. Exiting.")
return
rows: List[Dict[str, Any]] = []
errors: List[Tuple[str, str]] = []
t0 = time.time()
for i, m in enumerate(matches, start=1):
mid = str(m["match_id"])
try:
pkg = orch.analyze_match(mid)
if pkg is None:
continue
row = capture_bet_row(m, pkg)
rows.append(row)
except KeyboardInterrupt:
print("\nInterrupted, writing partial results...")
break
except Exception as e:
errors.append((mid, str(e)))
if len(errors) <= 5:
traceback.print_exc()
if i % args.progress_interval == 0:
elapsed = time.time() - t0
rate = i / elapsed
eta = (n - i) / rate if rate else 0
playable_so_far = sum(1 for r in rows if r["playable"])
print(f" [{i}/{n}] rate={rate:.1f}/s eta={eta/60:.1f}min "
f"playable={playable_so_far} errors={len(errors)}")
print(f"\nProcessed {len(rows)} rows in {(time.time()-t0):.1f}s "
f"({len(errors)} errors)")
# Aggregate
print("Aggregating...")
agg = aggregate(rows)
diag = loss_diagnostics(rows)
recs = make_recommendations(rows, agg, diag)
stamp = datetime.now().strftime("%Y%m%d_%H%M%S")
csv_path = os.path.join(REPORTS_DIR, f"diagnostic_backtest_{stamp}.csv")
json_path = os.path.join(REPORTS_DIR, f"diagnostic_backtest_{stamp}.json")
txt_path = os.path.join(REPORTS_DIR, f"diagnostic_backtest_{stamp}.txt")
write_csv(rows, csv_path)
with open(json_path, "w", encoding="utf-8") as f:
json.dump({"args": vars(args), "aggregate": agg, "loss_diagnostics": diag,
"recommendations": recs, "errors_sample": errors[:20]},
f, indent=2, default=str)
write_text_summary(rows, agg, diag, recs, txt_path, args)
print(f"\nOutputs:")
print(f" CSV: {csv_path}")
print(f" JSON: {json_path}")
print(f" TXT: {txt_path}")
print("\nOverall:", agg.get("overall"))
if __name__ == "__main__":
main()
+254
View File
@@ -0,0 +1,254 @@
"""
Filter Optimizer
================
Grid-search over filter thresholds (per market) using the existing
diagnostic_backtest CSV. Finds the (confidence, edge, odds, reliability)
combination that maximizes ROI while keeping bet volume reasonable.
No re-prediction needed — pure offline simulation on the bets already
captured. Output: per-market optimal thresholds + projected ROI lift +
JSON patch ready to drop into config/market_thresholds.json.
Usage:
python scripts/optimize_filters.py
python scripts/optimize_filters.py --csv reports/diagnostic_backtest_X.csv
python scripts/optimize_filters.py --min-bets 20 --apply
"""
import argparse
import json
import os
import sys
import glob
import itertools
from typing import List, Dict, Tuple, Optional
import pandas as pd
import numpy as np
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
AI_ENGINE_DIR = os.path.dirname(SCRIPT_DIR)
sys.path.insert(0, AI_ENGINE_DIR)
REPORTS_DIR = os.path.join(AI_ENGINE_DIR, "reports")
CONFIG_PATH = os.path.join(AI_ENGINE_DIR, "config", "market_thresholds.json")
def latest_csv() -> Optional[str]:
files = sorted(glob.glob(os.path.join(REPORTS_DIR, "diagnostic_backtest_*.csv")),
key=os.path.getmtime, reverse=True)
return files[0] if files else None
def load_backtest(path: str) -> pd.DataFrame:
df = pd.read_csv(path)
# Keep only playable + settled bets — these are what the SYSTEM
# actually placed and got an outcome on.
pdf = df[(df["playable"] == True) & (df["won"].notna())].copy()
pdf["won"] = pdf["won"].astype(bool)
pdf["calibrated_confidence"] = pdf["calibrated_confidence"].fillna(0)
pdf["ev_edge"] = pdf["ev_edge"].fillna(0)
pdf["odds"] = pdf["odds"].fillna(0)
pdf["odds_reliability"] = pdf["odds_reliability"].fillna(0.35)
return pdf
def evaluate(pdf: pd.DataFrame, mask) -> Dict:
kept = pdf[mask]
if len(kept) == 0:
return {"n": 0, "hit_pct": 0, "profit": 0, "staked": 0, "roi_pct": 0}
wins = kept["won"].sum()
profit = kept["unit_profit"].sum()
staked = kept["stake_units"].sum()
return {
"n": int(len(kept)),
"hit_pct": round(100.0 * wins / len(kept), 2),
"profit": round(profit, 3),
"staked": round(staked, 3),
"roi_pct": round(100.0 * profit / staked, 2) if staked else 0,
}
def grid_search_market(
market_df: pd.DataFrame,
market: str,
min_bets: int = 15,
) -> List[Dict]:
"""Try a wide grid of (min_conf, min_edge, max_edge, min_odds, max_odds,
min_reliability) combinations. Return all candidates with n >= min_bets,
sorted by ROI descending."""
conf_options = [0, 45, 50, 55, 60, 65, 70]
min_edge_options = [-1.0, -0.05, 0.0, 0.03, 0.05, 0.08]
max_edge_options = [10.0, 0.30, 0.20, 0.15, 0.10]
min_odds_options = [1.20, 1.30, 1.40, 1.50, 1.60, 1.80]
max_odds_options = [10.0, 3.0, 2.5, 2.2, 2.0]
rel_options = [0.0, 0.30, 0.45, 0.55]
consensus_options = ["any", "agree_or_null"]
candidates: List[Dict] = []
for mc, mine, maxe, mino, maxo, mrel, cons in itertools.product(
conf_options, min_edge_options, max_edge_options,
min_odds_options, max_odds_options, rel_options, consensus_options,
):
if mine >= maxe or mino >= maxo:
continue
mask = (
(market_df["calibrated_confidence"] >= mc)
& (market_df["ev_edge"] >= mine)
& (market_df["ev_edge"] <= maxe)
& (market_df["odds"] >= mino)
& (market_df["odds"] <= maxo)
& (market_df["odds_reliability"] >= mrel)
)
if cons == "agree_or_null":
mask &= market_df["v27_consensus"] != "DISAGREE"
result = evaluate(market_df, mask)
if result["n"] >= min_bets:
candidates.append({
"market": market,
"min_conf": mc,
"min_edge": mine,
"max_edge": maxe,
"min_odds": mino,
"max_odds": maxo,
"min_reliability": mrel,
"consensus": cons,
**result,
})
candidates.sort(key=lambda r: (r["roi_pct"], r["n"]), reverse=True)
return candidates
def baseline(pdf: pd.DataFrame, market: str) -> Dict:
m = pdf[pdf["market"] == market]
return evaluate(m, pd.Series([True] * len(m), index=m.index))
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--csv", default=None, help="Override CSV path")
parser.add_argument("--min-bets", type=int, default=15,
help="Min bet count to consider a config valid")
parser.add_argument("--top-k", type=int, default=3,
help="Show top K configs per market")
parser.add_argument("--apply", action="store_true",
help="Patch config/market_thresholds.json with winners")
args = parser.parse_args()
csv_path = args.csv or latest_csv()
if not csv_path or not os.path.exists(csv_path):
print("No backtest CSV found.")
return
print(f"Loading: {csv_path}")
pdf = load_backtest(csv_path)
print(f"Playable + settled bets: {len(pdf)}")
markets = sorted(pdf["market"].dropna().unique())
print(f"Markets: {markets}\n")
all_winners: Dict[str, Dict] = {}
for market in markets:
market_df = pdf[pdf["market"] == market]
n_total = len(market_df)
base = baseline(pdf, market)
print(f"\n{'=' * 78}")
print(f"MARKET: {market} (n={n_total} baseline_roi={base['roi_pct']}%)")
print(f"{'=' * 78}")
if n_total < args.min_bets * 2:
print(f" Sample too small to grid-search reliably (n={n_total}). Skip.")
continue
candidates = grid_search_market(market_df, market, args.min_bets)
if not candidates:
print(f" No config kept >= {args.min_bets} bets. Skip.")
continue
# Pareto-ish: show top-K by ROI but also one that keeps higher bet count
winners = candidates[:args.top_k]
keep_high_volume = None
for c in candidates:
if c["n"] >= max(40, n_total // 3) and c["roi_pct"] > base["roi_pct"]:
keep_high_volume = c
break
print(f" {'rank':<5}{'n':>5}{'hit%':>7}{'roi%':>8} "
f"{'min_conf':>9}{'min_edge':>10}{'max_edge':>10}"
f"{'min_odds':>10}{'max_odds':>10}{'min_rel':>9}{'cons':>15}")
for i, w in enumerate(winners, 1):
print(f" {i:<5}{w['n']:>5}{w['hit_pct']:>7}{w['roi_pct']:>+8}"
f" {w['min_conf']:>9}{w['min_edge']:>+10.3f}{w['max_edge']:>+10.3f}"
f"{w['min_odds']:>10.2f}{w['max_odds']:>10.2f}"
f"{w['min_reliability']:>9.2f}{w['consensus']:>15}")
if keep_high_volume and keep_high_volume not in winners:
print(f" high {keep_high_volume['n']:>5}{keep_high_volume['hit_pct']:>7}"
f"{keep_high_volume['roi_pct']:>+8}"
f" {keep_high_volume['min_conf']:>9}"
f"{keep_high_volume['min_edge']:>+10.3f}"
f"{keep_high_volume['max_edge']:>+10.3f}"
f"{keep_high_volume['min_odds']:>10.2f}"
f"{keep_high_volume['max_odds']:>10.2f}"
f"{keep_high_volume['min_reliability']:>9.2f}"
f"{keep_high_volume['consensus']:>15}")
# Pick a "good" recommendation: best ROI with n >= min_bets
# If best ROI is still negative, flag the market as unprofitable.
best = winners[0]
all_winners[market] = best
if best["roi_pct"] <= 0:
print(f" ⚠️ Best config still loses money (ROI={best['roi_pct']}%) "
f"— consider muting this market entirely.")
else:
print(f" ✅ Best config: ROI={best['roi_pct']}% on {best['n']} bets "
f"(vs baseline {base['roi_pct']}% on {n_total}).")
# ─── Aggregate impact ────────────────────────────────────────────────
print(f"\n{'=' * 78}")
print("AGGREGATE IMPACT (if we apply each market's best config)")
print(f"{'=' * 78}")
total_old_bets = total_old_profit = total_old_staked = 0
total_new_bets = total_new_profit = total_new_staked = 0
for market, win in all_winners.items():
base = baseline(pdf, market)
total_old_bets += base["n"]
total_old_profit += base["profit"]
total_old_staked += base["staked"]
total_new_bets += win["n"]
total_new_profit += win["profit"]
total_new_staked += win["staked"]
base_roi = 100.0 * total_old_profit / total_old_staked if total_old_staked else 0
new_roi = 100.0 * total_new_profit / total_new_staked if total_new_staked else 0
print(f" Baseline: {total_old_bets:>4} bets, "
f"profit={total_old_profit:+.2f}u, ROI={base_roi:+.2f}%")
print(f" Optimized: {total_new_bets:>4} bets, "
f"profit={total_new_profit:+.2f}u, ROI={new_roi:+.2f}%")
print(f" Δ: {total_new_bets - total_old_bets:+d} bets, "
f"{total_new_profit - total_old_profit:+.2f}u, "
f"{new_roi - base_roi:+.2f}pp")
# ─── Write JSON patch ────────────────────────────────────────────────
patch_path = os.path.join(REPORTS_DIR, "filter_optimization_patch.json")
patch = {market: {
"min_calibrated_confidence": win["min_conf"],
"min_ev_edge": win["min_edge"],
"max_ev_edge": win["max_edge"],
"min_odds": win["min_odds"],
"max_odds": win["max_odds"],
"min_odds_reliability": win["min_reliability"],
"require_v27_agree": win["consensus"] == "agree_or_null",
"expected_n_bets": win["n"],
"expected_hit_pct": win["hit_pct"],
"expected_roi_pct": win["roi_pct"],
} for market, win in all_winners.items()}
with open(patch_path, "w", encoding="utf-8") as f:
json.dump(patch, f, indent=2)
print(f"\nPatch saved: {patch_path}")
if args.apply:
print("\n--apply flag set. Patching not implemented yet — "
"review the patch JSON and update config/market_thresholds.json manually.")
if __name__ == "__main__":
main()
+54
View File
@@ -0,0 +1,54 @@
"""Smoke test for the score-coherence filter using the LAFC vs Sounders
1-0 scenario from production. Verifies that markets that contradict the
predicted score are correctly excluded from the coherent set, and that
the markets the model got right are all included.
"""
import os, sys
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from services.betting_brain import BettingBrain
brain = BettingBrain()
pkg = {
"score_prediction": {"ft": "1-0", "ht": "0-0"},
}
coh = brain._score_consistent_markets(pkg)
print(f"Predicted: 1-0 (HT 0-0)")
print(f"Coherent set size: {len(coh)}")
print()
# Each pick the system actually offered for the LAFC match, with whether
# it was the *actual* winning pick.
test_picks = [
("MS", "1", True, "correct"),
("MS", "2", False, "wrong"),
("MS", "X", False, "wrong"),
("DC", "1X", True, "correct"),
("DC", "12", True, "correct"),
("DC", "X2", False, "wrong"),
("OU25", "Üst", False, "WRONG — system featured this"),
("OU25", "Alt", True, "correct"),
("OU35", "Alt", True, "correct"),
("OU35", "Üst", False, "wrong"),
("BTTS", "Var", False, "wrong"),
("BTTS", "Yok", True, "correct"),
("HT", "X", True, "correct"),
("HT", "1", False, "wrong"),
("HTFT", "X/1", True, "correct"),
("HTFT", "1/1", False, "wrong (HT was 0-0)"),
("HT_OU05", "Üst", False, "wrong"),
("HT_OU05", "Alt", True, "correct"),
("OE", "Çift", False, "wrong (1 is odd)"),
("OE", "Tek", True, "correct"),
]
print(f"{'market':<10}{'pick':<10}{'real-win?':<12}{'in-coherent?':<14}{'match?'}")
print("-" * 60)
ok = 0
for market, pick, would_win, note in test_picks:
in_coh = (market, pick) in coh
match = "" if in_coh == would_win else "✗ MISMATCH"
if in_coh == would_win: ok += 1
print(f"{market:<10}{pick:<10}{str(would_win):<12}{str(in_coh):<14}{match} {note}")
print()
print(f"Result: {ok}/{len(test_picks)} picks correctly classified")
+201 -1
View File
@@ -39,6 +39,31 @@ class BettingBrain:
SNIPER_BLOCKED_MARKETS = {"HT", "HTFT", "OE", "CARDS", "HT_OU05", "HT_OU15"}
# Markets that lose money under every filter combination per the
# diagnostic backtest (1000 matches). Until calibration is rebuilt for
# these specifically, force NO_BET. Re-evaluate after each backtest run.
MUTED_MARKETS = {"BTTS"}
# Per-market optimal filter envelopes derived from the diagnostic
# backtest grid search (reports/filter_optimization_patch.json). Any
# pick falling OUTSIDE this envelope is vetoed. Tightens the playable
# band to the ROI-positive zone identified empirically.
#
# Each entry: {min_conf, min_edge, max_edge, min_odds, max_odds,
# min_reliability, require_v27_agree}
MARKET_OPTIMAL_FILTERS = {
"MS": {
"min_edge": -0.05, "max_edge": 0.15,
"min_odds": 1.20, "max_odds": 10.0,
"min_reliability": 0.0, "require_v27_agree": True,
},
"OU25": {
"min_edge": -1.0, "max_edge": 0.15,
"min_odds": 1.80, "max_odds": 10.0,
"min_reliability": 0.0, "require_v27_agree": False,
},
}
MARKET_PRIORS = {
"DC": 4.0,
"OU15": 3.0,
@@ -86,6 +111,36 @@ class BettingBrain:
watchlist.sort(key=self._candidate_sort_key, reverse=True)
no_value.sort(key=self._candidate_sort_key, reverse=True)
# ── SCORE COHERENCE FILTER ──────────────────────────────────────
# If the model also produced a score prediction (e.g. 1-0), pick
# main_pick from the subset of candidates that would WIN at that
# score. Stops the system from recommending OU25 Üst while also
# predicting 1-0 (only 1 goal). Falls back to original list if no
# coherent candidate exists.
coherent_set = self._score_consistent_markets(guarded)
coherent_flag = False
if coherent_set:
def is_coherent(row: Dict[str, Any]) -> bool:
m = str(row.get("market") or "")
p = str(row.get("pick") or "")
return (m, p) in coherent_set
approved_coh = [r for r in approved if is_coherent(r)]
watchlist_coh = [r for r in watchlist if is_coherent(r)]
if approved_coh:
approved = approved_coh
coherent_flag = True
elif watchlist_coh:
# No coherent BET candidates — at least promote a coherent
# watch over an incoherent BET.
watchlist = watchlist_coh + [r for r in watchlist if not is_coherent(r)]
coherent_flag = True
# Tag every row so the UI/diagnostics can see what happened
for row in judged_rows.values():
row.setdefault("betting_brain", {})
row["betting_brain"]["score_coherent"] = is_coherent(row)
original_main = guarded.get("main_pick") or {}
main_pick = None
decision = "NO_BET"
@@ -142,10 +197,11 @@ class BettingBrain:
rejected = [d for d in decisions if d.get("action") == "REJECT"]
guarded["betting_brain"] = {
"version": "judge-v1",
"version": "judge-v2-score-coherent",
"decision": decision,
"reason": decision_reason,
"main_pick_key": main_key or None,
"score_coherent_filter_applied": coherent_flag,
"approved_count": len(approved),
"watchlist_count": len(watchlist),
"rejected_count": len(rejected),
@@ -243,6 +299,44 @@ class BettingBrain:
if play_score < 50.0 and not is_value_sniper:
vetoes.append("play_score_too_low")
# ── HARD EV-EDGE VETO ───────────────────────────────────────────
# Diagnostic backtest (1000 maç, 524 settled bet) gösterdi ki
# ev_edge < 0 olan bahisler %76 of all picks ve ROI yaklaşık -%16.
# ev_edge < 0 = "model market'in altında olasılık veriyor" = vig'i
# yiyemeyeceğimiz negative-EV bahis. Hard veto: oynama.
# Sniper override hâlâ geçer (yüksek convicted alternatif pick'ler).
if ev_edge < 0.0 and not is_value_sniper:
vetoes.append("negative_ev_edge")
issues.append(f"ev_edge={ev_edge:.3f}_below_zero")
# Trap edge: bizim diagnostic backtest'te ev_edge >= 0.20 olan tüm
# bahisler kaybediyordu (n=10, hepsi -%25+ ROI). Model market'i bu
# kadar yanlış buluyorsa muhtemelen modelin kendisinin yanlış olduğu
# bir senaryo (eksik info, tuhaf maç, vs.) — oynama.
if ev_edge >= 0.20 and not is_value_sniper:
vetoes.append("ev_edge_too_high_trap")
issues.append(f"ev_edge={ev_edge:.3f}_trap_range")
# ── MUTED MARKETS (grid search showed no profitable config) ──
if market in self.MUTED_MARKETS and not is_value_sniper:
vetoes.append("market_muted_by_backtest")
issues.append(f"market_{market}_muted")
# ── PER-MARKET OPTIMAL ENVELOPE (from grid search) ──
envelope = self.MARKET_OPTIMAL_FILTERS.get(market)
if envelope and not is_value_sniper:
if ev_edge < envelope["min_edge"]:
vetoes.append("outside_envelope_edge_low")
if ev_edge > envelope["max_edge"]:
vetoes.append("outside_envelope_edge_high")
if odds and odds < envelope["min_odds"]:
vetoes.append("outside_envelope_odds_low")
if odds and odds > envelope["max_odds"]:
vetoes.append("outside_envelope_odds_high")
if odds_rel < envelope["min_reliability"]:
vetoes.append("outside_envelope_reliability_low")
if envelope["require_v27_agree"] and consensus != "AGREE":
vetoes.append("outside_envelope_v27_must_agree")
if divergence is not None:
if divergence >= self.HARD_DIVERGENCE and not is_value_sniper:
score -= 42.0
@@ -635,6 +729,112 @@ class BettingBrain:
return self._safe_float(ou25.get(key)) if key else None
return None
def _score_consistent_markets(self, package: Dict[str, Any]) -> Optional[set]:
"""Build the set of (market, pick) tuples that WOULD WIN if the
model's own score prediction came true. We use this as a coherence
gate: if the model is confident about a 1-0 outcome but also wants
to play OU25 Üst, those two beliefs contradict each other — and the
score prediction is the more informative one because it aggregates
all market signals into a single most-likely scenario.
Returns None if the score prediction is missing or malformed; in
that case we skip the coherence check.
"""
score_pred = package.get("score_prediction") or {}
ft_raw = str(score_pred.get("ft") or score_pred.get("full_time") or "").strip()
ht_raw = str(score_pred.get("ht") or score_pred.get("half_time") or "").strip()
def parse(s: str) -> Optional[Tuple[int, int]]:
for sep in ("-", ":", ""):
if sep in s:
parts = s.split(sep, 1)
try:
return int(parts[0].strip()), int(parts[1].strip())
except (ValueError, IndexError):
return None
return None
ft = parse(ft_raw)
if ft is None:
return None
ht = parse(ht_raw)
fh, fa = ft
total = fh + fa
consistent: set = set()
# MS / 1X2 — single outcome
if fh > fa:
consistent.add(("MS", "1"))
consistent.add(("ML", "1"))
elif fh < fa:
consistent.add(("MS", "2"))
consistent.add(("ML", "2"))
else:
consistent.add(("MS", "X"))
consistent.add(("ML", "X"))
# DC — two of three legs win at any score
if fh >= fa:
consistent.add(("DC", "1X"))
if fh <= fa:
consistent.add(("DC", "X2"))
if fh != fa:
consistent.add(("DC", "12"))
# Over/Under main lines
for line, market in ((0.5, "OU05"), (1.5, "OU15"),
(2.5, "OU25"), (3.5, "OU35"), (4.5, "OU45")):
if total > line:
for p in ("Üst", "Ust", "Over", "OVER"):
consistent.add((market, p))
elif total < line:
for p in ("Alt", "Under", "UNDER"):
consistent.add((market, p))
# total == line → push, neither side wins → don't add
# BTTS — both teams score
if fh > 0 and fa > 0:
for p in ("Var", "KG Var", "Yes", "YES"):
consistent.add(("BTTS", p))
else:
for p in ("Yok", "KG Yok", "No", "NO"):
consistent.add(("BTTS", p))
# OE — total goals odd/even
if total % 2 == 1:
for p in ("Tek", "Odd", "ODD"):
consistent.add(("OE", p))
else:
for p in ("Çift", "Cift", "Even", "EVEN"):
consistent.add(("OE", p))
# HT-only markets (need HT score)
if ht is not None:
hh, ha = ht
ht_total = hh + ha
if hh > ha:
consistent.add(("HT", "1"))
elif hh < ha:
consistent.add(("HT", "2"))
else:
consistent.add(("HT", "X"))
for line, market in ((0.5, "HT_OU05"), (1.5, "HT_OU15"), (2.5, "HT_OU25")):
if ht_total > line:
for p in ("Üst", "Ust", "Over"):
consistent.add((market, p))
elif ht_total < line:
for p in ("Alt", "Under"):
consistent.add((market, p))
# HTFT — single combo
ht_o = "1" if hh > ha else "2" if hh < ha else "X"
ft_o = "1" if fh > fa else "2" if fh < fa else "X"
consistent.add(("HTFT", f"{ht_o}/{ft_o}"))
consistent.add(("HTFT", f"{ht_o}{ft_o}"))
return consistent
def _triple_value(self, package: Dict[str, Any], key: Optional[str]) -> Optional[Dict[str, Any]]:
if not key:
return None
+13 -1
View File
@@ -449,6 +449,12 @@ class DataLoaderMixin:
return 1.5, 1.2
return weighted_for / total_weight, weighted_against / total_weight
# Approximate European season window — Eredivisie/PL/La Liga start late
# July / mid-August, end May. Using 300 days as a buffer covers most
# competitions while excluding "career points" from previous seasons.
# When a proper seasons table lands this should query season boundaries.
_SEASON_LOOKBACK_MS = 300 * 24 * 60 * 60 * 1000
def _estimate_league_position(
self,
cur: RealDictCursor,
@@ -458,6 +464,7 @@ class DataLoaderMixin:
) -> int:
if not team_id or not league_id:
return 10
season_start_ms = before_date_ms - self._SEASON_LOOKBACK_MS
try:
cur.execute(
"""
@@ -478,6 +485,7 @@ class DataLoaderMixin:
AND m.score_home IS NOT NULL
AND m.score_away IS NOT NULL
AND m.mst_utc < %s
AND m.mst_utc >= %s
UNION ALL
SELECT
m.away_team_id AS team_id,
@@ -492,11 +500,15 @@ class DataLoaderMixin:
AND m.score_home IS NOT NULL
AND m.score_away IS NOT NULL
AND m.mst_utc < %s
AND m.mst_utc >= %s
) tm
GROUP BY tm.team_id
ORDER BY points DESC
""",
(league_id, before_date_ms, league_id, before_date_ms),
(
league_id, before_date_ms, season_start_ms,
league_id, before_date_ms, season_start_ms,
),
)
rows = cur.fetchall()
if not rows:
@@ -225,20 +225,43 @@ class FeatureBuilderMixin:
if enrichment_failures:
print(f"⚠️ Enrichment partial failures for {data.match_id}: {', '.join(enrichment_failures)}")
# ── Cup game detection (used by upset engine + elo dampening below) ──
_league_name_lower = (getattr(data, 'league_name', '') or '').lower()
_cup_keywords = ("kupa", "cup", "coupe", "copa", "coppa", "pokal",
"trophy", "shield", "ziraat", "süper kupa", "super cup",
"beker", "taça", "taca")
_is_cup_match = any(kw in _league_name_lower for kw in _cup_keywords)
# ── League size hint: top European leagues 18-20 teams, lower 16-24 ──
# We don't have a per-league team count, so fall back to 20 (standard).
# When standings infra lands this should pull from seasons table.
_league_total_teams = 20
# Upset engine features
upset_atmosphere, upset_motivation, upset_fatigue = 0.0, 0.0, 0.0
try:
upset_engine = get_upset_engine()
# Use the real position estimates from data_loader; fall back to mid-
# table (10) only when the loader couldn't compute one. Hardcoding 10
# for every team made motivation_score collapse to 0 for everyone.
_home_pos = getattr(data, 'home_position', None)
_away_pos = getattr(data, 'away_position', None)
if _home_pos is None or _home_pos <= 0:
_home_pos = 10
if _away_pos is None or _away_pos <= 0:
_away_pos = 10
upset_feats = upset_engine.get_features(
home_team_name=getattr(data, 'home_team_name', '') or '',
home_team_id=data.home_team_id,
away_team_name=getattr(data, 'away_team_name', '') or '',
league_name=getattr(data, 'league_name', '') or '',
home_position=10,
away_position=10,
home_position=_home_pos,
away_position=_away_pos,
match_date_ms=data.match_date_ms,
is_cup_match=_is_cup_match,
home_days_rest=int(home_rest),
away_days_rest=int(away_rest),
total_teams=_league_total_teams,
)
upset_atmosphere = upset_feats.get('upset_atmosphere', 0.0)
upset_motivation = upset_feats.get('upset_motivation', 0.0)
@@ -276,15 +299,10 @@ class FeatureBuilderMixin:
is_season_start = 1.0 if match_month in (7, 8, 9) else 0.0
is_season_end = 1.0 if match_month in (5, 6) else 0.0
# ── Cup game detection: dampen home advantage in feature space ──
_league_name = (getattr(data, 'league_name', '') or '').lower()
_cup_keywords = ("kupa", "cup", "coupe", "copa", "coppa", "pokal",
"trophy", "shield", "ziraat", "süper kupa", "super cup")
_is_cup = any(kw in _league_name for kw in _cup_keywords)
# ── Derived / Interaction features (V27) ──
# Cup games: home ELO advantage is ~30% weaker (rotation, lower motivation)
elo_diff = (home_elo - away_elo) * (0.70 if _is_cup else 1.0)
# Uses _is_cup_match computed earlier (before upset engine call).
elo_diff = (home_elo - away_elo) * (0.70 if _is_cup_match else 1.0)
form_elo_diff = home_form_elo_val - away_form_elo_val
attack_vs_defense_home = data.home_goals_avg - data.away_conceded_avg
attack_vs_defense_away = data.away_goals_avg - data.home_conceded_avg