↓ Skip to main content
All methods

stakepd.kalshi_data.KalshiClient.get_orderbook

→ DataFrame
Signature
client.get_orderbook(ticker, depth=None)

Get the current order book for a market, in long format.

Kalshi lists bids only, for both YES and NO. A NO bid at price p is the same as a YES ask at 1 - p, so:

  • best YES ask = 1 - best NO bid
  • best NO ask = 1 - best YES bid

Parameters

ticker:str
Market ticker.
depth:int, optional
Return only the best N price levels on each side (1–100). None returns the whole book.

Returns

pandas.DataFrame
One row per price level, with each side sorted best price first.
Main columns
ColumnTypeDescription
sidestr"yes" or "no"
pricefloatBid price in dollars
quantityfloatContracts bid at that price

Raises

ValueError
If depth is outside 1–100.

See also

KalshiClient.get_market
Best bid and ask without the full book.
KalshiClient.get_trades
List public trades, newest first.

Notes
#

The order book is a snapshot at the moment of the request.

Examples
#

from stakepd import kalshi_data as kd

client = kd.KalshiClient()          # market data is public: no API key needed

Example:

book = client.get_orderbook("KXHIGHNY-26NOV27-B57.5", depth=3)
print(book)
Output:
  side  price  quantity
0  yes   0.70    345.44
1  yes   0.69      2.00
2  yes   0.68     83.81
3   no   0.29    109.00
4   no   0.28     46.80
5   no   0.27     41.00

The best YES bid is 0.70, and the best YES ask is 1 − 0.29 = 0.71.

Spread from the book:

yes = book[book.side == "yes"]
no = book[book.side == "no"]
best_bid, best_ask = yes.price.max(), 1 - no.price.max()
spread = best_ask - best_bid           # 0.01

This method is also covered, alongside the rest of the module, in the overview guide.