Quantitative research project analyzing pricing efficiency in Kalshi's NBA prediction markets. Tests whether market prices reflect true probabilities, identifies systematic biases, and simulates trading strategies that exploit miscalibration.
Over 1 million settled NBA markets analyzed, with full trade-level data for high-volume markets.
The core question: when Kalshi prices a market at $0.80, does YES resolve 80% of the time?
Points above the diagonal = YES is underpriced (buy YES for edge). Points below = YES is overpriced (buy NO for edge). Error bars are 95% Wilson confidence intervals.
Classic bias from sports betting markets: longshots (low-probability outcomes) are systematically overpriced, while heavy favorites are underpriced. This is the primary exploitable edge.
Breaks down the calibration error (in cents per contract) across the full probability range. The dotted lines show the ~2¢ fee hurdle — buckets outside that range have tradeable edge.
Whether edge is correlated with market liquidity. High-volume markets tend to be better calibrated; thin markets show larger deviations.
How calibration evolves as markets approach settlement. Edge is generally larger farther from close and narrows as prices incorporate new information.
Compares historical calibration against the most recent 30 days to check whether the edge is persistent or decaying.
Visualizes gross edge against the fee threshold. Only the portion above the dashed line translates to real profit after Kalshi's ~2¢/contract fee.
The strategy exploits the favorite-longshot bias:
- BUY NO on longshots priced 20–35¢ (they resolve YES less often than priced)
- BUY YES on heavy favorites priced 65–80¢ (they resolve YES more often than priced)
Strategy card summary:
Backtest accounts for:
- Kalshi fee: $0.02 per contract
- Bid-ask spread: ~$0.01 per contract
- Position sizing: flat $1 per trade
Tracks whether the strategy's edge has been stable, growing, or decaying over the dataset window.
| Chart | Description |
|---|---|
![]() |
All markets |
![]() |
High-volume markets only |
![]() |
Low-volume markets only |
pip install requests tqdm matplotlib numpy scipy pandasOptional: Kalshi API credentials for higher rate limits (get API keys).
export KALSHI_API_KEY_ID="your-key-id"
export KALSHI_PRIVATE_KEY_PATH="path/to/private_key.pem"# 1. Collect data (~10–30 min depending on rate limits)
python collect_data.py
# 2. Run core calibration analysis
python analyze_calibration.py
# 3. Generate all charts
python make_charts.py
python make_recent_charts.py
# 4. Backtest the strategy
python backtest.py
# 5. Scan all markets for current edges
python scan_all_markets.py
# 6. Run paper trader (live monitoring, no real money)
python paper_trader.py # run once
python paper_trader.py --loop # run every 30 minThe main database (kalshi_nba.db, ~11 GB, not included) has four tables:
| Table | Description |
|---|---|
markets |
Every settled NBA market: ticker, title, result, last price, volume |
events |
Parent events with category metadata |
candlesticks |
Hourly OHLCV price history per market |
trades |
Individual trade fills: price, size, timestamp, taker side |
- Diagonal = perfect calibration
- Above diagonal = YES underpriced → buy YES
- Below diagonal = YES overpriced → buy NO
- Error bars = 95% Wilson confidence intervals
- Edge = cents of expected profit per $1 contract, before fees
The fee hurdle on Kalshi is roughly 2¢ per contract (varies by market). Only price buckets where the measured edge exceeds 2¢ are actionable.
collect_data.py — Fetches all settled NBA markets + trade history from Kalshi API
explore_data.py — Quick sanity checks on collected data
analyze_calibration.py — Core calibration tests and edge estimation
backtest.py — Historical strategy backtest with fee modeling
make_charts.py — Comprehensive chart generation suite
make_recent_charts.py — Charts using recent trade-level snapshots
scan_all_markets.py — Fast scanner across all Kalshi market categories
paper_trader.py — Live paper trading bot (no real money)
analysis_output/ — Generated PNG charts


















