Examples#
from stakepd import kalshi_data as kd
client = kd.KalshiClient() # market data is public: no API key needed
Example:
trades = client.get_trades("KXHIGHNY-26NOV27-B57.5", max_results=4)
print(trades[["created_time", "yes_price", "no_price", "count", "taker_outcome_side"]])
Output:
created_time yes_price no_price count taker_outcome_side
0 2026-11-27 07:09:33.402301+00:00 0.71 0.29 5.00 yes
1 2026-11-27 07:08:36.563541+00:00 0.70 0.30 40.00 no
2 2026-11-27 07:07:19.752408+00:00 0.70 0.30 18.46 no
3 2026-11-27 07:06:14.298487+00:00 0.70 0.30 15.38 no
One day of trades, VWAP and volume:
# All trades in a market over one day
day = client.get_trades("KXHIGHNY-26NOV27-B57.5", start="2026-11-26", end="2026-11-27")
# Volume-weighted average price (VWAP)
vwap = (day.yes_price * day["count"]).sum() / day["count"].sum()
# Contracts traded per 15 minutes
day.set_index("created_time")["count"].resample("15min").sum()
Save for later:
trades = client.get_trades("KXHIGHNY-26NOV27-B57.5")
trades.to_parquet("trades.parquet") # keeps the dtypes, including UTC times
trades = pd.read_parquet("trades.parquet")
count is also the name of a DataFrame method, so write df["count"] rather than df.count.