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:
@@ -244,8 +244,8 @@ class Backtester:
|
|||||||
)
|
)
|
||||||
logger.info(f"[{sym}] 데이터 로드: {len(df):,}캔들 ({df.index[0]} ~ {df.index[-1]})")
|
logger.info(f"[{sym}] 데이터 로드: {len(df):,}캔들 ({df.index[0]} ~ {df.index[-1]})")
|
||||||
|
|
||||||
# walk-forward 모델 주입
|
# walk-forward 모델 주입 (use_ml=True일 때만)
|
||||||
if ml_models is not None:
|
if ml_models is not None and self.cfg.use_ml:
|
||||||
self.ml_filters = {}
|
self.ml_filters = {}
|
||||||
for sym in self.cfg.symbols:
|
for sym in self.cfg.symbols:
|
||||||
if sym in ml_models and ml_models[sym] is not None:
|
if sym in ml_models and ml_models[sym] is not None:
|
||||||
@@ -620,13 +620,14 @@ class WalkForwardBacktester:
|
|||||||
f"학습 {train_start.date()}~{train_end.date()}, "
|
f"학습 {train_start.date()}~{train_end.date()}, "
|
||||||
f"검증 {test_start.date()}~{test_end.date()}")
|
f"검증 {test_start.date()}~{test_end.date()}")
|
||||||
|
|
||||||
# 심볼별 모델 학습
|
# 심볼별 모델 학습 (use_ml=True일 때만)
|
||||||
models = {}
|
models = {}
|
||||||
for sym in self.cfg.symbols:
|
if self.cfg.use_ml:
|
||||||
model = self._train_model(
|
for sym in self.cfg.symbols:
|
||||||
all_raw[sym], train_start, train_end, sym
|
model = self._train_model(
|
||||||
)
|
all_raw[sym], train_start, train_end, sym
|
||||||
models[sym] = model
|
)
|
||||||
|
models[sym] = model
|
||||||
|
|
||||||
# 검증 구간 백테스트
|
# 검증 구간 백테스트
|
||||||
test_cfg = BacktestConfig(
|
test_cfg = BacktestConfig(
|
||||||
|
|||||||
Reference in New Issue
Block a user