Skip to content
gmalbertPublic

About

Data analysis and sports betting for Cricket

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Wicket Oracle 🏏

Production-ready cricket betting analytics — win probability, player props, value bets, and playoff forecasts backed by verified data.


What is Wicket Oracle?

Wicket Oracle is a production-grade web app for cricket bettors who want data-driven insights. Every day before matches start, a nightly pipeline pulls the latest fixtures, weather, and DraftKings lines, then runs validated predictions. You see, side by side, what the model thinks will happen and what the bookmaker is pricing — so you can spot the gaps.

2026 audit update: match-winner betting is disabled; totals and in-play are research-only with flat paper stakes; player props abstain until confirmed-XI and timestamped-price gates pass. Kelly staking is not published.

The frontier implementation adds multi-format coverage, point-in-time logging, leakage-safe forward validation, live win probability, toss/XI scenarios, matchup shrinkage, advanced venue/phase analytics, model health, and optional OpenCode Zen previews through OPENCODE_API_KEY.

Production Features:

  • ✅ No mock data in production — Never shows simulated predictions as real
  • ✅ Atomic cache updates — Failed pipeline runs preserve last known good data
  • ✅ Full audit trail — Every run tracked with manifest, errors, and data lineage
  • ✅ Competition-aware — Per-competition status tracking (ready/stale/no_fixtures/etc.)
  • ✅ Model validation — Predictions only published if they pass 6 validation gates
  • ✅ Performance tracking — Settled predictions scored with Brier, calibration, ROI, CLV
  • ✅ Comprehensive testing — Unit tests, integration tests, CI/CD with GitHub Actions

What's inside

Today's Matches Research forecasts for each match with format-aware context, venue and weather inputs, toss/XI scenarios, forecast horizon, data coverage, and model verification status. Captured market prices are shown for comparison only while winner publishing is disabled.

Player Props Research projections for batters and bowlers. The app explicitly abstains instead of inventing lines, and props remain unavailable until confirmed-XI, timestamped-price, sample-size, and validation gates pass.

Market Release Gates An auditable view of per-market policy and validation status. Match-winner publishing is disabled; totals and in-play are research-only with flat paper stakes; props and futures remain unavailable. No Kelly stakes are published.

Team Deep Dive Recent form, batting and bowling breakdowns by phase of play (powerplay / middle overs / death), head-to-head records, and venue-specific performance for any team in the competition.

Fixtures & Table The full schedule with results, live points table, and a playoff probability simulator that runs 10,000 season scenarios to show each team's chances of making the top four.

Model Performance A running scorecard of how predictions have performed. Rolling accuracy, Brier score, calibration metrics, cumulative ROI, closing line value (CLV), and full match-by-match settlement log.

Statistics Deep-dive profiles for every venue, batter, bowler, and umpire based on historical ball-by-ball data.


Getting started

The front-end is a pure static React site (no Python server, no Streamlit). The Python pipeline remains, but it runs only inside GitHub Actions as the nightly data pull; the site consumes its exported JSON at build/serve time.

1. Site development

cd web
npm install
npm run dev        # local dev server at http://localhost:5173
npm run build      # type-check + production build into web/dist
npm run preview    # serve the production build locally

2. Data pipeline (Python, nightly)

pip install -r requirements.txt

To see real predictions, you need two free API keys:

Key Where to get it
ODDS_API_KEY the-odds-api.com
CRICKET_DATA_API_KEY cricketdata.org

Create a .env file (never commit this):

APP_ENV=production
ODDS_API_KEY=your_key_here
CRICKET_DATA_API_KEY=your_key_here

Then run the data pipeline and refresh the site's data bundle:

python -m pipeline.run_pipeline --skip-cricsheet
python pipeline/export_site_data.py

