Skip to content

michaelschecht/Edge-Radar

Repository files navigation

Edge-Radar

Automated Edge Detection & Execution for Prediction Markets

Kalshi Live Trading Python 3.11+ Normal CDF Markets Edge Detection Risk Gates Docs APIs Dashboard Data Flow

Edge-Radar Banner

▶ View the interactive data-flow diagram

Scans thousands of Kalshi markets, cross-references 12 sportsbooks + free APIs (including MLB pitcher stats and ESPN rest data), identifies mispriced contracts with a normal CDF probability model, sizes bets with Kelly criterion (soft-capped above 15% edge per calibration), enforces 13 risk gates including per-sport edge floors, a $0.10 lottery-ticket price floor, NO-side favorite guard, a prediction-market safety gate, and per-sport series dedup (MLB/NHL 72h, others 48h), and executes limit orders — logging every decision with fill-accurate accounting for closing line value tracking.



Supported Markets

🏟️ Sports Betting

🏈 NFL · 🏀 NBA · ⚾ MLB · 🏒 NHL 🎓 NCAAB · NCAAF · 🥊 UFC · Boxing ⚽ Soccer · MLS · 🏎️ F1 · NASCAR ⛳ PGA · 🏏 IPL · 🎮 Esports

27 filters · 18 sports with Odds API edge detection

🏆 Championship Futures

🏈 Super Bowl 🏀 NBA Finals 🏒 Stanley Cup ⚾ World Series ⛳ PGA Tour

N-way de-vig · cross-referenced against sportsbook outrights

📈 Prediction Markets

₿ Crypto (BTC, ETH, XRP, SOL, DOGE) 📊 S&P 500 + VIX 🌡️ Weather (13 cities) 🗳️ Politics

4 categories · CoinGecko, Yahoo Finance, NWS


Edge Detection Pipeline

🔗 View the interactive version →

graph LR
    A["12 Sportsbooks<br><sub>The Odds API</sub>"] --> D["Normal CDF<br>Fair Value"]
    B["Team Stats<br><sub>ESPN / NHL / MLB</sub>"] --> D
    C["Signals<br><sub>Weather, Pitchers, Rest, Sharp $</sub>"] --> D
    D -->|"compare"| E["Kalshi Price"]
    E -->|"Edge >= 3%"| F["Composite Score<br><sub>0-10 scale</sub>"]
    F --> G["13 Risk Gates"]
    G --> H["Kelly Sizing"]
    H --> I["Limit Order + Log"]

    style D fill:#8B5CF6,color:#fff,stroke:none
    style G fill:#e74c3c,color:#fff,stroke:none
    style I fill:#2ea44f,color:#fff,stroke:none
Loading
Signal Source
Normal CDF Model Sport-specific stdev bell curve probabilities
Sharp Book Weighting Pinnacle 3x, Circa 3x, DraftKings 0.7x
Team Stats ESPN/NHL/MLB win% validates fair value
Sharp Money Open-vs-close odds detect reverse line movement
Weather NWS forecasts for 61 NFL/MLB outdoor venues
Pitcher Matchups ERA, FIP, WHIP, K/9, rest days from MLB Stats API
Rest Days NBA/NHL back-to-back fatigue detection
Book Disagreement >4pt spread range flags injury news

Important

Every scan defaults to preview mode. No money is risked until you pass --execute. Each scan row shows a Gate column (R18) that previews whether it will pass the static risk gates — ok if all clear, or a short label (score, conf, no-fav, pred-off, etc.) for the failing gate.


Risk & Position Sizing

13 Risk Gates

Every order must clear gates 1-7 (including 3.5, 4.5, 4.6, 4.7). Gates 8-9 cap sizing instead of rejecting.

