Skip to content

betting_combat.domain.market

Order-book tops, trade prints and the market’s implied probabilities.

Classes

BookTop

The best YES bid and ask of one Kalshi market, and the size behind each.

ask is what buying YES costs now (1 minus the best NO bid); ask_size is how many contracts are offered at it. as_of is when this top was last confirmed (a WebSocket update or a REST snapshot).

age_seconds

age_seconds(now: dt.datetime) -> float

from_bids

from_bids(ticker: str, yes_bid: tuple[float, float] | None, no_bid: tuple[float, float] | None, as_of: dt.datetime) -> BookTop

Kalshi books hold bids only. The YES ask is 1 minus the best NO bid, offered in that NO bid’s size; (price, size) or None per side.

Print

One trade on a Kalshi market: yes_price is the YES side’s price; the taker bought taker_side (‘yes’ lifted an offer, ‘no’ hit a YES bid); either is None when the venue did not say (such a print counts as volume, never as a fill).

Functions

fair_prob_a

fair_prob_a(book_a: BookTop, book_b: BookTop) -> float | None

P(fighter A wins) implied by the two winner books: the average of A’s mid and one minus B’s mid. Both books must be two-sided.