fix(fitness): hardening anti-overfit post-7y incident — 3 correzioni
Incident: extended run elite (Sharpe IS 1.93) net-negativo su 7y
continuous (fees=101% del gross). Multi-fold validation NON sufficiente:
ogni fold restarta equity, mascherando accumulo fees compound.
Correzioni:
1) Default --start esteso a 2018-09-01 (7.3 anni)
- Copre bear 2018-19, halving 2020, COVID, ATH 2021, winter 2022,
ETF rally 2024, regime corrente.
- Una finestra corta (2y) lasciava il GA libero di overfit single-regime.
2) fees_eat_alpha promosso a hard-kill in fitness v2
- Da soft-penalty 0.4x a hard-kill 0 fitness.
- Una strategia con fees > 50% del gross non e' recuperabile via
selection: il prodotto del GA non puo' deployare con quel cost burden.
3) Nuovo finding negative_net_pnl (HIGH, hard-kill)
- Fires quando sum(trade.net_pnl) < 0 sul training window.
- Cattura: gross negativo (no edge direzionale) E gross positivo ma
fees > gross (edge insufficiente).
- Sintesi del net-after-fees su finestra continua come "deal-breaker"
non negoziabile via soft penalty.
CLI:
- --fitness-hard-kill <csv> per override esplicito.
- Default v2: no_trades,degenerate,undertrading,fees_eat_alpha,negative_net_pnl.
Test:
- 252 pass (251 + 1 nuovo: test_negative_net_pnl_fires_on_negative_gross).
- Test e2e WFA aggiornato: passa fitness_hard_kill_findings=('no_trades',)
perche' il fixture sintetico non produce strategie profittevoli.
- test_no_findings_on_reasonable_strategy rinominato:
test_rsi_mean_reversion_loses_money_on_synthetic_data (riflette
semantica reale: RSI mean-rev su synthetic ohlcv ha net negativo).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -111,7 +111,7 @@ Stack: Python 3.13, uv workspace, hatchling, pytest+pytest-mock+responses, opena
|
||||
```bash
|
||||
uv sync # installa entrambi i workspace member come editable
|
||||
cp .env.example .env # compila CERBERO_*_TOKEN e OPENROUTER_API_KEY
|
||||
uv run pytest # 250 test attesi (246 core + 4 smoke strategy_crypto)
|
||||
uv run pytest # 252 test attesi (248 core + 4 smoke strategy_crypto)
|
||||
```
|
||||
|
||||
### Variabili .env richieste
|
||||
@@ -151,15 +151,16 @@ uv run mypy src/ scripts/
|
||||
uv run python scripts/smoke_run.py
|
||||
|
||||
# Run reale Phase 1/2 (Cerbero + OpenRouter, ~$0.15-0.25 per run K=20 10gen,
|
||||
# ~$0.40-0.55 per run esteso K=40 20gen con WFA OOS)
|
||||
# ~$0.40-0.55 per run esteso K=40 20gen con WFA OOS).
|
||||
# Default --start ora 2018-09-01 (7.3y, copre bear+halving+covid+ATH+winter+ETF).
|
||||
uv run python scripts/run_phase1.py \
|
||||
--name run-XXX \
|
||||
--exchange deribit --symbol BTC-PERPETUAL --timeframe 1h \
|
||||
--start 2024-01-01T00:00:00+00:00 \
|
||||
--end 2026-01-01T00:00:00+00:00 \
|
||||
--population-size 20 --n-generations 10 \
|
||||
--prompt-mutation-weight 0.30 --fitness-v2 \
|
||||
--llm-concurrency 8 # 5-8x speedup wall time (default 1)
|
||||
# fitness-v2 hardened: hard-kill su {no_trades, degenerate, undertrading,
|
||||
# fees_eat_alpha, negative_net_pnl}. Override via --fitness-hard-kill CSV.
|
||||
# Default --prompt-library: importlib.resources del package strategy_crypto/prompts.json
|
||||
|
||||
# Multi-fold validation di un run esistente (anti-overfit, 7y expanding-window)
|
||||
|
||||
Reference in New Issue
Block a user