Skip to content

betting_combat.services.markets

Today’s card straight from Kalshi: its fights, their markets and milestones.

Used by the card run (trading.session) and strategy 4’s upcoming-card loader (services.rounds_upcoming) — trading never waits on a batch job.

Classes

CardMarkets

Functions

card_markets

card_markets(kalshi: KalshiRest, card_date: dt.date, source: CardSource = 'kalshi') -> CardMarkets

discover_card’s reads, also returning every market ticker it saw.

derive_fights

derive_fights(winner_markets: Iterable[Market], distance_markets: Iterable[Market], side_markets: Iterable[Market] = (), milestones: Iterable[Milestone] = (), competitions: dict[str, str | None] | None = None, known: dict[str, Fight] | None = None, dates: Mapping[str, dt.date] | None = None) -> tuple[list[Fight], Counter[str]]

One Fight per winner event with exactly two markets, dated by dates (cards.card_dates; an event not in it by its ticker’s code).

Values Kalshi does not supply this time (a milestone gone from the feed, an event label not re-read) keep what known already had; nothing known is ever overwritten with nothing.

discover_card

discover_card(kalshi: KalshiRest, card_date: dt.date, source: CardSource = 'kalshi') -> tuple[list[Fight], Counter[str]]

Today’s card straight from Kalshi: the fights on the card (cards.card_dates: the winner events carrying the card’s date code, or, ‘cito’, the fights whose starts run together from the card’s date), their distance and decision side markets, milestones and card label.

fight_status

fight_status(a: Market, b: Market) -> tuple[str, str | None]

(status, winner) from the two winner markets’ official results.

linked_events

linked_events(milestones: Iterable[Milestone], problems: Counter[str]) -> dict[str, dict[str, str]]

winner event -> {series: the fight’s event on that series}, for the distance and side series, from Kalshi’s milestone links. A side event’s code need not be the winner event’s (KXUFCFIGHT-26OCT03SILCON / KXUFCROUNDS-26OCT03SILWAN), so these links, not the code, say which event is the fight’s; a series a fight links to more than one event of is left out (the code then decides).

side_roles

side_roles(a: Market, b: Market, side_markets: Iterable[Market], problems: Counter[str], feed_ids: tuple[str | None, str | None] = (None, None)) -> tuple[tuple[Role, str], ...]

The fight’s side markets, as (role, ticker): each fighter’s method-of-victory markets (matched to A/B by Kalshi’s competitor id, else by name) and the draw one, the method-of-finish markets, the victory-round markets (each fighter’s rounds by name, and decision / draw / no contest) and “ends before round k”. The two “by decision” markets are only kept together (the decision pair buys them together).

feed_ids are the milestone’s two fighter ids, which the side series carry: a winner market’s competitor id can differ from them (Wang Cong, 2026-10-03), so when one feed id is a winner market’s, the other is the other fighter’s. A name matches in either order (“Cong Wang by Decision” is “Wang Cong”).