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

@@ -326,10 +326,29 @@ def run_breakout_backtest_portfolio(
minute_ticks = (
collect_minute_ticks(ticks_by_code, code, t) if use_tick_exit else None
)
# 수익구간·손절호가: LS(또는 history_source) 호가 OR (둘 중 ON일 때만 · 기본 OFF)
from kis_trader.engine.momentum_hts_logic import (
collect_exit_ob_or_history,
need_ob_or_history,
_ob_or_ma_window_for_history,
)
sell_params = dict(params)
if need_ob_or_history(params) and orderbook_by_code:
ors = collect_exit_ob_or_history(
orderbook_by_code,
code,
entry_time=str(pos.get("entry_time") or ""),
asof_time=t,
ma_window=_ob_or_ma_window_for_history(params),
)
pos["_ob_or_history"] = ors
sell_params["_ob_or_history"] = list(ors)
else:
sell_params["_ob_or_history"] = list(pos.get("_ob_or_history") or [])
res = resolve_backtest_sell(
pos,
bar,
params,
sell_params,
is_eod=is_eod,
sell_fn=check_sell_signal_breakout_live,
low_mode="current",