A comprehensive Python tool for analyzing fantasy football player performance and identifying buy-low/sell-high opportunities using advanced metrics and machine learning techniques.
- Expected Fantasy Points (xFP) - Converts opportunity quality into expected points
- Buy-Low Scoring - Position-specific algorithms (0-100 scale)
- Usage Metrics - TPRR, WOPR, Snap Share, Route Participation
- Red Zone Analysis - Inside-5/Inside-10 opportunities
- Team Context - PROE, Pace, Air Yards Share
- Sleeper API - League settings, rosters, scoring
- NFL Data - Play-by-play, weekly stats, team data
- SumerSports - Advanced metrics and historical data
- MySportsFeeds - Injuries, depth charts (optional)
- Web-based Data Viewer - Sort, filter, and analyze players
- Buy-Low Identification - Automated candidate detection
- Position-Specific Analysis - WR/TE, RB, QB focused metrics
- Export Capabilities - CSV, Excel, HTML reports
git clone https://github.com/Alexander-Rees/FantasyFootballAnalysis.git
cd FantasyFootballAnalysis
pip install -r requirements.txtcp env_example.txt .env
# Edit .env with your API keys and league settings# Run enhanced analysis with advanced metrics
python src/analysis/enhanced_processor.py
# Start interactive data viewer
cd data/outputs
python -m http.server 8081
# Open http://localhost:8081/enhanced_fantasy_viewer.htmlPosition-specific composite score based on:
- WR/TE: TPRR (35%) + Route% (25%) + WOPR (20%) + Air Yards% (15%) + PROE (5%)
- RB: xFP (30%) + Snap% (25%) + Routes/DB (20%) + Inside-5 (15%) + RYOE (10%)
- QB: Dropbacks (35%) + Designed Rushes (25%) + PROE/Pace (20%) + EPA+CPOE (20%)
Expected Fantasy Points minus Actual Fantasy Points
- Positive = Buy Low (underperforming expectations)
- Negative = Sell High (overperforming expectations)
- TPRR - Targets per Route Run (most predictive WR/TE metric)
- WOPR - Weighted Opportunity (1.5×Target Share + 0.7×Air Yards Share)
- Snap Share - % of team offensive snaps
- Route Participation - % of team dropbacks with player running route
- WR/TE: Brian Thomas (xFP Gap: 12.4), Xavier Legette (xFP Gap: 12.0)
- RB: Jonathan Taylor (xFP Gap: 22.4), Tony Pollard (xFP Gap: 22.4)
- 35 total candidates identified across all positions
- Malik Nabers - High points but negative xFP gap (-12.2)
- Rome Odunze - Overperforming expectations (-17.8 gap)
FantasyFootballAnalysis/
├── src/
│ ├── analysis/ # Advanced metrics calculator
│ │ ├── advanced_metrics.py
│ │ └── enhanced_processor.py
│ ├── data_sources/ # Data collection modules
│ ├── transforms/ # Position-specific transforms
│ └── utils/ # Utility functions
├── data/
│ ├── raw/ # Raw data files
│ ├── processed/ # Processed data
│ └── outputs/ # Final outputs and viewer
│ ├── enhanced_fantasy_viewer.html
│ ├── enhanced_*_2025.csv
│ └── buy_low_*_2025.csv
├── docs/ # Documentation
└── tests/ # Unit tests
from src.analysis.enhanced_processor import EnhancedFantasyProcessor
processor = EnhancedFantasyProcessor()
wr_data, rb_data, qb_data = processor.run_enhanced_processing()
# Filter for high buy-low scores
buy_low_wr = wr_data[wr_data['buy_low_flag'] == True]
print(buy_low_wr[['player', 'buy_low_score', 'xFP_gap', 'fantasy_points']])# Top targets with high TPRR
high_volume_wr = wr_data[
(wr_data['targets'] >= 15) &
(wr_data['tprr'] >= 0.25)
].sort_values('tprr', ascending=False)# Required
SLEEPER_LEAGUE_ID=your_league_id
SEASON=2025
WEEKS=1,2
# Optional
MSF_API_KEY=your_msf_keyThe tool automatically pulls scoring settings from your Sleeper league, but you can override them in src/config.py.
The interactive web viewer provides:
- Sortable tables - Click any column header
- Advanced filtering - Min thresholds for all metrics
- Color coding - Green for buy-low, yellow for high scores
- Real-time search - Filter by player name or team
- Export capabilities - Download filtered data as CSV
This project is licensed under the MIT License - see the LICENSE file for details.
- Sleeper API for league data
- NFL Data for play-by-play statistics
- SumerSports for advanced metrics
- Fantasy Footballers for methodology insights