betting_combat.rounds.backtest.execution
The backtest of any strategy under the one execution (rounds.execution, 2026-11-08): each
fight’s breaks as the card run decides them (backtest.joint’s timing, prices and fills), the
strategy’s Execution deciding at every break it trades and every in-round minute after one.
Replaces backtest.joint.run (rounds, distance) and backtest.noko.run (no KO): with
their settings it reproduces the first to the cent (tests/primary/test_execution_parity.py)
and the second up to its own pricing (see the parity notes there).
breaks per round start k >= 1 in the decision grid (``working.decision_grid``) whose probabilities are known: decided at the market's bell or the feed (``working.bell_decision``); the rounds / distance quotes the grid's (the book known at the decision), the pair's asks likewise, its bids, a held distance position's bid and the KO market's book from the minute books known at the decision; the chances (``space.Chances.at_break``); the candidates the grid's candidate bets (``models.candidates``) and KN when its edge is positive (``Execution.candidates``)scope the strategy decides only at the breaks it trades (``Settings.trades_break``: all, all but the last, the last; the formats) and in the rounds after them; every break still settles the rounds market of the round before (the fight reached it)in-round ``backtest.joint``'s: every ``mid_interval_s`` of the round after a traded break, from its start + 60 s, before the next round's bell and the next break's decision, tau < 5:00, the winner books open; the chances on the strategy's clock; the minute's books; buys of that break's candidates only; each order <= the volume share of its market's recent dollars (None: no cap)fills at most the recorded books' 25th-percentile depth per market, phase and side (``DEPTH``; the KO market's from the 2026-10-10 / 10-17 books), at the quote + the slip (the pair: each leg), Kalshi's fee; ``Fills.capacity``: a recorded book's contracts instead (the limit-price study)settle a rounds market of an earlier round settles NO at the next break; at the end the rounds market by its round, the distance, pair and KO market by the fightledger every fill: where, when, the instrument, planned / filled contracts, the price, the all-in unit, the fee and ``p`` (the decision's chance the instrument pays: a buy's expected profit = contracts x (p - unit), a sale's = contracts x (unit - p))Classes
Decision
One fight’s break after round round_idx: when and how it was decided, the window, the
chances’ inputs, the outcomes, every instrument’s price and the grid’s candidate bets.
chances
chances(draw: float, shade: float) -> ChancesFills
How orders fill: at most depth contracts per (market kind, phase, side taken), at the
quote + slip; capacity (fight_id, round_idx, inst, ‘buy’ / ‘sell’, phase, t, H) -> the
contracts a recorded book offered at the order’s limit (None: the table’s).
buy
buy(inst: str, n: float, pr: Price, phase: str, cap: float | None, where: tuple[str, int, Any, float] | None = None, p: float | None = None) -> tuple[float, float, float, float](filled, all-in per contract, fee per contract, price). where (fight_id, round_idx,
t, the window’s seconds) and p (P(the instrument pays)): for fills that read a book.
room
room(inst: str, kind: str, phase: str) -> floatsell
sell(inst: str, n: float, pr: Price, phase: str, cap: float | None, where: tuple[str, int, Any, float] | None = None, p: float | None = None) -> tuple[float, float, float, float](sold, net per contract, fee per contract, price).
Functions
breaks
breaks(events: pd.DataFrame, grid: pd.DataFrame, probs: pd.DataFrame, minutes: pd.DataFrame, timing: Timing, cushion: float = 0.01, fights: Sequence[str] | None = None) -> dict[str, list[Decision]]Per fight, its breaks in order (round_idx >= 1, in the grid, priced): backtest.joint.breaks
with the KO market and the KO chances. events: the candidate bets
(models.candidates.candidate_events); fights: which fights (None: every fight with a
candidate bet; the no-KO strategy needs every priced fight).
probs_of
probs_of(P: pd.DataFrame, rows: pd.DataFrame) -> pd.DataFrameThe runner’s probabilities from the primary’s chances P (primary_* cells per
fight_id, round_idx) and the dataset’s rows (event, outcomes): finish_final /
finish_l1 = P(ends this round), decision_l1 = P(goes the distance) (as
training.final_probs names them), ko_round / ko_later and y_ko.
run
run(fights_breaks: Mapping[str, Sequence[Decision]], ex: Execution, fights: pd.DataFrame, minutes: pd.DataFrame, finish_clock: FinishClock | None, method_clock: MethodClock | None, fills: Fills | None = None, ledger: list[dict[str, Any]] | None = None, card_cap: float | None = None, stop_loss: float | None = None) -> pd.DataFrameEvery fight (FIGHT_COLUMNS, one row each). With card_cap / stop_loss (dollars)
the fights of a card run in the order they started, each settled before the next: a fight’s
loss is bounded by the cap + the card’s P&L so far, and once that P&L is at or below
-stop_loss no fight buys.
run_fight
run_fight(brk: Sequence[Decision], ex: Execution, fills: Fills, fight: Any | None, minutes: pd.DataFrame | None, finish_clock: FinishClock | None, method_clock: MethodClock | None, cushion: float | None = None, ledger: list[dict[str, Any]] | None = None, loss_room: float | None = None, stopped: bool = False) -> dict[str, Any]One fight: its P&L and counters (FIGHT_COLUMNS), each trade into ledger.
loss_room: the card cap’s room for this fight (None: no card cap); stopped: the card’s
stop loss has hit (no buys, sales still).