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