Skip to content

betting_combat.rounds.market.listing

Which Kalshi markets belong to which fight, named from fighter A’s side.

Ported from the research (ufc/dataset/markets.py: _fight_ids; ufc/dataset/live.py: swap_side, LiveSets.fights, LiveSets.market_list; ufc/joint.py: fight_markets, _code).

Fighter A is the dataset’s A (UFCStats slot a_slot), not Kalshi’s first ticker: a fight whose Kalshi fighter A is our fighter B has every fighter-level market name swapped (win_a <-> win_b, mov_a_* <-> mov_b_*, vic_a<k> <-> vic_b<k>).

Functions

by_fight_key

by_fight_key(markets: Iterable[Mapping[str, Any]]) -> dict[str, list[Mapping[str, Any]]]

A series’ markets grouped by fight key (the event ticker after the series prefix), each group in listing order.

code

code(ticker: str) -> str

A market ticker’s last part: KXUFCFIGHT-25AUG02BRERIB-BRE -> BRE.

fight_ids

fight_ids(fights: pd.DataFrame, bouts: pd.DataFrame) -> pd.DataFrame

Kalshi fights (:func:~.timing.build_fights) joined to their UFCStats fight_id, with ka_is_1: whether Kalshi’s fighter A is UFCStats slot 1 (name_1).

Args: fights: :func:~.timing.build_fights rows (ufc_event, ufc_bout). bouts: UFCStats bouts with fight_id, EVENT, BOUT, name_1, name_2 (stripped), in the research’s order (date, event, card position).

fight_markets

fight_markets(key: str, a_code: str, b_code: str, mov: Mapping[str, list[Mapping[str, Any]]], mof: Mapping[str, list[Mapping[str, Any]]], rounds_: Mapping[str, list[Mapping[str, Any]]], vic: Mapping[str, list[Mapping[str, Any]]], dist_ticker: str | None) -> list[tuple[str, str, Mapping[str, Any], dict[str, Any]]]

Every side market of one fight as (family, name, market, cell spec), names framed on Kalshi’s fighter A (a_code, the code of Kalshi’s first winner ticker).

Args: key: the fight key, e.g. 25AUG02BRERIB. a_code, b_code: the two winner tickers’ codes. mov, mof, rounds_, vic: :func:by_fight_key of the KXUFCMOV, KXUFCMOF, KXUFCROUNDS and KXUFCVICROUND markets. dist_ticker: the distance market’s ticker when Kalshi listed it, else None.

live_fights

live_fights(fights: pd.DataFrame, minutes: Mapping[str, list[dict[str, Any]]], clock: FightClock, keys: pd.DataFrame, a_slot: Mapping[str, int]) -> pd.DataFrame

The Kalshi-listed fights of the round dataset with their clock (research LiveSets.fights): fight_id, event_ticker, key, ticker_a, ticker_b, rounds, start, snap, timing, swap (Kalshi’s fighter A is our B), event_id, event_date, split. A fight Kalshi listed twice keeps its first listing.

Args: fights: :func:fight_ids rows. minutes: the winner markets’ 1-minute candles by ticker. clock: the fight clock. keys: the dataset’s rows (fight_id, event_id, event_date, split); only these fights are kept. a_slot: fight_id -> the UFCStats slot (1 or 2) of fighter A.

market_list

market_list(fights: pd.DataFrame, mov: Iterable[Mapping[str, Any]], mof: Iterable[Mapping[str, Any]], rounds_: Iterable[Mapping[str, Any]], vic: Iterable[Mapping[str, Any]], distance: Iterable[Mapping[str, Any]]) -> pd.DataFrame

Every market of every fight (research LiveSets.market_list): fight_id, name (A-framed), ticker; the first market of a (fight, name) is kept.

Args: fights: :func:live_fights rows. mov, mof, rounds_, vic: the KXUFCMOV, KXUFCMOF, KXUFCROUNDS, KXUFCVICROUND markets. distance: the KXUFCDISTANCE markets.

swap_side

swap_side(name: str) -> str

The A-framed name when Kalshi’s fighter A is our fighter B.