Examples#
from stakepd import kalshi_data as kd
client = kd.KalshiClient() # market data is public: no API key needed
Example:
candles = client.get_candlesticks("KXHIGHNY-26NOV27-B57.5", start="2026-11-26",
interval="1h", series_ticker="KXHIGHNY")
print(candles[["price_open", "price_high", "price_low", "price_close", "volume"]].dropna().tail(4))
Output:
price_open price_high price_low price_close volume
end_period_ts
2026-11-27 04:00:00+00:00 0.30 0.69 0.30 0.50 3198.40
2026-11-27 05:00:00+00:00 0.51 0.57 0.51 0.57 594.85
2026-11-27 06:00:00+00:00 0.57 0.77 0.57 0.74 3850.81
2026-11-27 07:00:00+00:00 0.74 0.76 0.70 0.72 2390.41
Plot, mid-price and local time:
# Plot the probability over time
candles["price_close"].ffill().plot(ylabel="P(YES)")
# Mid-price is defined even when nothing traded
candles["mid"] = (candles.yes_bid_close + candles.yes_ask_close) / 2
# Convert to New York time
candles.index = candles.index.tz_convert("America/New_York")
Downsample 1-minute candles to 5-minute candles:
m1 = client.get_candlesticks(ticker, start="2026-11-26", interval="1m", series_ticker="KXHIGHNY")
m5 = m1.resample("5min").agg({"price_open": "first", "price_high": "max",
"price_low": "min", "price_close": "last", "volume": "sum"})
Price history for every market in an event:
markets = client.get_markets(event_ticker="KXHIGHNY-26NOV27")
closes = pd.DataFrame({
row.yes_sub_title: client.get_candlesticks(row.ticker, start="2026-11-25", interval="1h",
series_ticker="KXHIGHNY")["price_close"]
for row in markets.itertuples()
}).ffill()
closes.plot(ylabel="P(YES)")