Skip to content

betting_combat.models.inround_price

inround_price - the price INSIDE a round, block by block (Sam 2026-11-17): a walk of 30-second steps from the price at one bell to the price at the next, pinned to both. The bells’ prices are given (Kalshi’s real ones on its cards; PriceSimulator’s for every fight since 2015): this fills the round between them.

the walk steps on the log-odds scale, each drawn from the real steps of the same market, phase (the
break / the round's minute 1-5) and price level; ``DRAWS`` free walks per round, the ``KEEP``
that land nearest the end kept and pinned to it exactly (the miss taken back across the steps
in proportion to each step's variance: a random walk conditioned on where it ends)
stats=True each step also moved by what happened in the fight in that block, the one before and the one
after (the market sees the fight before Cito's feed shows it): least squares on the fights Cito
read; the steps drawn are then what the stats leave (knockdown blocks from their own pool)

One path per fight x round x market (segments), always from the round’s bell (the price at the end of the break’s last block, -1): winner fighter A wins; to the next bell (the round’s blocks + the break’s two) distance the fight goes the distance; the same span ko it ends by KO / TKO / DQ; the same span finish_round it ends in this round (‘ends before the next round’); to its last price before the horn (the settle at the horn is a jump: the YES bid holds a few cents until then) the fight’s last round: to the block before the finish second’s (the jump is the result’s, not the walk’s) or to the horn on a decision (in a test every end is a real price; for fights without one, the ends come from elsewhere: the bells from PriceSimulator, the last price before a finish or the horn still to be built)

The block’s price (PRICE, picked on the real blocks’ noise): winner = its last print (1-2c spreads: no bounce between bid and ask), distance = its volume-weighted price (its last print bounces), finish_round = the YES bid at the block’s end (its prints sit on the bid, its mid stays half an ~20c spread above them), ko = the quote’s mid at the block’s end where the spread is within MAX_SPREAD. Blank where there is none: a walk is judged only where the real price is seen.

scale=True (default) each walk draws its own scale from the real paths' (a calm round, a wild one: the
moves of a path are not independent draws), the moves drawn in those units

GUARD: the walk is pinned to where the price ended (and the bells’ prices know the outcome): for testing rules and as the yardstick, NEVER an input to an outcome model.

InroundInputs the reads: features.market_blocks, ufc.bouts, features.fight_blocks
series one price per fight x round x block x market
segments the paths: one row per path (start, end) + one per step
stat_features each step's block stats (the block before, its own, the one after)
InroundPriceWalk fit / simulate
score_blocks, score_paths the real price against the simulated ones

Classes

InroundInputs

read

read(db: DBClient) -> InroundInputs

InroundPriceWalk

The walk between two bells’ prices (module doc). stats: the steps moved by the block’s stats.

fit

fit(segs: pd.DataFrame, steps: pd.DataFrame, X: pd.DataFrame | None = None) -> InroundPriceWalk

Per market: the level bins, the stats’ push (stats), the pools of what is left of each real move.

simulate

simulate(segs: pd.DataFrame, steps: pd.DataFrame, X: pd.DataFrame | None = None) -> np.ndarray

keep pinned paths per path, aligned with steps’ rows: the log-odds price at each step (the last step = the end, exactly). Rows of a market without a model stay blank.

JointPriceWalk

Bases: InroundPriceWalk

The four markets walked together (Sam 2026-11-18): each block, every market’s move = its stats’ push (as InroundPriceWalk(stats=True)) + its own leftover, the four leftovers drawn TOGETHER from one real block (the same block of a real fight: one exchange moves the winner, the distance and the KO at once; where the real block lacks a market’s price, that one from its own pool), each round’s calm or wild scale drawn together from one real round. lags: the four markets’ moves of the block before push too (a VAR of one block’s lag; the winner its own, the others the four). Kept: the draws whose ends land nearest every market’s end together (each miss in its own path’s spread), each market then pinned to its end exactly - one simulated fight-round across the four, the same draw in every market’s column k of the output. given_end: no draw thrown away (four ends at once leave a nearest-draws pick loose): each draw’s four scales from a real round picked by how likely its scales make the four ends (each market’s move to its end less its stats’ push, against its scale x its steps’ spread), every draw then pinned.

fit

fit(segs: pd.DataFrame, steps: pd.DataFrame, X: pd.DataFrame | None = None) -> JointPriceWalk

Per market as the walk with stats (the push now from the stats and, lags, the block before’s moves); then the joint pieces: every real block’s four standardized leftovers, every real round’s four scales.

simulate

simulate(segs: pd.DataFrame, steps: pd.DataFrame, X: pd.DataFrame | None = None) -> np.ndarray

keep pinned joint paths per fight-round, aligned with steps’ rows (column k: the same draw in every market); rows of a market without a model stay blank.

Functions

card_folds

card_folds(segs: pd.DataFrame, k: int = 5) -> pd.Series

Each path’s fold: the cards cut into k runs in time, a card whole in one (purged by card).

lag_features

lag_features(segs: pd.DataFrame, steps: pd.DataFrame) -> pd.DataFrame

Each step’s block-before moves of the four markets (the real moves at its path’s previous point, 0 where unseen or at the path’s first step), aligned with steps: lag_winner (A’s, signed), lag_abs_winner, lag_distance, lag_ko, lag_finish_round. The winner reads its own (the A / B mirror); the others the four.

moves

moves(segs: pd.DataFrame, steps: pd.DataFrame) -> pd.DataFrame

The real one-block moves: each step’s price minus the one before (j = 1: the bell’s), where both are seen; level: the price before the move.

score_blocks

score_blocks(segs: pd.DataFrame, steps: pd.DataFrame, sims: np.ndarray, seed: int = 0) -> pd.DataFrame

Every seen real price inside a path (not its end) against its simulated ones, on the price scale: pit, in the middle 50 % / 80 %, crps; line: a straight line between the two ends, |miss|.

score_paths

score_paths(segs: pd.DataFrame, steps: pd.DataFrame, sims: np.ndarray) -> pd.DataFrame

Each path’s length on the price scale (the sum of its moves between the prices seen, the two ends included), the real one against the simulated ones: pit, inside the middle 80 %.

segments

segments(S: pd.DataFrame, bouts: pd.DataFrame) -> tuple[pd.DataFrame, pd.DataFrame]

The paths. segs: seg, market, bout_id, event_id, date, round, n (steps), x0 / x_end (log-odds), how (‘next_bell’ / ‘horn’ / ‘pre_finish’ / ‘settled’). steps: seg, j (1..n), bout_id, r_b / block (the block it ends), phase, x (the real price there, blank where unseen; j = n: the end), end.

series

series(blocks: pd.DataFrame, bouts: pd.DataFrame, venue: str = 'kalshi') -> pd.DataFrame

One price per fight x round x block x market (PRICE), on the exact clocks only: bout_id, event_id, date, round, block, market, clock_source, p (blank: none in the block). Kalshi’s (the walk is fitted on its markets), unless venue.

stat_features

stat_features(steps: pd.DataFrame, stats: pd.DataFrame) -> pd.DataFrame

Each step’s block stats, aligned with steps: {lag}_{stat}_d (A - B) and _t (A + B) for the block before (-1), its own (0) and the one after (1), control in 30 s units; the break’s steps none. cito: Cito read the step’s block; kd: a knockdown in the block itself; kd_sign: whose (+1 A, -1 B); event: a knockdown in any of the three.