From 005107a46197c78ae3b4250b77531a2d3c4152d7 Mon Sep 17 00:00:00 2001 From: TPTBusiness Date: Mon, 13 Apr 2026 15:52:03 +0200 Subject: [PATCH] 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