betting_combat.rounds.market.trades
The raw trade layer under Sets 3 and 4: every Kalshi trade in the fight markets, on the dataset’s keys and the fight clock.
Ported from the research (ufc/dataset/trades.py: build).
trades_main the two winner markets (win_a, win_b)trades_side every side market (distance, method of victory, method of finish, rounds, victory round)Columns (both): fight_id, event_id, event_date, market (A-framed name), ticker, ts (UTC),
yes_price, count (contracts), dollars (count x yes_price), taker (‘yes’: the buyer lifted an
offer; ‘no’: the seller hit a bid), block, the clock at the trade: t_min, round, phase
(settled / pre / post_bell / round / break), and trade_id: the trade’s number within its
fight, over the fight’s tapes read in market-list order, each tape in its own order (a fight’s
numbers do not depend on which other fights are built). Sorted by (fight_id, ts, trade_id),
so trades in one millisecond keep the tape’s order whatever the sort; text columns are
categorical. :func:time_order puts any tape in (ts, trade_id) order.
Functions
time_order
time_order(tape: pd.DataFrame) -> pd.DataFrameThe tape in time order, trades at the same ts in trade_id order (unique in a fight:
no tie is left to the sort); a tape without trade_id keeps its own order among ties
(stable sort).
trade_tables
trade_tables(fights: pd.DataFrame, markets: pd.DataFrame, tapes: Mapping[str, list[list[Any]]]) -> tuple[pd.DataFrame, pd.DataFrame](trades_main, trades_side) from the markets’ trade tapes.
Args:
fights: :func:~.listing.live_fights rows.
markets: :func:~.listing.market_list rows.
tapes: ticker -> the tape’s trades ([ts_ms, yes_price, count, taker_yes, block],
the trades list of mm/<ticker>.json.gz); a ticker without a tape is absent.
with_pulled
with_pulled(markets: pd.DataFrame, tapes: Mapping[str, Any]) -> pd.DataFrameThe market list with pulled: whether the market’s tape exists (live_markets).