Context and instructions for AI coding agents working on this project.
| Document | What it covers |
|---|---|
| README.md | Architecture, quick start, module table, CLI reference |
| pyproject.toml | Dependencies, entry points, build config |
| data/fantasy_league_rules_2026.md | Official 2026 rules — squad constraints, transfers, boosters |
| data/squads_2026.json | 2026 IPL squads — 249 players, 10 teams, official credit costs from iplt20.com |
| data/player_aliases.json | ESPN name → Cricsheet name mapping (249 entries, verified) |
| data/schedule_2026.json | Parsed IPL 2026 schedule (first 20 matches) |
| data/raw/t20_recent_form.csv | Recent T20 form (175 players, 12 leagues + SMAT) |
- Entry point:
cli/main.py→ installed asipl-fantasyvia pyproject.toml - Pipeline:
orchestrator.pychains: forecast → simulate → optimize → captain → rerank → bandit - Player pool: Always from
data/squads_2026.json, never from historical CSV - Forecaster trains on historical IPL data but predicts for 2026 squad players only
- Name resolution:
src/forecast/models.pyusesplayer_aliases.json(ESPN → Cricsheet) before history lookup - Team abbreviations: MI, CSK, RCB, KKR, SRH, DC, GT, PBKS, RR, LSG — resolved in
cli/main.py
Historical Data (278K deliveries, 1169 matches)
↓
PlayerForecaster.fit(scorecards, deliveries)
├── Per-player history (career + recent 5 matches)
├── Venue-specific history (37 venues, player-venue pairs)
├── Batter-vs-team matchups (406 matchups)
├── T20 form data (175 players, 12 leagues)
└── T20 WC snub boost (+8% for dropped players)
↓
MonteCarloSimulator (10K simulations)
↓
IPLFantasyOptimizer (ILP with budget/role/team/overseas constraints + boosters)
↓
CaptainSelector (P(50+) + per-player IPL history + role bonus)
↓
RewardModel + LineupBandit (Thompson Sampling)
↓
Output: OptimizedLineup with C/VC
The forecaster blends multiple signals (in order of application):
- IPL career average (40%) + recent 5-match form (60%)
- Venue adjustment — player-venue history (30% weight, min 5 matches) or venue multiplier fallback
- Opposition matchup — batter SR vs bowling team (±10% for dominant/struggling matchups)
- T20 form — 20% weight blend from non-IPL T20 leagues (with 35% domestic discount for SMAT-only)
- T20 WC snub boost — +8% for players dropped from India's 2026 squad
- Cold-start — if no IPL history: use T20 form estimate; if no form: role-based priors
- Don't modify historical CSVs —
matches.csvanddeliveries.csvare append-only - 3 squad players not in IPL Fantasy portal — Muzarabani, Aman Rao, Dasun Shanaka
- Credit costs are static — real credits change per match. Update
squads_2026.jsonwhen new data available - Schedule only has 20/70+ matches — update
schedule_2026.jsonwhen BCCI releases Part 2 - T20 form CSV needs periodic refresh — run
uv run python scripts/fetch_t20_form.py --months 12 - BCCI SMAT API — JSONP format at
https://scores.bcci.tv/domesticstats/syed-mushtaq-ali-trophy-elite-2025-26/stats/player/full/mostRuns.js - Venue names have variants — normalized via
_VENUE_ALIASESinmodels.py. New venues may need adding.
- Say "I don't know" when you don't know. Do not guess factual information (schedules, fixtures, dates, venues). Check authoritative sources in the project first.
- IPL 2026 schedule: Consult
data/schedule_2026.jsonor the PDF — do not rely on general knowledge. - Injured players: Use
--exclude/-xflag ongenerate,squad init, andplancommands.
- Python 3.11+ required
- Install:
uv sync --extra dev - Run:
uv run <command>— no manual venv needed - Tests:
uv run pytest tests/ -v— 83 tests, all passing - LLM sidecar (optional): set
GOOGLE_API_KEYorOPENAI_API_KEY - No external DB — all data in CSV/JSON files under
data/
data/
├── raw/
│ ├── matches.csv, deliveries.csv # Historical IPL (2007-2025)
│ ├── cricket_data_2026.csv # Per-year player stats
│ ├── t20_recent_form.csv # T20 form (12 leagues + SMAT)
│ └── ...IPL Schedule 2026_Part 1.pdf # Official schedule PDF
├── scraped/ # Raw ODT files with official credits
├── squads_2026.json # 249 players, official credits
├── player_aliases.json # 249 name mappings (verified)
├── schedule_2026.json # First 20 matches parsed
└── fantasy_league_rules_2026.md # Official 2026 rules
src/
├── scoring/fantasy.py # Fantasy point calculation
├── forecast/models.py # Forecaster (history + venue + matchup + form + snub)
├── forecast/cold_start.py # Cold-start priors
├── simulation/monte_carlo.py # 10K Monte Carlo sims
├── optimizer/fantasy_ilp.py # ILP optimizer with boosters
├── optimizer/transfer_optimizer.py # Transfer-aware ILP with look-ahead
├── captain/selector.py # C/VC: P(50+) + per-player history
├── reranker/ # Reward model + Thompson Sampling
├── agent/orchestrator.py # Full pipeline orchestrator
├── season/schedule.py # Schedule loader
├── season/state.py # Squad state persistence
├── data/ingest.py # CSV loading
├── data/features.py # Scorecard builder
├── llm/sidecar.py # LLM context
└── config.py # Constraints, scoring, boosters, transfers
cli/main.py # All CLI commands
scripts/fetch_t20_form.py # T20 form data fetcher
scripts/fetch_2025_data.py # Cricsheet→CSV converter
- Full IPL 2026 schedule (Part 2+ from BCCI)
- Streamlit dashboard
- Live API for match-day inputs
- Transfer optimizer unit tests
scripts/parse_schedule.pyfor automated schedule updates