Skip to content

betting_combat.rounds.backtest.labeler

The meta model’s rows and labels (Sam, 2026-10-27): one row per bet - a break x strategy x contract the break flagged - built from a strategy’s backtest (joint.run / noko.run with ledger and flags).

row a break's bet: the contracts the break may buy (``flags``: the joint execution's
``live.joint.buy_candidates``, the 'no KO' strategy's candidate - the edge after
fees clears the strategy's min edge), filled or not. In-round never opens a bet (it
adds to the break's flagged contracts or cuts a holding below its cost): the round's
adds belong to the break's row of that contract, a sale (a break's or a cut) to the
rows holding the contract then, pro rata to their open contracts (the backtests
release the basis pro rata)
label 1 if the contract pays at the end, else 0 (a contract bought under $1 cannot break
even at the end: 1 = made money held to the end): rounds NO (RN) the round after the
break does not end the fight, rounds YES (RY) it does; distance YES (DY) and the pair
(PR, settled as the backtest settles it) the fight goes the distance, distance NO (DN)
it does not; KO NO the fight does not end by KO/TKO/DQ (Kalshi's KO option)
pnl the bet's dollars: its buys at the break and in its round, its share of every sale,
the rest settled; summed over a fight, the strategy's backtest P&L to the cent
life from the decision to the contract's settlement: a rounds contract at the end of the
round after the break (or the fight's end, if earlier), every other one at the
fight's end
weight Lopez's average uniqueness (AFML 4.4): over the row's life, the mean of 1 / the
number of rows alive then (every strategy's rows of the same fight)

row_id: the break’s decision id (trading.records.decision_id: card date, fight, strategy, clock minute 6 x round_idx) and the contract.

Functions

build

build(flags: pd.DataFrame, trades: pd.DataFrame, outcomes: pd.DataFrame, times: pd.DataFrame, strategy: str) -> pd.DataFrame

A strategy’s rows (ROW_COLUMNS but weight: uniqueness over every strategy’s).

flags the backtest’s flags (fight_id, event_date, round_idx, t, inst, p, ask, c, bid, held, held_basis; kelly_dollars / last / event_id where it has them) trades its ledger as trades (ledger_joint / ledger_noko) outcomes per (fight_id, round_idx): ends_round (the round after the break ended the fight), decision (it went the distance), ko (it ended by KO/TKO/DQ), event_id times per (fight_id, round_idx): t_break (the decision’s time where the flag has none), round_end (the end of the round after the break, or the fight’s end if earlier), fight_end

by_strategy

by_strategy(rows: Mapping[str, pd.DataFrame]) -> pd.DataFrame

Every strategy’s rows together with their weights (uniqueness across strategies).

label

label(inst: str, ends_round: int, decision: int, ko: int) -> int

1 if a contract of inst pays at the end: ends_round the round after the break ended the fight, decision it went the distance, ko it ended by KO/TKO/DQ.

ledger_joint

ledger_joint(ledger: pd.DataFrame) -> pd.DataFrame

joint.run’s ledger as trades: fight_id, round_idx, t, kind (‘buy’ / ‘sell’), phase (‘break’ / ‘round’), inst, contracts (> 0), unit (a buy’s all-in, a sale’s net), in order.

ledger_noko

ledger_noko(ledger: pd.DataFrame) -> pd.DataFrame

noko.run’s ledger as trades (ledger_joint’s columns; the contract KO_NO).

uniqueness

uniqueness(rows: pd.DataFrame, step_s: float = 1.0) -> np.ndarray

Lopez’s average uniqueness (AFML 4.4) of each row: over its life (life_start to life_end, on a step_s grid), the mean of 1 / the number of rows of the same fight alive at that time (every strategy’s). A row with no life (it settles at its decision) counts as alive for one step.