A 24/7 NBA betting analysis bot written in Go that identifies +EV opportunities on Kalshi by comparing prediction market prices against sportsbook consensus.
- Polls odds from 14+ sportsbooks via balldontlie.io (600 req/min)
- Calculates consensus probabilities with vig removal and log-linear pooling
- Filters for freshness — only uses odds updated within 30 seconds
- Compares against Kalshi prices to find +EV opportunities
- Rejects longshots — skips bets where true probability < 15% or > 85%
- Sizes bets using Kelly criterion (quarter-Kelly default)
- Optionally executes trades via Kalshi API with RSA authentication
- Log-linear opinion pool consensus with winsorized outlier capping and Power method vig removal
- Spread/total line normalization using Student's t-distribution with context-dependent SD
- Fee-adjusted EV calculation (accounts for Kalshi's dynamic fee:
0.07 * price * (1-price), capped at $0.0175) - Longshot filter: skips bets where true probability < 15% or > 85%
- Staleness filtering: rejects vendor odds older than 30 seconds (game and prop markets)
- Order book depth and slippage analysis
- Arbitrage detection on existing positions
- SQLite position tracking with hedge alerts
- Deduped console alerts (5-min cooldown)
# Clone
git clone https://github.com/mchen04/sports-betting-bot.git
cd sports-betting-bot
# Configure
cp .env.example .env
# Edit .env with your API keys
# Run
go run ./cmd/bot| Variable | Default | Description |
|---|---|---|
BALLDONTLIE_API_KEY |
required | Ball Don't Lie API key |
KALSHI_API_KEY_ID |
optional | Kalshi API key ID |
KALSHI_API_KEY_PATH |
optional | Path to RSA private key (local dev) |
KALSHI_PRIVATE_KEY |
optional | RSA private key content (cloud deployment) |
EV_THRESHOLD |
0.03 | Min EV to alert (3%) |
KELLY_FRACTION |
0.25 | Fraction of full Kelly |
MAX_ODDS_AGE_SEC |
30 | Max age of vendor odds in seconds |
AUTO_EXECUTE |
false | Auto-execute trades |
MAX_BET_DOLLARS |
0 | Max bet size (0 = no cap) |
KALSHI_DEMO |
false | Use demo API |
See docs/architecture.md for full configuration options.
- Architecture - System design and configuration
- Math - EV calculation, Kelly criterion, vig removal
- Player Props - Props analysis and line interpolation
├── cmd/bot/ # Entry point
├── internal/
│ ├── api/ # balldontlie.io client
│ ├── kalshi/ # Kalshi API, orderbook, orders
│ ├── odds/ # Consensus, conversion, vig removal
│ ├── analysis/ # EV detection, Kelly sizing, longshot filter
│ ├── mathutil/ # Logit/sigmoid, t-distribution, beta functions
│ ├── config/ # Configuration loading & validation
│ ├── engine/ # Polling loop, trade execution, ticker mapping
│ ├── positions/ # SQLite tracking, hedge detection
│ └── alerts/ # Notification system
├── Dockerfile # Multi-stage build
└── fly.toml # Fly.io deployment
Deploy to Fly.io:
fly launch
fly secrets set BALLDONTLIE_API_KEY=xxx KALSHI_API_KEY_ID=xxx
fly deploy- balldontlie.io - GOAT tier ($39.99/mo) for 14+ sportsbook odds
- Kalshi - Prediction market prices and execution
MIT