betting_combat.models.block_price_simulator
block_price_simulator — what the markets would have shown in every 30-second block of every round since 2015 (Sam
2026-11-18): BlockPriceSimulator, one class beside StatsSimulator (the blocks’ stats) and PriceSimulator
(the round starts’ prices). Four markets on Kalshi’s YES side, framed as models.inround_price: winner (fighter A
wins), distance, finish_round (it ends in this round), ko (it ends by KO / TKO / DQ); per block the price (the walk’s
PRICE: winner / distance / ko about the mid, finish_round the YES bid) and the bid / ask.
the bells ``PriceSimulator``'s draws at each round start (its stage 2, the informed market) as the walk's price: winner, distance, ko the mid of the draw's bid / ask (ko: 1 - the no-KO mid), finish_round the YES bid (1 - the no-finish ask)the ends where no next bell pins a path - a round's finish_round at the horn (a round before the fight's last), every market in the fight's last round (the block before the finish, or the horn) - ``EndPrice``: logit(end) = a + b logit(bell) + c (outcome - bell) + d log(blocks), per market x end, its misses drawn from the real ones (Kalshi's exact-clock paths)the walk ``InroundPriceWalk(stats=True)`` (g12 / g12b: kept over the joint walks), fitted on the rounds Cito read with their real stats, walked on the StatsSimulator's stats of the same draw, pinned to both ends: one path a market x round x drawthe quotes ``BlockQuotes``: each block's spread - log(spread) by market: phase + |logit p| + |the block's move| (least squares on Kalshi's real blocks), its leftovers one real round's in order, drawn from the latest ``RECENT`` cards (today's market, as PriceSimulator) - the bid / ask around the price (finish_round's price is its bid), whole cents
BlockPriceInputs the reads: market_blocks, bouts, the live stats blocksreal_block_quotes the real blocks: Kalshi's price / bid / ask per market, Polymarket's price, Polymarket US's bid / ask / mid - the in-round table's draw 0bell_prices PriceSimulator's draws as the walk's bellsBlockPriceSimulator fit / simulate / assess (the gates) / save, loadGUARD: built from the outcomes (the bells’ and the ends’ informed market): history for rules and the in-round model’s training, judged on real live blocks; never an outcome model’s input.
Classes
BlockPriceInputs
The reads: features.market_blocks (every venue), ufc.bouts, features.fight_blocks (the live stats).
read
read(db: DBClient) -> BlockPriceInputsBlockPriceModels
Bases: FeatureTable
features.block_price_models: every fitted BlockPriceSimulator, by version.
BlockPriceSimulator
The blocks’ prices (module doc).
assess
assess(inputs: BlockPriceInputs, k: int = 5) -> dict[str, Any]The ends (k runs of Kalshi’s cards in time, each whole: fitted on the others): per market x end the middle 80 % of the held-out real ends and the CRPS against the bell held flat; the quotes (fitted before the latest GATE_CARDS cards, drawn on those cards’ real prices): the median spread against the real per market, and the real spreads’ place in the simulated middle 80 %.
fit
fit(inputs: BlockPriceInputs) -> BlockPriceSimulatorThe walk on the rounds Cito read (their real stats), the ends on every Kalshi exact-clock path, the quotes on Kalshi’s real blocks.
forecast
forecast(R: pd.DataFrame, stats: pd.DataFrame, bells: pd.DataFrame, bouts: pd.DataFrame, draws: tuple[int, ...] = (1,)) -> pd.DataFrameStep 5: R’s rounds on cards this fit never learned from, walked by it (fold ‘final’).
from_json
from_json(b: dict[str, Any]) -> BlockPriceSimulatorload
load(name: str) -> BlockPriceSimulatorload_db
load_db(db: DBClient, version: str | None = None) -> tuple[BlockPriceSimulator, pd.Timestamp] | Noneout_of_sample
out_of_sample(inputs: BlockPriceInputs, R: pd.DataFrame, stats: pd.DataFrame, bells: pd.DataFrame, draws: tuple[int, ...] = (1,), n_jobs: int = 1) -> pd.DataFrameSteps 3-4: each training card’s rounds in R walked (simulate: on stats’ draws from bells’ draws - both
out of sample for the card themselves) by a fit on every OTHER card - the card’s fights out of the market blocks and
the live stats; fold the card. Rounds on cards with no market blocks: the final fit’s (forecast).
save
save(name: str | None = None) -> Pathsave_db
save_db(db: DBClient) -> dict[str, int]simulate
simulate(R: pd.DataFrame, stats: pd.DataFrame, bells: pd.DataFrame, bouts: pd.DataFrame, draws: list[int]) -> pd.DataFrameFor each draw in draws: the rounds R (round_rows) walked on that draw’s simulated stats (stats:
draw, bout_id, round, block, a_* / b_*) from that draw’s bells (bell_prices, draw); one row a (bout_id,
round, block, draw): {m}_p, {m}_bid, {m}_ask. A fight’s finish block: blank (the fight ends in it).
to_json
to_json() -> dict[str, Any]training_cards
training_cards(inputs: BlockPriceInputs) -> set[str]The cards a fit learns from: every card with market blocks (and the live stats of their fights).
BlockQuotes
Each block’s spread (module doc): per market least squares of log(spread) on the phase (6), |logit p| and
|the block’s move|; its leftovers whole real rounds’ (Kalshi’s blocks), the latest RECENT cards’ drawn.
draw
draw(Q: pd.DataFrame, rng: np.random.Generator) -> tuple[np.ndarray, np.ndarray]The bid / ask of each row of framed quotes (with draw): one recent real round’s leftovers a (bout_id,
round, draw, market), in block order.
fit
fit(real: pd.DataFrame, dates: pd.Series) -> BlockQuotesreal: real_block_quotes’ Kalshi columns, long (bout_id, round, block, market, p, bid, ask); dates:
each fight’s date (the latest cards’ leftovers).
frame
frame(Q: pd.DataFrame) -> pd.DataFrameQuotes’ rows: per (bout_id, round, block, market) with p, its move from the block before (in that round’s order), the phase.
EndPrice
Where no next bell pins a path (module doc): per market x end (ENDS) least squares of the log-odds end on
[1, the bell, outcome - the bell’s chance, log(blocks)], its misses drawn from the real ones (a thin cell: the
market’s ends pooled).
draw
draw(R: pd.DataFrame, rng: np.random.Generator) -> np.ndarrayOne end per row of R (market, end, x0, y, n): the fit + a real miss of its cell (blank: no fit).
fit
fit(E: pd.DataFrame) -> EndPricequantiles
quantiles(R: pd.DataFrame, qs: tuple[float, ...]) -> np.ndarrayrows
rows(segs: pd.DataFrame, bouts: pd.DataFrame) -> pd.DataFrameThe real ends of Kalshi’s paths: market, end (ENDS), x0, x_end, n, y (the market’s outcome).
Functions
bell_prices
bell_prices(raw: pd.DataFrame) -> pd.DataFramePriceSimulator’s raw draws (bout_id, brk, market, draw, bid, ask) as the walk’s bells: bout_id, round (brk + 1), draw, market (ours), x (log-odds): winner / distance the mid, ko 1 - the no-KO mid, finish_round the YES bid of ‘ends in this round’ = 1 - the no-finish (‘rounds’) ask.
history_paths
history_paths(R: pd.DataFrame, bells: pd.DataFrame, bouts: pd.DataFrame) -> tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame]One draw’s paths for the rounds R (bout_id, round, n, L, end; one draw of bells: bout_id, round, market,
x): segs (seg, market, bout_id, event_id, date, round, n, x0, x_end (blank: an end to draw), how, end, y),
steps (seg, j, bout_id, r_b, block, phase, x, end) - the rules of inround_price.segments (to the next bell
through the break, finish_round to the horn, the fight’s last round to the block before the finish or the
horn) - and holds: the break blocks no path walks (finish_round at its round’s bell, round 1’s minute
before the bell), their price the bell’s.
real_block_quotes
real_block_quotes(blocks: pd.DataFrame, bouts: pd.DataFrame) -> pd.DataFrameEvery real block (bout_id, round, block), per market: Kalshi’s {m}_p (the walk’s price), {m}_bid, {m}ask (the quote at the block’s end, our side: winner fighter A’s - its own market, else 1 - B’s); Polymarket’s poly{m}p (its last print in the block, else its last minute’s); Polymarket US’s polyus{m}_bid / _ask / _p (the mid).