### Soccer Betting Strategy Backtest: EPL 2023-24 Season - Over 2.5 Goals on High xG Teams\n\nThis is a data-driven strategy targeting **over 2.5 goals** in EPL matches where **both teams averaged >1.5 xG (offensive expected goals) over their previous 5 league outings**. It focuses on games likely to be high-scoring based on recent attacking quality. \n\n**Key Assumptions for Code:**\n- `games` list contains all 2023-24 EPL games (380 matches), sorted chronologically by `'date'` (ISO format, e.g., '2023-08-11').\n- Each game dict includes: `'game_id'`, `'date'`, `'home_team'` (str, e.g., 'Manchester City'), `'away_team'`, `'home_score'`, `'away_score'`, `'home_xg'` (float), `'away_xg'` (float).\n- Data sourced from BallDontLie API (filter to EPL 2023-24 season via `/games` endpoint with league/date params).\n- Bets only placed if **both teams have ≥5 prior outings** (skips early-season games).\n- Assumed odds: -110 (decimal 1.91) for over 2.5 goals (standard; adjust in `params`).\n- Flat staking (1 unit/bet); medium risk tolerance.\n- Baseline: 2023-24 EPL had 52.6% over 2.5 goals (200/380 matches), avg 3.28 goals/game.\n- **Risk Warning**: Single bets have lower variance than parlays/round robins, but xG momentum can fade. Backtest on real data; past performance ≠ future. High variance—expect drawdowns.\n\nThe code below:\n- Generates bets chronologically (stateful: tracks team xG history).\n- Simulates backtest with profit curve simulation, metrics, and simple text "chart" (profit evolution).\n- Usage: Fetch EPL 2023-24 games from BallDontLie, pass to `run_backtest()`.\n\n\n\n**To Run:**\n1. Fetch 2023-24 EPL data from BallDontLie API (`/games?seasons[]=2023&league=EPL` or equivalent).\n2. Ensure fields match (add xG via join if not native; BallDontLie may require supplement from FBref/Understat for xG).\n3. Call `run_backtest(games)`—outputs metrics instantly.\n4. **Improvements**: Dynamic odds from data, Kelly staking, filter by odds value (>1.95), combine with home/away bias.\n\n**Expected Hypothetical Performance** (based on EPL xG patterns): ~60-65% win rate on 100-150 bets (high-xG teams like LIV, MCI, ARS dominate mid-season), +5-10% ROI if edges hold. Test it! Questions? Provide your data for tweaks.\n\n⚠️ **Note:** Live backtesting encountered an issue. Please try again or use the Strategy Playground for detailed analysis.