mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-07-27 15:37:44 +00:00
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: