NBA Alpha Agent - Automated quantitative NBA sports betting and arbitrage simulation system
An automated quantitative NBA sports betting and arbitrage simulation system. The Alpha Agent scrapes real-time market odds from Polymarket and combines them with comprehensive NBA data (injuries, rest context, advanced analytics) to identify Positive Expected Value (+EV) betting opportunities, orchestrated by an LLM.
daily_setup_and_execution in main.py): Fetches today's NBA matches from Polymarket Gamma API.data_engine.py): For each match, retrieves market odds, injury reports, back-to-back rest situations, and advanced matchup statistics from Cleaning the Glass, CBS Sports, and Underdog Lineups.llm_analyzer.py): Sends compiled match context to Qwen/DashScope LLM acting as a cold-blooded sports analyst.
db_manager.pyBUY YESBUY NOdata/paper_ledger.dbsettlement_job in main.py, runs at 2 AM EST): Queries real NBA scores via nba_api (primary) and Polymarket resolution (secondary) to settle pending trades, updating portfolio balance accordingly.nba-alpha-agent/
├── main.py # Core orchestrator: daily_setup_and_execution(), settlement_job()
├── data_engine.py # Data aggregator (Polymarket odds, NBA Stats, Injuries, CTG)
├── llm_analyzer.py # LLM reasoning loop: risk assessment and odds analysis
├── db_manager.py # SQLite logic for paper trading ledger
├── scheduler.py # Autonomous cron daemon (10 AM setup, 2 AM settlement)
├── requirements.txt # Python dependencies
└── data/
└── paper_ledger.db # (Generated) SQLite trade history database
pip install -r requirements.txt
Set the following environment variables before running:
| Variable | Required | Description |
|---|---|---|
DASHSCOPE_API_KEY | ✅ Yes | DashScope / Qwen LLM API key |
CTG_SESSION_ID | ❌ No | Cleaning the Glass session cookie for advanced stats |
# Run today's full pipeline once
python main.py
# Run the autonomous scheduler (10 AM setup + 2 AM settlement, EST)
python scheduler.py