e29ab6fd6a
PART 1 verified by inducing the REAL rowsFromSnapshot over REAL lock_lines
rows from prod. Three cases, 0 non-takeable anchors:
Narvaez (dabble/kalshi/prizepicks/smarkets, NO takeable book)
-> book=null, price=null, takeable=null [honest absent]
Schwarber(bovada/dabble/novig/PINNACLE before draftkings)
-> draftkings +102 [pinnacle SKIPPED, proving TAKEABLE not MODEL]
Ohtani (dabble/onexbet before draftkings) -> draftkings -266
Narvaez is the case that matters: pre-fix he was stamped dabble +104
takeable=true; he is now honestly absent.
A HARNESS BUG RECORDED: my first verification pulled live /api/odds/mlb,
which returned {"error":"Odds data temporarily unavailable"}. The script
read that as 0 props and printed "all from takeable books? true" -- a
VACUOUSLY TRUE pass. I caught it only because I also printed the book list
and it was empty. Same family as the silent-false traps: a probe that finds
nothing looks identical to a probe that finds nothing wrong.
PART 2: 1,006 rows tagged via the purpose-built quarantine_reason at ROW
level with three sub-cases (recoverable_same_line 936, no_takeable_quote
49, takeable_line_differs 21). getModelAggregate ALREADY excluded
quarantined rows, so the public record and the n>=20 gate were clean
automatically; all five committed holdout scripts now carry the exclusion
explicitly.
PART 3 -- the re-stamp call is now fact-based. The takeable LOCK-TIME price
is recoverable for 936/1,006 (93.0%) from lock_lines, the correct
instrument. Only 431 appear in closing_captures, which is the wrong timing
for a lock price anyway.
LINE CONTAMINATION ANSWERED (previously unverified): the stored line
MATCHES a takeable book's line on 936 (93.0%), DIFFERS on 21 (2.1%), and is
unverifiable on 49 (4.9%) where no takeable book quoted the prop at all.
That makes it cleanly row-level: re-stamp the 936 as an honest JOIN and
recover 886 pending rows for the holdouts, or leave all 1,006 excluded.
Either way the 21 + 49 stay out -- re-stamping those would invent a lock
price, or a line, we never captured. Nothing re-stamped; Kev's call.
Gates: 4,111 tests / 330 suites green; next build exit 0.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QJs13VsyiSKYQP6rj3NNmc
59 lines
2.8 KiB
SQL
59 lines
2.8 KiB
SQL
-- opportunity-axis-holdout.sql — the Step 4 proof, RUN WHEN n IS ADEQUATE.
|
|
--
|
|
-- Cannot run yet, by construction: the axis went live 2026-08-01 and its first
|
|
-- rows carry game_date 2026-08-01 (games not yet played). Settled rows carrying
|
|
-- the axis: 0. The earliest possible run is the next morning settle pass, and a
|
|
-- defensible n is several days out at ~140 opportunity-axis rows per snapshot.
|
|
--
|
|
-- BOTH reliability AND resolution must improve for the axis to promote. One or
|
|
-- neither => SHELVE and record why.
|
|
--
|
|
-- reliability = n-weighted mean |predicted - actual| across deciles. Bucket
|
|
-- FIRST: mean|p - outcome| on 0/1 rows is noise-dominated individual error, not
|
|
-- calibration.
|
|
|
|
--
|
|
-- CONTAMINATION EXCLUSION (2026-08-02, MANDATORY). Rows whose price/book/takeable
|
|
-- were stamped from a NON-TAKEABLE book (DFS / offshore / exchange) between
|
|
-- 2026-08-01 and the write-path fix are tagged `quarantine_reason LIKE
|
|
-- 'nontakeable_book%'`. They are EXCLUDED here and must never be pooled with
|
|
-- clean rows: their locked price -- and therefore the `takeable` flag computed
|
|
-- from it -- describes a market you could not have bet.
|
|
|
|
with rows_ as (
|
|
select game_date, id,
|
|
p_win::numeric champ,
|
|
p_win_challenger::numeric chal,
|
|
(outcome='hit')::int won
|
|
from public.ledger_entries
|
|
where sport='mlb' and user_id is null
|
|
and (quarantine_reason is null or quarantine_reason not like 'nontakeable_book%')
|
|
and outcome in ('hit','miss')
|
|
and p_win is not null and p_win_challenger is not null
|
|
-- ONLY rows the opportunity axis actually touched. Including untouched rows
|
|
-- would dilute the comparison with rows where challenger === champion by
|
|
-- construction, and make a null result look like a small positive one.
|
|
and challenger_adjustments::text like '%opportunity%'
|
|
),
|
|
split as (
|
|
select *, case when ntile(2) over (order by game_date, id) = 1 then 'train' else 'holdout' end split
|
|
from rows_
|
|
),
|
|
b_champ as (
|
|
select split, width_bucket(champ, 0.0, 1.0, 10) bkt, count(*) n, avg(champ) pred, avg(won::numeric) actual
|
|
from split group by 1,2),
|
|
b_chal as (
|
|
select split, width_bucket(chal, 0.0, 1.0, 10) bkt, count(*) n, avg(chal) pred, avg(won::numeric) actual
|
|
from split group by 1,2)
|
|
select
|
|
s.split,
|
|
count(*) n,
|
|
round((select sum(n*abs(pred-actual))/nullif(sum(n),0) from b_champ c where c.split=s.split),4) reliability_champion,
|
|
round((select sum(n*abs(pred-actual))/nullif(sum(n),0) from b_chal c where c.split=s.split),4) reliability_challenger,
|
|
round(corr(s.champ, s.won::numeric)::numeric,4) resolution_champion,
|
|
round(corr(s.chal, s.won::numeric)::numeric,4) resolution_challenger,
|
|
round(avg(s.won::numeric),4) base_rate
|
|
from split s
|
|
group by s.split
|
|
order by s.split desc;
|