# Gate Action
1 Daily loss limit Reject at -$250
2 Position count Reject at 50 open
3 Edge threshold Reject below floor (3% global; 12% NBA; 10% NCAAB)
3.5 Market price floor Reject bets priced below MIN_MARKET_PRICE (default $0.10 — lottery-ticket filter)
4 Composite score Reject below 6.0/10
4.5 Min confidence Reject below MIN_CONFIDENCE (default medium)
4.6 NO-side favorite Reject NO bets <25¢ unless edge ≥25% AND confidence=high
4.7 Prediction-market safety Reject crypto/weather/spx/mentions/companies/politics unless ALLOW_PREDICTION_BETS=true (R25)
5 Duplicate check Reject same market
6 Per-event cap Reject at 2/game
7 Series dedup Reject same matchup bet within window (MLB/NHL 72h, others 48h; per-sport via SERIES_DEDUP_HOURS_<SPORT>)
8 Bet size cap Cap at $100
9 Bet ratio cap Cap at 3x batch median

All limits configurable via .env. Gate 3.5 (MIN_MARKET_PRICE, R7) added 2026-04-22 — F10 from the 14-day review showed sub-10¢ bets at 1W-3L with the model claiming "+50% edge" on 8-10¢ longshots. Gate 4.5 (MIN_CONFIDENCE) and Gate 4.6 (NO_SIDE_*) added 2026-04-21 after low-confidence bets at -105% ROI and all 13 high-edge losers being NO-side on heavy favorites. NO bets below NO_SIDE_KELLY_PRICE_FLOOR (default 35¢) are additionally sized at half-Kelly. NBA floor bumped 0.08 → 0.12 in R14 (2026-04-24) after the 30-day calibration showed NBA Brier 0.3306 (worst of all sports). Confidence bumps now one-way (R13, 2026-04-24) — team stats, rest/B2B, and sharp-money signals can drop a tier but no longer bump up; upward bumps correlated with inflated claimed edge rather than better outcomes. Gate 4.7 (ALLOW_PREDICTION_BETS, R25) added 2026-04-24 after a prediction-market audit found all 6 modules (crypto/weather/spx/mentions/companies/politics) cache stale data with no TTL and produce nonsense fair values; the gate blocks those categories by default until the models are rebuilt. R8 (2026-04-29) adds an optional cross-category dedup that runs before the gates: when CROSS_CATEGORY_DEDUP_<SPORT>=true, ML+Total+Spread on the same game collapse to the highest-composite row instead of being treated as 3 independent bets — addresses F11 (12 matchups bet ≥2× in 14d, several same-day cross-category). Default off because cross-category correlation varies by sport. See Architecture

Batch-Aware Kelly Sizing

Bet size scales with edge, divided by batch count to control total exposure. Edge is soft-capped above 15% before sizing (trusted_edge()) to damp Kelly on likely-overstated signals — raw edge remains in gates and reports.

bet = max(unit, (kelly_frac / batch) * trusted_edge(edge) * bankroll)
Edge Trusted 1 bet 5 bets 10 bets
3% 3% $0.75 $0.15 $0.08
10% 10% $2.50 $0.50 $0.25
15% 15% $3.75 $0.75 $0.38
25% 20% $5.00 $1.00 $0.50
35% 25% $6.25 $1.25 $0.63

Example: $50 bankroll, KELLY_FRACTION=0.50. Capped by max bet ($100) and balance. Soft-cap: KELLY_EDGE_CAP=0.15, KELLY_EDGE_DECAY=0.5.


Quick Start

# 0. Clone repo and enter project
git clone https://github.com/michaelschecht/Edge-Radar.git
cd Edge-Radar

# 1. Create + activate virtual environment
python -m venv .venv
# macOS/Linux (bash/zsh):
source .venv/bin/activate
# Windows PowerShell:
# .venv\Scripts\Activate.ps1

# 2. Install dependencies and create env file
python -m pip install --upgrade pip
pip install -r requirements.txt
cp .env.example .env

# 3. Verify environment (API keys, dependencies)
python scripts/doctor.py

# 4. Preview opportunities (no money risked)
python scripts/scan.py sports --filter nba

# 5. Execute with risk controls
python scripts/scan.py sports --filter nba --execute --unit-size 1 --max-bets 5

# 6. Settle bets and view P&L
python scripts/kalshi/kalshi_settler.py report --detail --save

