Skip to content

betting_combat.features.market

market — the market table: what the prediction markets did, per fight and per round. Kalshi k_, Polymarket p_, Polymarket US pu_; both corners explicit (fighter_a / fighter_b: each corner’s own winner market). KEY (bout_id, round): round 0 is the fight row (everything before the first bell), round r what happened in the market INSIDE round r and in the break after it (the same idea as fighter_stats: the model rows read rounds before theirs).

A price is given as the venue quotes it (bid, ask, last, mid: the mid of a two-sided quote, else the last), as the odds it means (_odds: 1 / price) and as the fair chance (_p: a corner’s mid over both corners’ mids).

fight row per venue and corner: bid, ask, last, mid at the bell and their odds; the mid and
its odds 7 d, 3 d, 1 d, 6 h, 1 h before; the fair chance at each; the spread and
the open interest at the bell; the trading before the bell (trades, contracts,
dollars, the corner's flow: contracts bought on it less sold, over all; the last
day's contracts, dollars, flow, VWAP; big trades' share, $500+); the last day's
realised volatility and jumps (minutes moving 5 c+); days listed. The distance
market (yes) and each corner's method markets (KO/TKO, submission, decision) at
the bell where the venue lists them
round rows per venue and corner: the quote at the round's start and end (bid, ask, last,
mid, their odds), the move, the high and low, the trading inside the round, its
jumps; the mid at the end of the break after it and the break's trading; the fair
chance at the start and the end; the distance market at the start and the end

The fight’s clock, each moment from its best teller: Cito’s round starts where told (2026); else Kalshi’s rounds tape: ‘ends before round k+1’ settles at 0 the second round k ends without a finish (rounds.market.bell.tape_bell), so round k ends there and round k+1 starts a break later, round 1 at round 1’s end less 5:00 (TAPE_LAG added back: measured against Cito’s told starts); else derived: a winner market settles the minute the result is known (its first reading at 99 c+ or 1 c- after trading between 10 and 90 c in the 3 hours before); less the fight’s length (5-minute rounds, 1-minute breaks, the last round to its told time) and the result’s delay (a decision is read out minutes after the bell; measured on the fights Cito timed) gives the first bell and each round’s start and end. The derived clock is off by more than a minute for 40 % of decisions (the reading delay varies; checked on the 146 fights Cito timed, 2026-11-15): the tape’s is within about 30 s. Before 2026 the cut is that bell, never the card’s start (events.starts_at is the main card’s then). flag_m_clock (the first bell) and each round’s flag_r_start / flag_r_next: 0 told, 1 derived, 2 the fight’s scheduled time (a fight to come), 3 the rounds tape. Flags are never inputs.

Classes

MarketInputs

The raw rows the table reads (read), or handed in (tests). clock holds both parts (_part ‘fights’: bout, bell, end, flag; ‘rounds’: bout, round, start, end, next start); trades the trading per market and segment (pre, pre1d, r{k}, b{k}); methods each method market’s quote at the bell.

read

read(db: DBClient, schema: str = 'ufc') -> MarketInputs

MarketTable

Bases: FeatureTable

features.market: per fight a fight row and its rounds, what the venues did (module doc).

build

build(db: DBClient, base: Base | None = None) -> dict[str, int]

compute

compute(base: Base) -> pd.DataFrame

update

update(db: DBClient, since: Any, base: Base | None = None) -> dict[str, int]

Functions

clock

clock(bouts: pd.DataFrame, settle: pd.Series, told: pd.DataFrame, tape: pd.DataFrame | None = None) -> tuple[pd.DataFrame, dict[str, float]]

Each bout’s first bell and its rounds (start, end, the next round’s start), each from its best teller (the module doc: Cito told, the rounds tape, else the settle less the length and the result’s delay DELAY_S); the teller in flag_m_clock / flag_r_start / flag_r_next. Also the delays used.

mid

mid(df: pd.DataFrame) -> pd.Series

The mid of a two-sided quote, else the last trade; a price only inside 0 .. 1.

read_clock

read_clock(db: DBClient, schema: str = 'ufc') -> pd.DataFrame

Every fight’s clock as this table builds it (clock): the ‘fights’ part (bell, end, flag_m_clock) and the ‘rounds’ part (round, start, end, next_start, flag_r_start / flag_r_next: 0 Cito told, 3 the rounds tape, 1 derived from the settle, 2 a fight’s scheduled time).

segments

segments(markets: pd.DataFrame, clk: pd.DataFrame) -> pd.DataFrame

The trading windows per winner market: before the bell, its last day, each round, each break.

settles

settles(minutes: pd.DataFrame, markets: pd.DataFrame, days: pd.Series | None = None) -> pd.Series

Per bout: the first minute a winner market read 99 c+ or 1 c- after trading between 10 and 90 c in the 3 hours before (the result known), on the card’s day (days: bout -> its date; from 12 h before it to 2 days after: a market settled weeks early is a fight called off).

tape_bells

tape_bells(tape: pd.DataFrame, approx: pd.Series, max_rounds: int = 5) -> dict[tuple[str, int], pd.Timestamp]

Round k’s end per bout from Kalshi’s rounds tape (tape: bout_id, before_round, ts, yes_price): the backtests’ tape_bell on ‘ends before round k+1’, searched from round k-1’s bell + the break (round 1: from 5 minutes before the fight’s approx first bell). A round that ended in a finish has none (the market settles at 1), nor any round after it.