betting_combat.live.clock
clock.py — one fight’s clock from every source that tells it: when each round started and ended and how the fight ended, each moment with its teller and when we learned it.
MarketBell the bell ending round k from a venue's 'ends before round k+1' market, print by print: the backtests' rule exactly (``rounds.market.bell.market_bell``: from the gate, a group at 1c or below with nothing above 3c, held 5 s)Phase before | round | break | decision (the last bell rang) | endedClockState the clock at one moment: round, phase, seconds into the round, the bellFightClock one fight. Each source's method takes its reading and returns the moments it brought (``FightEvent`` rows, ``source`` the teller); the clock's own account (the best teller of each moment) is ``start(k)``, ``bell(k)``, ``finished_at``, ``state(now)``, and ``account()`` as moments (``source clock``) once it endsWho is believed, per moment:
round k start Cito: its capture time less its round clock, the median of the round's first five readings (Cito's capture times jitter ~±4 s; a pause only moves later readings), else round k-1's bell + 60 s, else Kalshi's round counter stepping, less its lag (``FEED_LAG``)round k end Cito's clock run out (the round's start as its latest five readings have it, the pauses included, + 5:00), else a venue's market bell (Kalshi's, then Polymarket US's), else round k+1's start - 60 s. The market bell is kept apart (``market_bell``): it is what the backtests decide a break on, and it can lag the bell by a minute (11-07 Lorenco v Petroski R1: Cito ran out at 00:19:09, the market collapsed at 00:20:23, round 2 began at 00:20:30)the finish Cito's 'completed' or Kalshi's close: the first seen (Polymarket's end is told as a moment, never ends the clock)The gate of a market bell sits where the backtests put it: the round’s true start + FEED_LAG
GATE(the backtests place the live gate from the tape’s bell - 5:00 +FEED_LAG), so an exact start from Cito never fires a bell earlier than the backtests would. Nothing here does I/O: the card’s session feeds it (live.card) and writes what it returns.
Classes
ClockState
FightClock
One fight’s clock (see the module doc).
account
account(seen_at: dt.datetime) -> list[FightEvent]The clock’s own moments as they stand (source clock, detail the teller):
written once the fight is over, when no later reading can improve them.
bell
bell(k: int) -> dt.datetime | NoneRound k’s end, by the best teller (a finish inside the round is finished_at).
cito
cito(r: LiveState | Snapshot, seen_at: dt.datetime) -> list[FightEvent]A Cito reading (stream, state or snapshot).
expected_start
expected_start(k: int) -> dt.datetime | NoneRound k’s start as the execution times its windows by (the backtest’s start is Cito’s told start): Cito’s
once round k is on; before that round k-1’s bell + EXPECTED_BREAK (the break as this clock sees it on the
recorded cards: median 73 s, half within 2.4 s - not the rulebook’s 60); else start.
kalshi
kalshi(ld: LiveData, seen_at: dt.datetime) -> list[FightEvent]Kalshi’s live data (REST, polled): the round counter, the close.
last_round
last_round(k: int) -> boolRound k is the fight’s last scheduled one (its bell: the judges, no break).
market_bell
market_bell(k: int) -> MarketBell | NoneThe venue market bell that decides round k’s end: Kalshi’s when it fired, else
Polymarket US’s.
polymarket
polymarket(period: str | None, live: bool | None, ended: bool | None, seen_at: dt.datetime) -> list[FightEvent]Polymarket’s state of the fight (US eventState or the intl sports socket):
period a round (‘R2’, ‘2’) or ‘FT’.
prints
prints(venue: Venue, round_k: int, prints: Iterable[Print], now: dt.datetime) -> list[FightEvent]Prints of venue’s ‘ends before round round_k + 1’ market: round round_k’s bell.
start
start(k: int) -> dt.datetime | NoneRound k’s start, by the best teller (module doc).
state
state(now: dt.datetime) -> ClockStatetick
tick(now: dt.datetime) -> list[FightEvent]The time passing with no new print: a market bell’s hold may complete (the session calls this every second or so).
MarketBell
The bell ending round from one venue’s ‘ends before round+1’ market.
update
update(prints: Iterable[Print], now: dt.datetime, start: dt.datetime | None) -> boolRead prints (any order, repeats ignored) up to now, the round started at
start (None: unknown, no fire); True when the bell fires on this call.
Phase
Bases: StrEnum