Skip to content

betting_combat.providers.kalshi.models

models.py — Kalshi’s payloads as typed vendor rows. Kalshi serves two number formats: current endpoints send fixed-point strings (volume_fp, yes_price_dollars), the archive the old names (volume, yes_price; integer cents on the oldest rows). Every row reads both and holds floats: prices in dollars (0-1), sizes in contracts, times aware UTC.

Event one event (one fight in one series): its card label (``competition``)
Market one market: status, result, custom strike, top of book, volume, times
Milestone one fight on Kalshi's calendar: start, fighters, its six events, feed link
Target a structured target (a fighter: ``ufc_competitor``): name, provider ids
Candle one candle (END of the period): YES bid/ask closes, price close/mean, volume
Book a REST book: each side's bids, best LAST (Kalshi sorts ascending)
Trade one public trade
LiveData one fight in ``/live_data``: status, current round, the end
OrderAck the answer to a submitted order
Order · Fill · Position · Settlement our account
OrderGroup a group's rolling 15 s contracts limit (the kill switch)
QueuePosition how many contracts rest ahead of one of our orders
Series · ExchangeStatus the series, and whether the exchange trades now
Rfq · Quote a request for quote and a maker's quote on it
ApiKeys our keys and the location attestation's expiry

Classes

ApiKeys

Bases: _Row

Our API keys and when the location attestation runs out: past it, sports trading by API is refused (403 ‘location attestation missing or expired’) until Sam logs in again.

Book

Bases: _Row

A REST book: each side’s resting bids (price, contracts), best LAST. YES ask = 1 - the best NO bid.

Candle

Bases: _Row

One candle; end is the END of the period. Only minutes with activity are served.

Event

Bases: _Row

ExchangeStatus

Bases: _Row

Fill

Bases: _Row

LiveData

Bases: _Row

One fight in Kalshi’s live feed (REST only). No in-round clock: current_round steps around each round’s start (tens of seconds late); the end fills the rest.

Market

Bases: _Row

Milestone

Bases: _Row

One fight on Kalshi’s calendar. start_date is Kalshi’s scheduled start (never date a fight from a ticker); primary_event_tickers its six events; source_ids the live feed’s link (empty: no round progression).

Order

Bases: _Row

OrderAck

Bases: _Row

OrderGroup

Bases: _Row

A group of orders under one rolling 15 s contracts limit: hit it and the group’s orders are cancelled (a per-fight or per-strategy kill switch).

Position

Bases: _Row

QueuePosition

Bases: _Row

Quote

Bases: _Row

Rfq

Bases: _Row

Series

Bases: _Row

Settlement

Bases: _Row

Target

Bases: _Row

A structured target: a fighter (type ufc_competitor), or an outcome like ‘Draw/No Contest’ (empty source_ids). source_ids: source_3 Sportradar, source_2 OpticOdds.

Trade

Bases: _Row

Functions

num

num(value: Any) -> float | None

A Kalshi number (‘0.6500’, 37.54, ”) as a float; blank → None.