After that, the pipeline runs automatically every morning at 06:00 UTC via GitHub Actions, exports web/public/data/*.json, commits the result, and triggers a Cloudflare Pages redeploy — so the site always has fresh data.

Important: In production mode (APP_ENV=production), the pipeline never writes mock data. If the pipeline hasn't run or a cache is missing, the site displays its "No data available" state instead of fake predictions.


Production Architecture

Pipeline Workflow

  1. Fetch Cricsheet — Historical ball-by-ball data → team form, player stats, venue stats
  2. Fetch Fixtures — CricketData.org → today's matches + full schedule
  3. Fetch Odds — The Odds API → DraftKings implied probabilities
  4. Fetch Weather — Open-Meteo (no key required) → venue weather forecasts
  5. Feature Engineering — Build model features from historical and current data
  6. Run Models — XGBoost + LightGBM predictions (with validation)
  7. Monte Carlo — 10,000-trial playoff probability simulator
  8. Reconcile Predictions — Match predictions to actual results for performance tracking
  9. Export Site Data — pipeline/export_site_data.py materialises the static bundle into web/public/data/

Data Flow

[APIs] → [Nightly GH Workflow] → [Atomic Cache] → [Site Data Export] → [Cloudflare Pages]
                                      ↓
                                [Run Manifests]
  • Pipeline writes to cache/runs/{run_id}/ during execution
  • On success, atomically promotes to production cache with backup
  • On failure, preserves last known good cache
  • Every run tracked with full manifest (errors, warnings, counts, hashes)
  • The site itself is fully static: it fetches /data/*.json and renders client-side

Production States

Each competition tracked with granular status:

  • ready — Live predictions available
  • stale — Data > 24 hours old
  • no_fixtures — No matches scheduled
  • no_draftkings_market — No betting markets available
  • historical_data_insufficient — Need 100+ historical matches
  • model_not_ready — Model failed validation
  • no_qualifying_bets — No bets meet edge threshold
  • fetch_failed — API errors
  • not_run — Pipeline never executed
  • not_enabled — Competition disabled for production

Deployment

Local Development

cd web
npm install
npm run dev

Production Deployment (Cloudflare Pages)

The site is a static build hosted on Cloudflare Pages via Git integration: Cloudflare pulls the repo from GitHub and builds it on every push — no API tokens, no repo secrets, nothing pushed from CI.

One-time setup in the Cloudflare dashboard (Workers & Pages → Create → Pages → Connect to Git → select gmalbert/cricket):

Setting Value
Project name wicket-oracle
Production branch main
Root directory web
Build command npm run build
Build output directory dist

After that, every push to main — including the nightly pipeline's data commits under web/public/data/ — is pulled by Cloudflare and republished automatically. Branch pushes get preview URLs.

See docs/DEPLOYMENT.md and web/README.md for the full guide.

Health Monitoring

# Run health check (pipeline data freshness)
python scripts/health_check.py

# Expected output:
# ✅ Environment: production
# ✅ Cache is fresh (last updated: 2026-07-22T06:15:30Z)
# ✅ Using production data
# ✅ Competitions ready: 3/5
# ✅ Overall Status: HEALTHY

Testing

Run the full test suite:

# Python: pipeline + export contract tests
pytest tests/ -v

# With coverage
pytest tests/ -v --cov=pipeline --cov=utils --cov-report=term

# Web: type-check and build
cd web && npm run build

CI/CD runs automatically on every push:

  • Code quality (ruff, mypy)
  • Unit tests + site-data export smoke test
  • Integration tests
  • Security scanning
  • Build verification (Python imports + web build)

Keeping predictions honest

After every match finishes, the nightly pipeline checks the actual result against what was predicted and logs it. The Model Performance page shows this full history with:

  • Brier score — Calibration quality (lower is better, 0.20 is good)
  • Calibration slope/intercept — Are 60% predictions winning 60% of the time?
  • ROI by edge bucket — Are high-edge picks actually more profitable?
  • Closing Line Value (CLV) — Is the model ahead of market moves?

There's nowhere to hide a bad run. Every bet recommendation is backed by a live, auditable track record.


Documentation


Environment Variables

Variable Required Purpose Example
APP_ENV Yes Controls mock data behavior production or development
ODDS_API_KEY Production only The Odds API access abc123...
CRICKET_DATA_API_KEY Production only CricketData.org access xyz789...
OPENCODE_API_KEY Optional OpenCode Zen evidence-based match previews your-secret
OPENCODE_PREVIEWS_ENABLED Optional Override preview calls; defaults on when OPENCODE_API_KEY exists true or false

Never commit .env files — use environment secrets in production.


License

MIT License — see LICENSE for details.


Support

About

Data analysis and sports betting for Cricket

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages