refactor: enhance Optuna backtesting framework, optimize orderbook filtering, and update database management utilities.
This commit is contained in:
@@ -271,7 +271,7 @@ class MomentumStrategy(BaseStrategy):
|
||||
now,
|
||||
default_hm="15:20",
|
||||
)
|
||||
params = dict(self._engine_params or me.get_momentum_defaults_from_db())
|
||||
params_base = dict(self._engine_params or me.get_momentum_defaults_from_db())
|
||||
|
||||
for code, holding in list(self.holdings.items()):
|
||||
try:
|
||||
@@ -326,6 +326,27 @@ class MomentumStrategy(BaseStrategy):
|
||||
"candle_time": now.strftime("%Y%m%d%H%M"),
|
||||
}
|
||||
|
||||
params = dict(params_base)
|
||||
# 수익구간·손절호가: 실매 호가 OR 히스토리 (둘 중 하나 ON일 때만 · 기본 OFF)
|
||||
from kis_trader.engine.momentum_hts_logic import (
|
||||
append_live_exit_ob_or,
|
||||
need_ob_or_history,
|
||||
_ob_or_ma_window_for_history,
|
||||
)
|
||||
|
||||
if need_ob_or_history(params):
|
||||
hist = list(holding.get("_ob_or_history") or [])
|
||||
hist = append_live_exit_ob_or(
|
||||
hist,
|
||||
self.ws,
|
||||
code,
|
||||
ma_window=_ob_or_ma_window_for_history(params),
|
||||
)
|
||||
holding["_ob_or_history"] = hist
|
||||
params["_ob_or_history"] = list(hist)
|
||||
else:
|
||||
params["_ob_or_history"] = []
|
||||
|
||||
res = me.check_sell_signal_momentum_live(position, candle, params, is_eod=is_eod)
|
||||
if not res:
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user