betting_combat.live.recorder
recorder.py — the card’s books and prints as the venues push them, on our market ids, into the market-data tables (books appended, trades upserted), and each print handed on (the clock reads the ‘ends before’ markets’ prints for the bells).
BookRecorder ``watch(markets)`` the markets to keep (a late-listed one joins: the session adds it to the stream too); ``kalshi`` / ``us`` / ``intl`` each take one venue's stream messages (``stream.messages()``, or the session's pass-through of them) until they end, flushing every ``flush_s``; the books as they stand (``kalshi_books``, ``us_books``: what the execution quotes from) and every print handed on whole (``on_trade``: the execution's paper fills and finish signs)Kalshi: book snapshots and deltas (with their sequence: a gap rebuilds the stream, which re-snapshots), trades. Polymarket US: every market-data frame is the whole book (a snapshot), and trades (the venue keeps no trade history we can read later, so these are the record). Intl: books and level changes (its trades come from the data API afterwards, with their ids).
Classes
BookRecorder
Bases: Feed
The card’s books and trades from the venues’ streams.
flush
flush() -> NoneWrite what was gathered; a write that fails (or is cancelled at shutdown) puts its rows back for the next flush: nothing received is dropped.
intl
intl(messages: AsyncIterator[Any]) -> Nonekalshi
kalshi(messages: AsyncIterator[Any]) -> NoneKalshi’s messages: a delta is a change, so the level’s new size comes from the books
kept (kalshi_books); a book out of step is skipped until its next snapshot.
kalshi_stale
kalshi_stale(ticker: str, now: Any, max_age_s: float = 20.0) -> boolA Kalshi book the execution must not trade on: out of step (a delta missed, its snapshot not yet in) or the socket
silent max_age_s (11-19 audit: a stalled socket kept serving its last book).
keys
keys(venue: Venue) -> list[str]The venue keys watched (tickers, slugs), sorted.
tokens
tokens() -> list[str]us
us(messages: AsyncIterator[Any]) -> Nonewatch
watch(markets: Iterable[Market]) -> list[Market]Keep these markets; the ones new to the recorder.