Tip

All scanners share the same flags: --execute, --unit-size, --max-bets, --pick, --ticker, --save, --date, --exclude-open. Use --date tomorrow --exclude-open to avoid double-betting.

Next Steps

Guide What it covers
Setup Guide First-time install, API keys + RSA private key generation, .env wiring, safe rollout plan (dry-run → low-stakes → normal), automation, ongoing monitoring, troubleshooting
Local Dashboard Run the Streamlit dashboard on your own machine at http://localhost:8501
Cloud Dashboard Deploy your own instance to Streamlit Community Cloud (free tier)

Command Recipes

Expand any section for copy-paste CLI examples by workflow.

Sports Betting
python scripts/scan.py sports --filter nhl
python scripts/scan.py sports --filter mlb --execute --unit-size 1 --max-bets 10
python scripts/scan.py sports --filter mlb --date tomorrow --exclude-open
python scripts/scan.py sports --filter nba --save
Championship Futures
python scripts/scan.py futures --filter nba-futures
python scripts/scan.py futures --filter mlb-futures --execute --unit-size 2 --max-bets 5
python scripts/scan.py futures --filter nba-futures --save
Prediction Markets
python scripts/scan.py prediction --filter crypto
python scripts/scan.py prediction --filter weather
python scripts/scan.py prediction --filter crypto --execute --unit-size 1 --max-bets 5
Portfolio & Settlement
python scripts/kalshi/kalshi_executor.py status --save
python scripts/kalshi/risk_check.py --report positions --save
python scripts/kalshi/kalshi_settler.py settle
python scripts/kalshi/kalshi_settler.py report --detail --save
Backtesting
python scripts/backtest/backtester.py
python scripts/backtest/backtester.py --simulate --save
python scripts/backtest/backtester.py --sport mlb --confidence high --min-edge 0.10

Claude Code Integration

Edge-Radar ships with two slash commands for Claude Code:

Skill Definition Description
/edge-radar .claude/skills/edge-radar/SKILL.md Unified command center — scan, bet, status, settle, risk, detail, backtest across Kalshi sports, futures, and prediction markets.
/edge-radar-analysis .claude/skills/edge-radar-analysis/SKILL.md Post-hoc performance report — trade ledger + slices by sport, category, side, edge bucket, confidence, price, calibration, longshots, streaks, daily P&L.
/edge-radar status                        # Balance, positions, P&L
/edge-radar scan nba                      # Preview NBA opportunities
/edge-radar bet mlb --unit-size 1         # Scan + execute on confirm
/edge-radar settle                        # Settle + P&L report
/edge-radar-analysis 30 --save            # 30-day performance report to reports/Performance/

Routes natural language to the correct scanner, enforces all risk gates, always previews before executing. All CLI flags work inline.

Note

Requires Claude Code CLI, Desktop, or IDE extension.

Gemini CLI / OpenAI Codex — add the skill content to your GEMINI.md or AGENTS.md for equivalent functionality.


Automated Daily Execution

Pre-built scripts scan all sports, rank by composite score, and execute with Kelly sizing. See the Automation Guide.

# Install all scheduled tasks at once
python scripts/schedulers/automation/install_windows_task.py install all
Task Schedule Description
daily-summary 4:50 AM PT Morning P&L digest — yesterday settled + open exposure + today pending + 7d context. Emailed at 5:00 AM PT (U2, 2026-04-30)
scan 8:00 AM ET Preview scan — saves report, no bets
execute 8:00 AM ET Scan + execute — places live orders
settle 11:00 PM ET Settle bets, update P&L
next-day 9:00 PM ET Scan + execute tomorrow's games
calibration 2:00 AM, 1st of month 30-day calibration report — Brier, calibration curve, prescriptive recommendations

Reports save to reports/Sports/schedulers/ with full execution details.


Architecture

