betting_combat.services.cards
When a card is due: the rule the card_ready sensor applies, kept pure.
A card is due once its first fight is within the lead window, and stays due
while any of its fights is still to come or under way. Cards are read from
Kalshi’s live-feed milestones (mma_match), grouped into cards by
card_dates: by the date code in their winner event tickers (‘kalshi’), or
by their scheduled starts (‘cito’; settings.card_source).
Classes
CardPlan
Functions
card_dates
card_dates(milestones: Iterable[Milestone], source: CardSource = 'kalshi') -> dict[str, dt.date]Each Kalshi winner event’s card date. ‘kalshi’: the date code in its ticker. ‘cito’:
the fights grouped by their scheduled starts (sorted, a new card wherever two starts are
more than CARD_GAP apart), each card dated by its first fight’s New York date, the
date Cito (UFC.com) and UFCStats give the card; a fight with no start keeps its ticker’s
code. Kalshi’s codes are not always the card’s date: UFC Fight Night Cortes-Acosta vs
Walker (2026-11-07) had thirteen fights coded 26NOV06 and one 26NOV07.
card_of
card_of(event: str, dates: Mapping[str, dt.date]) -> dt.dateevent’s card date in dates (card_dates), else its ticker’s code.
next_card
next_card(milestones: Iterable[Milestone], now: dt.datetime, lead: dt.timedelta, source: CardSource = 'kalshi') -> CardPlan | Nonerun_key
run_key(card_date: dt.date, failed_runs: int) -> strOne run per card; a failed run is relaunched once per failure, under a new key.