Skip to content

howrealizdat/dfs-lineup-optimizer

Repository files navigation

🏀 DFS Lineup Optimizer — Constraint Optimization + LLM Reasoning

A daily-fantasy-sports lineup engine that builds salary-cap-valid lineups with Google OR-Tools constraint optimization, then runs an Anthropic Claude reasoning layer over each build to explain it, rate it, and suggest swaps. Real-time data ingestion feeds player projections, matchups, and an ownership/leverage model.

What it does

  • Constraint optimization (OR-Tools). Builds lineups that satisfy hard constraints — salary cap, roster slots/positions, and max players per team — while maximizing a custom projection score. Produces a 20-lineup portfolio, not just a single lineup.
  • Custom player valuation ("AceScore"). Blends projections, matchup grades, and value, with an ownership/leverage model layered on top for tournament (GPP) play.
  • LLM reasoning & explainability. An Anthropic Claude layer evaluates each finished lineup — strategy, strengths, risks, and realistic swaps — and scores it 0–100. The model is explicitly constrained to reason about the optimizer's output rather than invent new lineups: explainable AI over a deterministic optimizer, not freeform generation.
  • Portfolio & exposure management. Builds a diversified set of lineups and reports player exposure across the whole portfolio.
  • Real-time data ingestion. Scrapers and fetchers pull starters, matchup intel, and research context to feed the valuation model.

Pipeline

data ingestion  →  valuation (AceScore + ownership/leverage)  →  OR-Tools optimizer
      →  portfolio builder  →  Claude reasoning / rating  →  platform-ready CSV export

Files

  • main.py — pipeline entry point (load slate → value → optimize portfolio → validate → export).
  • main_phase4.py — slate loading, AceScore scoring, and the single-lineup OR-Tools optimizer.
  • advanced_optimizer.py — ownership & leverage model.
  • portfolio_manager.py — builds the multi-lineup portfolio.
  • output_formatter.py — formats lineups for upload and computes the exposure report.
  • ai_reasoner.py — Anthropic Claude reasoning / rating layer.
  • matchup_scraper.py, fetch_starters.py, fetch_research.py, lineup_generator.py — data ingestion + helpers.

Run it

  1. pip install -r requirements.txt
  2. Copy .env.example to .env and add your own keys (ANTHROPIC_API_KEY plus the data-source keys).
  3. python main.py

Keys are loaded from environment variables via python-dotenv and are never committed (.env is gitignored).

Tech

Python · Google OR-Tools · Anthropic Claude API · pandas · numpy · BeautifulSoup


Built by Edmund Gray.

About

Daily-fantasy-sports lineup optimizer: Google OR-Tools constraint optimization builds salary-cap lineups, then an Anthropic Claude reasoning layer explains, rates, and suggests swaps. Includes real-time data ingestion and portfolio/exposure management.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages