Skip to content

betting_combat.live.card

card.py — one card from its first fight to its last: the listings kept current, every fight’s clock from every source, the stat lines at each bell, the books and prints recorded, all on our ids and into the tables.

CardSession ``run()``: everything below, concurrently, until every fight is over (or
``until``); ``clock(bout_id)`` and ``breaks`` are what an execution reads,
``on_break`` is called at each round's bell with its lines (None: no stats).
The streams call its handlers (``on_cito``, ``on_kalshi_live``, ``on_sports``,
``on_print``) and ``tick``; a replay calls the same (``live.replay``)
main ``python -m betting_combat.live.card --day 2026-11-14 --host …``

The tasks:

listings the card-day poll every ``refresh_s`` (``CatalogFeed.refresh``) and at once when
Kalshi's lifecycle shows a UFC market created; new markets join the recorder and
the streams; the readiness check logged each time (its due gaps as warnings)
cito Cito's SSE stream of the card: each reading to its fight's clock and the
snapshots table (``kind stream``)
readings every fight on asked for its newest snapshots every 5 s, the new ones written as the archive
writes them (``live.readings``: snapshots, live_rounds, live_totals - the in-round rows' counts)
kalshi Kalshi's WebSocket (books, trades, UFC lifecycle) through the recorder; the
'ends before' prints to the clocks (the market bells); ``live_data`` polled every
``kalshi_poll_s`` for the fights on now (the round counter, the close)
us, intl Polymarket US's markets socket (with Sam's key) and the intl market socket
through the recorder; the intl sports socket (period, end) to the clocks
tick every ``tick_s``: the clocks' bells may fire; each round's first end (any
teller) asks Cito for the lines at the bell (``BellStats``), once

A fight’s clock account (source clock) is written when it ends. Nothing here trades: the execution (execution.card.CardTrading) sets on_break, on_tick and the recorder’s on_trade, and reads clock, markets and the recorder’s books.

Classes

CardSession

One card’s live run (see the module doc).

clock

clock(bout_id: str) -> FightClock | None

load

load() -> list[Market]

Refresh the card, take its fights and markets; the markets new to the recorder.

markets

markets(bout_id: str) -> list[Market]

The bout’s markets the card follows (the execution’s instruments).

on_cito

on_cito(st: LiveState, seen_at: dt.datetime) -> None

on_kalshi_live

on_kalshi_live(ld: LiveData, seen_at: dt.datetime) -> None

on_print

on_print(m: Market, trade_id: str, ts: dt.datetime, price: float) -> None

on_sports

on_sports(msg: SportsState, seen_at: dt.datetime) -> None

resume

resume() -> None

A relaunched run picks the card up where the tables have it: every Cito reading held for the card’s fights goes back through their clocks (rounds, bells, finishes as told then), a break already over is not asked again, a fight already accounted is not written again. A first run finds nothing.

run

run() -> dict[str, Any]

tick

tick(now: dt.datetime) -> None

The time passing: the clocks’ bells may fire; a fight over writes its clock account.

Functions

main

main() -> None