Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sports Betting Bot

A 24/7 NBA betting analysis bot written in Go that identifies +EV opportunities on Kalshi by comparing prediction market prices against sportsbook consensus.

How It Works

  1. Polls odds from 14+ sportsbooks via balldontlie.io (600 req/min)
  2. Calculates consensus probabilities with vig removal and log-linear pooling
  3. Filters for freshness — only uses odds updated within 30 seconds
  4. Compares against Kalshi prices to find +EV opportunities
  5. Rejects longshots — skips bets where true probability < 15% or > 85%
  6. Sizes bets using Kelly criterion (quarter-Kelly default)
  7. Optionally executes trades via Kalshi API with RSA authentication

Features

  • 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)

Quick Start

# 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

Configuration

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.

Documentation

  • Architecture - System design and configuration
  • Math - EV calculation, Kelly criterion, vig removal
  • Player Props - Props analysis and line interpolation

Project Structure

├── 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

Deployment

Deploy to Fly.io:

fly launch
fly secrets set BALLDONTLIE_API_KEY=xxx KALSHI_API_KEY_ID=xxx
fly deploy

Data Sources

  • balldontlie.io - GOAT tier ($39.99/mo) for 14+ sportsbook odds
  • Kalshi - Prediction market prices and execution

License

MIT

About

Go bot that finds +EV NBA betting opportunities on Kalshi by aggregating sportsbook consensus odds and applying Kelly Criterion sizing.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages