Skip to content

betting_combat.rounds.backtest.joint

Strategy 4’s backtest under the JOINT execution (2026-10-13): each fight’s whole position rebalanced by joint Kelly (rounds.live.joint) at every round break the market’s bell marks and, in-round, at every minute end — the card run’s rules (trading.rounds), on the recorded books. Research: data/ufc/experiments/midround/jk_mid.py (reproduced to the cent on the research’s inputs).

breaks per round start k >= 1 with a decision-grid row (``working.decision_grid``):
decided at the market's bell or the feed (``working.bell_decision``); every
rounds / distance quote the grid's quote for that market and side (the book
known at the decision; ``Execution.bell_price`` 'stress': the dearest bell
book), the pair's asks likewise, its bids and a held distance position's bid
from the books (the other side's quote); the probabilities the break's
(``training.final_probs``); buys only of the break's candidate bets
(``models.candidates``) that pass the sizing rule's gate
in-round at each minute end m of round r+1 after the break: tau = m - (the market's bell
of round r + 60 s), from tau 60 s, never at or after the next round's bell nor
its break, while the winner books leave the fight open (fair 3-97c; the card
run's gate); the probabilities conditioned on no finish by tau
(``joint.clock_probs``); the minute's book; each order at most ``vol_share`` x
its market's dollars in the last ``vol_minutes`` minutes; buys of the break's
candidates only (``add``), sells of any holding (``cut`` below its cost,
``take_profit`` at or above)
final ``final_distance`` (the card run's final-round switch,
``joint.final_round_markets``): at the break before the fight's last round (its
scheduled rounds, the fights frame's ``rounds``) and in that round, the distance
market's YES too
fills conservative, from the recorded books of 2026-10-03 / 10-10 (live fills there
were all IOC takers; the recorded book reproduced them 98.3 %): an order fills
at most the 25th percentile of the contracts resting within 1c of the best
price on the side it takes, in that phase (``DEPTH_Q25``: a break = the window's
capacity, the book at the fire and its refills; in-round one slice at the
minute's end), at the quote + ``SLIP`` (live paid 0.3c over the quote on
average); a pair at its thinner leg, each leg + ``SLIP``
settle a rounds market of an earlier round settles NO at the next break (the fight
reached it); at the end the rounds market by its round's result, the distance
and the pair by the fight's (the pair pays on every decision: no draws here)

Classes

Break

One fight’s decision at the break after round round_idx.

JointExecution

The joint execution’s switches (domain.config.RoundsConfig: execution ‘joint’): sells at the breaks (V2) or buys only (V1); in-round decisions (mid), each side of them (mid_add buys more, mid_cut sells below cost, mid_take_profit sells at or above), their volume cap; mid_clock False keeps the break’s probabilities (research only: worse); final_distance the final-round switch (RoundsConfig.final_round_distance).

Functions

bar_draw_share

bar_draw_share(m: pd.DataFrame, t: pd.Timestamp, floor: float = DRAW_SHARE) -> float

The pair’s draw share at t as live reads it (live.decision.draw_share): Kalshi’s draw mid over the distance mid, both two-sided, from the minute bars known at t; never below floor (the historical 1.5 %) nor above live.decision.DRAW_SHARE_MAX.

breaks

breaks(events: pd.DataFrame, grid: pd.DataFrame, probs: pd.DataFrame, minutes: pd.DataFrame, ex: Execution, cushion: float = 0.01) -> dict[str, list[Break]]

Per fight with a candidate bet, its breaks in order (round_idx >= 1, quoted in the grid): the decision’s time, prices, probabilities, outcomes and candidates. probs: every round start’s probabilities (training.final_probs: finish_final, finish_l1, decision_l1, y_finish_round, y_decision).

fill_buy

fill_buy(x: JointExecution, inst: str, n: float, pr: Price, phase: str, cap: float | None = None) -> tuple[float, float, float, float]

(filled, all-in per contract, fee per contract, price) of a buy of n (cap: what a recorded book offered, instead of the table).

fill_sell

fill_sell(x: JointExecution, inst: str, n: float, pr: Price, phase: str, cap: float | None = None) -> tuple[float, float, float, float]

(sold, net per contract, fee per contract, price) of a sell of n.

run

run(fights_breaks: Mapping[str, Sequence[Break]], rule: JointRule, x: JointExecution, fights: pd.DataFrame, minutes: pd.DataFrame, clock: FinishClock | None, draw: float = DRAW_SHARE, gate: Literal['none', 'meta'] = 'none', cushion: float = 0.01, ledger: list[dict[str, Any]] | None = None, markets: Sequence[str] = ('rounds', 'distance', 'decision_pair'), card_cap: float | None = None, stop_loss: float | None = None, flags: list[dict[str, Any]] | None = None) -> pd.DataFrame

Every fight (FIGHT_COLUMNS, one row each; each break’s bets into flags, run_fight). With card_cap / stop_loss (the card run’s money controls, dollars) the fights of a card run in the order they started (their first break), each settled before the next starts: 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 (the refit’s backtests run without them: the system alone).

run_fight

run_fight(brk: Sequence[Break], rule: JointRule, x: JointExecution, fight: Any | None, minutes: pd.DataFrame | None, clock: FinishClock | None, draw: float = DRAW_SHARE, gate: Literal['none', 'meta'] = 'none', markets: Sequence[str] = ('rounds', 'distance', 'decision_pair'), cushion: float = 0.01, ledger: list[dict[str, Any]] | None = None, loss_room: float | None = None, stopped: bool = False, flags: list[dict[str, Any]] | None = None) -> dict[str, Any]

One fight under the joint execution: its P&L and counters (FIGHT_COLUMNS); each trade into ledger; each break’s bets (tradeable: what the break and its round may buy, filled or not, with the probability, the prices, the Kelly target and what was already held - the meta model’s rows, backtest.labeler) into flags. gate ‘meta’: a candidate is bought only when its meta probability is at least 0.5 (kelly_meta_filter); ‘none’: the primary alone. loss_room: the card cap’s room for this fight (its loss in every state stays within it, joint.loss_rows; None: no card cap); stopped: the card’s stop loss has hit (no buys, sells still).

tradeable

tradeable(buys: Sequence[str], markets: Iterable[str]) -> list[str]

What a break and its round may buy (rebalance’s buy variables before the min edge, which each decision applies at its own price): the break’s candidates on the strategy’s markets, and with a distance YES the pair. The bets a break opens - the meta model’s rows.