Edge-Radar/
├── .claude/                           # Claude Code config (skills, commands, settings)
│   ├── commands/                      # Slash-command definitions
│   ├── html/                          # Rendered interactive data-flow diagram
│   ├── images/                        # Logos and README assets
│   └── skills/                        # /edge-radar, /edge-radar-analysis
├── .devcontainer/                     # VS Code dev container spec
├── .github/
│   └── workflows/                     # CI/CD + Streamlit Cloud deploy
├── app/
│   └── domain/                        # Typed domain objects (Opportunity, RiskDecision, Execution*)
├── docs/                              # All public documentation
│   ├── kalshi-futures-betting/        # Championship futures guide
│   ├── kalshi-prediction-betting/     # Crypto, weather, S&P guides
│   ├── kalshi-sports-betting/         # 27 sport filters, MLB filtering, sports guide
│   ├── mcp-config/                    # MCP server reference
│   ├── scripts/                       # Per-script detailed docs
│   ├── setup/                         # SETUP_GUIDE.md, AUTOMATION_GUIDE.md
│   └── web-app/                       # LOCAL.md, CLOUD.md
├── prompts/                           # LLM prompts for analysis agents
│   ├── futures/
│   ├── portfolio/
│   ├── predictions/
│   └── sports-betting/
├── scripts/
│   ├── backtest/                      # Equity curve, calibration, strategy simulation
│   ├── kalshi/                        # Scan → Size → Execute → Settle pipeline
│   ├── prediction/                    # Crypto, weather, S&P 500 scanners
│   ├── shared/                        # Team stats, weather, tickers, logging, odds API
│   ├── scan.py                        # Unified entry point (routes to each scanner)
│   ├── doctor.py                      # Environment & credentials validator
│   └── bootstrap.py                   # Import-path setup for the venv .pth file
├── tests/                             # 150+ pytest tests (domain, edge detection, fills, risk)
└── webapp/                            # Streamlit dashboard
    └── views/                         # scan_page, portfolio_page, settle_page, backtest_page

Gitignored at the root (auto-created where needed): data/ (trade history), logs/, reports/ (scan + P&L reports), keys/ (RSA private keys), .venv/, repos/.

Backtesting Framework

Analyze settled trades for win rate, ROI, profit factor, Sharpe ratio, equity curves, max drawdown, and calibration data — broken down by sport, category, confidence level, and edge bucket.

Metric Description
Win Rate Settled trades that won
ROI Net P&L / total wagered
Profit Factor Total wins / total losses
Sharpe Ratio Risk-adjusted daily P&L return
Max Drawdown Largest peak-to-trough decline
Calibration Predicted vs. actual win rate by bucket

The --simulate flag runs what-if scenarios across edge thresholds, confidence tiers, and categories. Use --save to export reports.


Documentation

Guide Description
Setup Guide Install, API keys, .env, safe rollout, automation, and monitoring — the single end-to-end operator guide
Automation Guide Windows Task Scheduler for daily betting
Scripts Reference Every script, flag, and example
Sports Guide 27 filters, edge detection, daily workflow
Futures Guide NFL, NBA, NHL, MLB, golf championships
Prediction Markets Crypto, weather, S&P 500, politics
Architecture Pipeline, risk gates, data flow
MLB Filtering 10 filter categories for MLB picks
Local Dashboard Run the Streamlit dashboard on your machine
Cloud Dashboard Deploy your own instance to Streamlit Community Cloud
Roadmap All enhancements — completed & pending
Changelog Full project history

Data Sources

All external data is free. Only Kalshi requires a funded account.

API Purpose
Kalshi Market data + order execution (API key + RSA signing)
The Odds API 12 US sportsbook odds (500 free req/mo)
ESPN NBA, NFL, NCAAB, NCAAF standings + line movement
NHL Stats API Standings, goal differential, last 10 record
MLB Stats API Standings, run differential, pitcher stats
NWS Hourly forecasts for 61 NFL/MLB outdoor venues
CoinGecko Crypto prices + 24h volatility
Yahoo Finance S&P 500 + VIX implied volatility

Setup  •  Architecture  •  Scripts  •  Changelog

Built with Python, scipy, and too many API calls — Back to top

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors