fix: WalkForward ignores use_ml=False flag, always injecting trained models

WF backtester always passed trained models to Backtester.run(ml_models=...),
overriding ml_filters even when use_ml=False. This caused 0 trades in
--no-ml mode because underfitted models (trained on ~27 samples) blocked
all entries with proba < 0.55 threshold.

- Skip model training when use_ml=False (saves computation)
- Only inject ml_models when use_ml=True

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
21in7
2026-03-07 00:19:27 +09:00
parent 89f44c96af
commit 072910df39

View File

@@ -244,8 +244,8 @@ class Backtester:
)
logger.info(f"[{sym}] 데이터 로드: {len(df):,}캔들 ({df.index[0]} ~ {df.index[-1]})")
# walk-forward 모델 주입
if ml_models is not None:
# walk-forward 모델 주입 (use_ml=True일 때만)
if ml_models is not None and self.cfg.use_ml:
self.ml_filters = {}
for sym in self.cfg.symbols:
if sym in ml_models and ml_models[sym] is not None:
@@ -620,8 +620,9 @@ class WalkForwardBacktester:
f"학습 {train_start.date()}~{train_end.date()}, "
f"검증 {test_start.date()}~{test_end.date()}")
# 심볼별 모델 학습
# 심볼별 모델 학습 (use_ml=True일 때만)
models = {}
if self.cfg.use_ml:
for sym in self.cfg.symbols:
model = self._train_model(
all_raw[sym], train_start, train_end, sym