betting_combat.rounds.live.windows
Set 3 at a live decision: the market-window features of one (fight, round start) at the decision time t, from the Kalshi trades before t and the books at t.
The training rows (rounds.market.windows: set3_main / set3_side) are computed for
a whole card at once; this computes one row with the same arithmetic (the research’s own
window_stats and implied), from what is known at t:
trades the fight's Kalshi trades so far, A-framed market names (``win_a``, ``win_b``, ``mov_a_ko`` .., ``distance``): ``market, ts, yes_price, count, dollars, taker`` (``block`` optional). Only trades BEFORE t may be passed (checked).books the books at t by market name (``Book``: bid, ask, open interest; NaN unknown), the minute panel's ``<market>_bid/_ask/_oi`` in trainingstart the fight's start (live: the feed's first live reading); the windows' edges are E = [start-60, start-30, start, start+6, ...] as in trainingDifferences from the training rows, all deliberate:
- no window reaches past t (
market.windows.window_bounds(causal=True)): the research’s round-0 row (t = the minute before the start) carries the last price before the START intosofar_vwap_a(itsprewindow, which also read past t, was fixed 2026-09-30).research_pre=Truereproduces the research (the parity replay only; it needs the trades up to the start, so it cannot run live). - trades with the same timestamp are ordered by their
trade_id, or kept in the order given when the tape has no ids (market.trades.time_order, the port’s rule since 2026-09-30): the frozen research sorted each fight’s whole tape with an unstable sort, so the order of trades sharing a millisecond — and so a window’s last price — depended on the fight’s later trades. The windows’ sums do not depend on the order; their last prices can. - dataset-wide fills: a missing main spread takes the training rows’ median
(
Fills.main_spread), side spreads theirs (Fills.side_spread); a missing open interest takes the fight’s previous row’s (training also took the NEXT row’s, a look-ahead), else 0. - the side rows’ complete-core rule (
drop_unpriceable) dropped a fight whose side markets could not be priced at ANY of its rows; live, a row that cannot be priced has no side features (layer 1 prices it), and the caller keeps the fight out afterwards.
Classes
Book
One market’s book at t (YES prices, dollars; NaN where unknown) and its open
interest, as the minute panel’s <market>_bid, _ask, _oi carry them.
Fills
The training rows’ dataset-wide fills (set3_main / set3_side): the median main
spread and each side market’s median spread, used when a book is missing at t.
from_training
from_training(set3_main: pd.DataFrame, set3_side: pd.DataFrame) -> FillsFunctions
edges_of
edges_of(start: pd.Timestamp, rounds: int) -> list[pd.Timestamp]The window edges E (market.windows.row_times).
main_row
main_row(trades: pd.DataFrame, books: Mapping[str, Book], r: int, t: pd.Timestamp, start: pd.Timestamp, rounds: int, pre_mid: float, fills: Fills, prev_oi: float | None = None, research_pre: bool = False) -> dict[str, Any]The Set 3 main row (set3_main’s columns after its keys) for round_idx r at t.
pre_mid: mid_a at the round-0 row’s time (mid_a_at; for r = 0 it is this
row’s own mid and is ignored). prev_oi: the fight’s previous row’s oi.
research_pre: the research’s round-0 sofar window (it carried the price before
the start), for the parity replay only; it needs the trades up to the start, taken in the
order given (market.trades.time_order, as the research reads them).
mid_a_at
mid_a_at(trades: pd.DataFrame, books: Mapping[str, Book], t: pd.Timestamp, given_order: bool = False) -> floatA’s winner mid at t (the main row’s mid_a): the mean of A’s mid and 1 - B’s mid
from the books at t; else A’s last traded price before t; else 0.5. trades: before t
(at the round-0 row’s time it is the pre_mid of the later rows).
side_row
side_row(trades: pd.DataFrame, books: Mapping[str, Book], r: int, t: pd.Timestamp, start: pd.Timestamp, rounds: int, mid_a: float, fills: Fills, given_order: bool = False) -> dict[str, Any] | NoneThe Set 3 side row (set3_side’s columns after its keys) for round_idx r at t, or
None when a side market cannot be priced (no book and no trade before t: the row has no
side features). mid_a: this row’s main mid_a. The side windows (last, prev) all
end by t, so the rule is the same live and in research. given_order: the trades’
order is kept (the parity replay’s research order).