refactor: enhance Optuna backtesting framework, optimize orderbook filtering, and update database management utilities.

This commit is contained in:
Your Name
2026-08-12 10:19:19 +09:00
parent cb7e5037a0
commit c6bd62a25f
218 changed files with 31613 additions and 759 deletions

View File

@@ -43,6 +43,16 @@ MOMENTUM_CONFIG_KEYS = frozenset({
"MOMENTUM_USE_VOL_TRIGGER",
"MOMENTUM_USE_RSI_FILTER",
"MOMENTUM_E_MIN_CHG_PCT",
"MOMENTUM_EXIT_OB_ENABLED",
"MOMENTUM_EXIT_OB_RATIO_MIN",
"MOMENTUM_EXIT_OB_MA_WINDOW",
"MOMENTUM_EXIT_OB_MIN_PROFIT_PCT",
"MOMENTUM_EXIT_OB_MIN_HOLD_BARS",
"MOMENTUM_STOP_OB_ENABLED",
"MOMENTUM_STOP_OB_RATIO_MIN",
"MOMENTUM_STOP_OB_MA_WINDOW",
"MOMENTUM_STOP_OB_MIN_LOSS_PCT",
"MOMENTUM_STOP_OB_MIN_HOLD_BARS",
"MOMENTUM_PATTERN_BREAKOUT",
"MOMENTUM_PATTERN_PULLBACK",
"MOMENTUM_CHASE_LOOKBACK_MIN",
@@ -246,4 +256,24 @@ def params_to_momentum_env_patch(p: Dict[str, Any]) -> Dict[str, str]:
_set("MOMENTUM_MAX_STOCKS", int(float(p["max_stocks"])))
if "total_budget_krw" in p:
_set("MOMENTUM_TOTAL_BUDGET_KRW", int(float(p["total_budget_krw"])))
if "exit_ob_enabled" in p:
_set("MOMENTUM_EXIT_OB_ENABLED", str(p["exit_ob_enabled"]).lower())
if "exit_ob_ratio_min" in p and p.get("exit_ob_ratio_min") not in (None, ""):
_set("MOMENTUM_EXIT_OB_RATIO_MIN", float(p["exit_ob_ratio_min"]))
if "exit_ob_ma_window" in p and p.get("exit_ob_ma_window") not in (None, ""):
_set("MOMENTUM_EXIT_OB_MA_WINDOW", int(float(p["exit_ob_ma_window"])))
if "exit_ob_min_profit_pct" in p and p.get("exit_ob_min_profit_pct") not in (None, ""):
_set("MOMENTUM_EXIT_OB_MIN_PROFIT_PCT", float(p["exit_ob_min_profit_pct"]))
if "exit_ob_min_hold_bars" in p and p.get("exit_ob_min_hold_bars") not in (None, ""):
_set("MOMENTUM_EXIT_OB_MIN_HOLD_BARS", int(float(p["exit_ob_min_hold_bars"])))
if "stop_ob_enabled" in p:
_set("MOMENTUM_STOP_OB_ENABLED", str(p["stop_ob_enabled"]).lower())
if "stop_ob_ratio_min" in p and p.get("stop_ob_ratio_min") not in (None, ""):
_set("MOMENTUM_STOP_OB_RATIO_MIN", float(p["stop_ob_ratio_min"]))
if "stop_ob_ma_window" in p and p.get("stop_ob_ma_window") not in (None, ""):
_set("MOMENTUM_STOP_OB_MA_WINDOW", int(float(p["stop_ob_ma_window"])))
if "stop_ob_min_loss_pct" in p and p.get("stop_ob_min_loss_pct") not in (None, ""):
_set("MOMENTUM_STOP_OB_MIN_LOSS_PCT", float(p["stop_ob_min_loss_pct"]))
if "stop_ob_min_hold_bars" in p and p.get("stop_ob_min_hold_bars") not in (None, ""):
_set("MOMENTUM_STOP_OB_MIN_HOLD_BARS", int(float(p["stop_ob_min_hold_bars"])))
return patch