How stoic-kal/betting-model works
Purpose and entry points
This is an MLB betting-model platform: it ingests baseball/odds data, builds features, trains and promotes moneyline/totals models, generates daily picks, tracks outcomes, and exposes results through a Python web application plus iOS and analytics-dashboard clients. Primary runtime entry points are app.py, run_betting_model.py, generate_game_card.py, and src/production_runner.py.
Application/API layer
The Python application is organized as a route-and-service system. Route modules present game, pick, result, analytics, diagnostics, and system endpoints; services own business workflows such as pick generation, model control, execution, reporting, and notifications.
• app.py
• web/routes/picks_routes.py
• web/routes/game_routes.py
• services/pick_service.py
• services/execution_service.py
• services/model_control_service.py
Data ingestion and feature stores
Historical and live workflows consume local baseball statistics, Statcast-derived tables, retrospective splits, and Vegas odds files. Pipeline ingestion/build stages normalize these sources into versioned game-feature datasets; live features are a boundary between scheduled games/current context and inference.
• pipeline/retrosplits_ingestion.py
• pipeline/vegas_ingestion.py
• pipeline/statcast_store.py
• pipeline/build_features_v2.py
• pipeline/live_features_v2.py
• data/games_v2_features_final.csv
Modeling, calibration, and promotion
Separate moneyline and totals training pipelines share common training/calibration machinery. Model artifacts are versioned in a filesystem registry, with latest.json pointers, metadata, promotion reports, and validation/audit outputs; this is the deployable-model contract rather than an external model service.
• pipeline/train_moneyline.py
• pipeline/train_totals.py
• pipeline/train_experimental_candidates.py
• pipeline/model_registry.py
• pipeline/retrain.py
• models/registry/moneyline/latest.json
• models/registry/totals/latest.json
Prediction and betting decisions
Production prediction combines trained artifacts with game context, odds/market signals, and prediction math to produce picks. Supporting services cover portfolios, shadow inference, opposite-model comparison, execution recording, and postgame/loss learning. Daily and historical pick files are durable handoff outputs.
• src/get_game_predictions_v2.py
• services/ml_model_v3.py
• services/totals_model_v3.py
• services/market_signals_service.py
• services/portfolio_risk_service.py
• results/daily_picks.csv
Operations, results, and external integrations
The service layer integrates odds feeds, Discord notifications, and Pikkit-related tracking, while scripts poll/fetch odds and import results. Deployment artifacts indicate Docker Compose and macOS launchd service operation. No cloud database or queue is evidenced in the tree; CSV/JSONL/JSON files are the visible persistence boundary.
• services/odds_feed_service.py
• services/notifications/engine.py
• services/pikkit_service.py
• scripts/odds/poll_odds.py
• docker-compose.yml
• deploy/com.jingleez.flask.plist
User-facing clients and analytics
The server-rendered web UI is under web/templates. A native SwiftUI iOS app calls an API client and presents Today, Results, Insights, Alerts, and Account views. projects/athena is a separate React/TypeScript/Vite diagnostics frontend with API/stream clients, state stores, and feature pages for calibration, CLV, drift/data health, edge, and prediction analysis.
• ios/JingleezMobile/JingleezMobile/APIClient.swift
• ios/JingleezMobile/JingleezMobile/JingleezMobileApp.swift
• projects/athena/src/services/api.ts
• projects/athena/src/app/router.tsx
• projects/athena/src/features/overview/OverviewPage.tsx
Research and governance boundary
Offline research supports leakage-aware historical replay, calibration/root-cause diagnostics, and reporting. These workflows consume data/model outputs and generate experiment artifacts; they should remain separate from live pick execution.
• research/historical_replay/cli.py
• research/historical_replay/engine.py
• research/diagnostics/totals/run_all.py
• pipeline/execution_audit.py
• reports/execution/complete_execution_audit.json
Main entry points: get_game_predictions_v2.py Prediction Engine · model_registry.py Filesystem Model Registry · games_v2_features_final.csv Versioned Game Features · app.py Python Web App
Components 20
Application & Clients
- Python Web App · Routes expose games, picks, results, analytics, and system APIs.
app.py - Route Modules
web/routes/picks_routes.py - iOS Client
ios/JingleezMobile/JingleezMobile/JingleezMobileApp.swift - Athena Dashboard
projects/athena/src/app/router.tsx
Data Pipeline
- Baseball & Odds Ingestion · Normalizes local baseball, Statcast, retrosplits, and Vegas inputs.
pipeline/retrosplits_ingestion.py - Historical Feature Builder
pipeline/build_features_v2.py - Versioned Game Features
data/games_v2_features_final.csv - Live Features · Combines scheduled-game context for current inference.
pipeline/live_features_v2.py
Model Lifecycle
- Moneyline & Totals Training · Separate targets share training and calibration machinery.
pipeline/train_moneyline.py - Experimental Candidates
pipeline/train_experimental_candidates.py - Filesystem Model Registry · Promotion metadata, reports, validation outputs, and latest pointers form the deployable contract.
pipeline/model_registry.py - Moneyline Latest Pointer
models/registry/moneyline/latest.json - Totals Latest Pointer
models/registry/totals/latest.json
Production Decisions
- Production Runner · Coordinates daily production workflows.
src/production_runner.py - Prediction Engine · Combines deployed artifacts, game context, odds, and prediction math.
src/get_game_predictions_v2.py - Pick & Portfolio Service · Generates picks and applies portfolio risk controls.
services/pick_service.py - Daily Picks
results/daily_picks.csv - Odds, Notifications & Tracking · Connects odds feeds, Discord notifications, and Pikkit tracking.
services/odds_feed_service.py
Research & Governance
- Historical Replay · Leakage-aware replay remains separate from live execution.
research/historical_replay/engine.py - Execution Audit
pipeline/execution_audit.py
Connections 24
- Python Web App → Route Modules: serves
- iOS Client → Python Web App: API calls
- Athena Dashboard → Python Web App: API and streams
- Baseball & Odds Ingestion → Historical Feature Builder: normalized inputs
- Historical Feature Builder → Versioned Game Features: writes
- Versioned Game Features → Moneyline & Totals Training: trains on
- Versioned Game Features → Live Features: historical context
- Moneyline & Totals Training → Filesystem Model Registry: registers candidates
- Experimental Candidates → Filesystem Model Registry: promotion inputs
- Filesystem Model Registry → Moneyline Latest Pointer: publishes
- Filesystem Model Registry → Totals Latest Pointer: publishes
- Production Runner → Live Features: builds daily context
- Production Runner → Prediction Engine: runs
- Moneyline Latest Pointer → Prediction Engine: loads model
- Totals Latest Pointer → Prediction Engine: loads model
- Odds, Notifications & Tracking → Prediction Engine: market odds
- Live Features → Prediction Engine: game context
- Prediction Engine → Pick & Portfolio Service: predictions
- Pick & Portfolio Service → Daily Picks: writes picks
- Daily Picks → Python Web App: picks and results
- Pick & Portfolio Service → Odds, Notifications & Tracking: records and notifies
- Versioned Game Features → Historical Replay: historical inputs
- Filesystem Model Registry → Historical Replay: model artifacts
- Daily Picks → Execution Audit: execution evidence