fix(strategy): Re-evaluate Optuna-optimized strategies with full OHLCV backtest

- Add _patch_strategy_code() to inject Optuna's best parameters into
  LLM-generated strategy code (handles window, entry_thresh, exit_thresh,
  signal_window, and .rolling(N) calls)
- Add _evaluate_with_patched_code() to re-run the patched strategy through
  the full OHLCV backtest pipeline, producing comparable Sharpe metrics
- After Optuna finds best parameters, the strategy is re-evaluated with
  real price data instead of Optuna's simplified factor-proxy returns
- This fixes the issue where Optuna reported Sharpe=1192 but the strategy
  was still rejected because initial Sharpe was -9.82 (different calculation)
- Now strategies can be rescued if Optuna finds parameters that produce
  positive Sharpe in the real backtest
This commit is contained in:
TPTBusiness
2026-04-13 15:52:03 +02:00
parent 554a499d09
commit 005107a461

Diff Content Not Available