옵투나 오류수정정

This commit is contained in:
Your Name
2026-08-21 20:18:24 +09:00
parent 0780b2cdd0
commit 3eaa3b61df
14 changed files with 370 additions and 106 deletions

View File

@@ -481,8 +481,14 @@ def run_tail_optuna(
direction=direction,
sampler=sampler,
)
from kis_trader.backtest.optuna_study_store import bind_study_trials, finalize_optuna_export
from kis_trader.backtest.optuna_study_store import (
bind_study_trials,
clamp_optimize_n_trials,
finalize_optuna_export,
make_study_goal_stop_callback,
)
bind_study_trials(study, n_trials=n_trials, log=logger)
n_trials = clamp_optimize_n_trials(study, n_trials, log=logger)
def objective(trial: optuna.Trial) -> float:
if ctx.mode == "tpe":
@@ -531,12 +537,16 @@ def run_tail_optuna(
)
t0 = time.time()
try:
study.optimize(
objective,
n_trials=n_trials,
n_jobs=n_jobs,
show_progress_bar=show_progress,
)
if n_trials <= 0:
logger.info("📌 추가 trial 없음 — 기존 study 결과만 정리")
else:
study.optimize(
objective,
n_trials=n_trials,
n_jobs=n_jobs,
show_progress_bar=show_progress,
callbacks=[make_study_goal_stop_callback(logger)],
)
elapsed = time.time() - t0
logger.info("✅ Optuna 완료 | %.1f초 | 완료 trial %d", elapsed, len(study.trials))