Skip to content

betting_combat.consumers.kalshi.schemas

Typed views of the Kalshi responses this container reads.

Kalshi serves two number formats: current endpoints send fixed-point strings (volume_fp, close_dollars) and archived (historical) endpoints send the older names (volume, close). Every model accepts both and normalises to floats in dollars / contracts. Fixtures recorded from production pin each shape (tests/fixtures/kalshi).

Classes

Candle

Bases: _Model

One candlestick. ts is the END of the period.

from_api

from_api(raw: dict[str, Any]) -> Candle

CentsPriceError

Bases: ValueError

A candle price that can only be integer cents: read as dollars it would be 100x too high. Refused loudly, never rescaled by guess.

Fill

Bases: _Model

One execution of one of our orders (GET /portfolio/fills).

KalshiOrder

Bases: _Model

One of our orders as the exchange reports it (GET /portfolio/orders).

LiveDetails

Bases: _Model

One fight in Kalshi’s live feed. The round clock is only filled once a fight ends.

Market

Bases: _Model

Milestone

Bases: _Model

MilestoneDetails

Bases: _Model

MinuteCandle

Bases: _Model

One candle as the round system reads it (research candle_frame and minute_frame): the YES bid and ask closes and the mean traded price, in dollars, the volume and the open interest. ts is the END of the period.

Each price is read the research’s way: <field>_dollars when the candle has that key (newer candles), else <field> (archived candles, dollar strings too). The volume is volume_fp or volume or 0; the open interest open_interest_fp when present, else open_interest.

from_api

from_api(raw: dict[str, Any]) -> MinuteCandle

to_api

to_api() -> dict[str, Any]

The candle in Kalshi’s current shape, as the round library reads candles.

OrderAck

Bases: _Model

The exchange’s answer to a submitted order.

OrderBook

Bases: _Model

from_api

from_api(raw: dict[str, Any]) -> OrderBook

top

top(ticker: str, as_of: dt.datetime) -> BookTop

OrderBookSide

Bases: _Model

Resting orders on one side, best price LAST (Kalshi sorts ascending).

Trade

Bases: _Model