# Strategy tournament pattern for crypto trading bots

Use this when a user wants to compare many historical or candidate strategies quickly without increasing live risk.

## Pattern

1. Reconstruct strategy DNA as parameter presets, not by running old commits directly.
   - Extract durable parameters: trigger thresholds, ATR/SL multipliers, break-even activation, trailing distances, time stops, max trades, leverage, volume filters, cooldowns.
   - Group near-duplicate commits into strategy families.
   - Add a small number of explicitly-labelled candidate presets; keep them paper/backtest only.

2. Keep one live market-data feed conceptually, but isolate execution state per strategy.
   - Runtime layout:
     - `~/.local/state/<Bot>/experiments/<strategy_id>/paper_state.json`
     - `~/.local/state/<Bot>/experiments/<strategy_id>/Tradeanalyse/trade_journal.jsonl`
     - `~/.local/state/<Bot>/experiments/<strategy_id>/metrics.json`
     - `~/.local/state/<Bot>/experiments/<strategy_id>/bot.log`
     - `~/.local/state/<Bot>/experiments/<strategy_id>/bot.pid`
   - Every journal event should include `strategy_id`.
   - Use `PYTHONUNBUFFERED=1` or equivalent so background bot logs flush promptly.

3. Cap API load before launching parallel runners.
   - Filter internal/exchange pseudo-symbols such as `@123`.
   - Filter stablecoins, blacklists, illiquid assets, and malformed symbols.
   - Prefer a whitelist of liquid assets for live paper tournaments.
   - Add `max_scan_coins`, baseline/indicator caches, request timeouts, and error-log throttling.
   - If network errors repeat, pause or throttle; do not spawn more bots.

4. Rank by risk-adjusted metrics, not raw PnL.
   - Closed trades, win rate, average/total PnL, max drawdown, profit factor, average time-in-trade.
   - Apply sample-size penalties; with fewer than ~5 closed trades, report observation-only.
   - Do not promote a strategy live from tiny samples or one outlier trade.

5. Run historical replay/backtests in parallel with paper tournaments.
   - Paper tournaments measure current market behavior slowly.
   - Backtests/replay quickly screen many presets over regimes.
   - Use walk-forward/out-of-sample splits before calling a champion.

## Safety boundary

Parallel strategy testing means parallel paper/backtest portfolios only. Never run multiple live order executors against the same wallet unless a global live risk engine arbitrates total exposure, duplicate entries, daily loss, and kill switches.
