ls증권 히스토리 구독 넣음
This commit is contained in:
@@ -68,8 +68,14 @@ def _env_bool_10(v: Any) -> str:
|
||||
def _detect_strategy(data: Dict[str, Any], path: str) -> str:
|
||||
base = os.path.basename(path).lower()
|
||||
s = (data.get("strategy") or "").strip().upper()
|
||||
if s in ("US_MOMENTUM", "US-MOMENTUM"):
|
||||
return "US_MOMENTUM"
|
||||
if s in ("MOMENTUM", "BREAKOUT", "SCALP", "TAIL", "UPDOW"):
|
||||
return s
|
||||
# CLI / JSON strategy 슬러그
|
||||
s_low = (data.get("strategy") or "").strip().lower()
|
||||
if s_low == "us_momentum":
|
||||
return "US_MOMENTUM"
|
||||
|
||||
if base.startswith("updow_param_"):
|
||||
return "UPDOW"
|
||||
@@ -77,7 +83,12 @@ def _detect_strategy(data: Dict[str, Any], path: str) -> str:
|
||||
return "TAIL"
|
||||
if base.startswith("search_breakout_") or base.startswith("optuna_breakout_"):
|
||||
return "BREAKOUT"
|
||||
if base.startswith("optuna_us_momentum_") or base.startswith("search_us_momentum_"):
|
||||
return "US_MOMENTUM"
|
||||
if base.startswith("search_momentum_") or base.startswith("optuna_momentum_"):
|
||||
# market=US 결과 JSON
|
||||
if str(data.get("market") or "").strip().upper() == "US":
|
||||
return "US_MOMENTUM"
|
||||
return "MOMENTUM"
|
||||
if base.startswith("optuna_tail_"):
|
||||
return "TAIL"
|
||||
@@ -130,11 +141,8 @@ def _patch_from_momentum_merged(m: Dict[str, Any]) -> Dict[str, str]:
|
||||
|
||||
patch["MOMENTUM_VOL_WIN"] = str(gi("mom_vol_win", 5))
|
||||
|
||||
patch["MOMENTUM_TIME_END_HM"] = str(gi("mom_time_end_hm", 1430))
|
||||
|
||||
ts = m.get("time_start_hm")
|
||||
if ts not in (None, ""):
|
||||
patch["MOMENTUM_TIME_START"] = str(int(float(ts)))
|
||||
# TIME_* 는 session_env_patch / PARAM_SEARCH_APPLY_SESSION_TIME 경로만.
|
||||
# Optuna 과적합 창이 실매 매수시간을 덮지 않도록 여기서는 쓰지 않음.
|
||||
|
||||
# ※ 모멘텀 apply 는 MOMENTUM_* 만 기록. SCALP_* 를 덮으면 스캘핑 실매/웹이 오염되고,
|
||||
# 엔진은 MOMENTUM_COOLDOWN_SEC 등을 읽는데 SCALP_COOLDOWN 만 써서 apply 가 무효가 된다.
|
||||
@@ -237,6 +245,12 @@ def _patch_from_momentum_merged(m: Dict[str, Any]) -> Dict[str, str]:
|
||||
x = m.get("pullback_max_pct")
|
||||
if x not in (None, ""):
|
||||
patch["MOMENTUM_PULLBACK_MAX_PCT"] = str(float(x))
|
||||
x = m.get("setup_vol_max_mult")
|
||||
if x not in (None, ""):
|
||||
patch["MOMENTUM_SETUP_VOL_MAX_MULT"] = str(float(x))
|
||||
x = m.get("setup_bear_bars_min")
|
||||
if x not in (None, ""):
|
||||
patch["MOMENTUM_SETUP_BEAR_BARS_MIN"] = str(int(float(x)))
|
||||
x = m.get("ema_fast_period")
|
||||
if x not in (None, ""):
|
||||
patch["MOMENTUM_EMA_FAST_PERIOD"] = str(int(float(x)))
|
||||
@@ -340,14 +354,7 @@ def _patch_from_breakout_merged(m: Dict[str, Any]) -> Dict[str, str]:
|
||||
if x is not None:
|
||||
patch["BREAKOUT_BODY_MIN_PCT"] = str(float(x))
|
||||
|
||||
x = gv("time_start_hm")
|
||||
if x is not None:
|
||||
patch["BREAKOUT_TIME_START"] = str(int(float(x)))
|
||||
x = gv("time_end_hm")
|
||||
if x is not None:
|
||||
te = str(int(float(x)))
|
||||
patch["BREAKOUT_TIME_END"] = te
|
||||
patch["BREAKOUT_GOLDEN_END_HM"] = te
|
||||
# TIME_* / GOLDEN_END 는 session_env_patch(기본 OFF) — Optuna apply 가 창을 자르지 않음
|
||||
|
||||
x = gv("max_daily")
|
||||
if x is not None:
|
||||
@@ -580,6 +587,14 @@ def main(argv: Optional[List[str]] = None) -> int:
|
||||
patch.update(session_env_patch("MOMENTUM", merged))
|
||||
patch = strip_portfolio_keys_from_apply_patch(patch, "MOMENTUM")
|
||||
|
||||
elif strategy == "US_MOMENTUM":
|
||||
from kis_trader.engine.us_momentum_env_keys import params_to_us_momentum_env_patch
|
||||
merged = merge_param_search_apply_source(item, data)
|
||||
patch = params_to_us_momentum_env_patch(merged)
|
||||
patch.update(session_env_patch("US_MOMENTUM", merged))
|
||||
patch = strip_portfolio_keys_from_apply_patch(patch, "US_MOMENTUM")
|
||||
patch = {k: v for k, v in patch.items() if str(k).startswith("US_MOMENTUM_")}
|
||||
|
||||
elif strategy == "BREAKOUT":
|
||||
merged = merge_param_search_apply_source(item, data)
|
||||
patch = _patch_from_breakout_merged(merged)
|
||||
|
||||
Reference in New Issue
Block a user