feat: Enhance Optuna integration and logging for backtesting framework

Changes:
- Added new API endpoints for continuing and confirming Optuna jobs, allowing for better management of ongoing studies.
- Introduced detailed logging for tick feed tracking and order book processing, improving traceability of vendor performance during backtests.
- Updated database schema to include new fields for managing Optuna study results, enhancing the ability to track study progress and outcomes.
- Refactored existing functions to utilize the new logging and tracking features, ensuring consistency across the backtesting framework.

Impact:
- These enhancements improve the robustness and transparency of the Optuna backtesting process, facilitating better analysis and optimization of trading strategies.
This commit is contained in:
Your Name
2026-08-21 19:05:23 +09:00
parent 0ecac7cb95
commit 0780b2cdd0
76 changed files with 4648 additions and 516 deletions

View File

@@ -273,7 +273,8 @@ def align_momentum_entry_from_ticks(
진입봉 첫 유효 틱 체결가 (없으면 분봉 시가).
Returns:
(fill_price, entry_time_key, source) — source: ws_ticks | ohlc_open
(fill_price, entry_time_key, source) — source: ws_ticks:<vendor> | ohlc_open
(vendor=kis|kiwoom|ls … — 옵투나/백테 피드 추적용)
"""
p = params or {}
fo = float(fallback_open or 0)
@@ -293,6 +294,7 @@ def align_momentum_entry_from_ticks(
owner = ticks.owner
_price = owner._price
_tick_time = owner._tick_time
_source = getattr(owner, "_source", None)
for i in ticks.iter_idx():
tt = _tick_time[i].decode("utf-8")
if min_tt and len(tt) >= 14 and tt[:14] < min_tt[:14]:
@@ -302,7 +304,13 @@ def align_momentum_entry_from_ticks(
continue
fill_px = px * (1.0 + slip_pct / 100.0) if slip_pct > 0 else px
et = tt[:14] if len(tt) >= 14 else bar_key
return fill_px, et, "ws_ticks"
vendor = ""
if _source is not None:
try:
vendor = _source[i].decode("utf-8").strip().lower()
except Exception:
vendor = ""
return fill_px, et, (f"ws_ticks:{vendor}" if vendor else "ws_ticks")
return fo, bar_key, "ohlc_open"
for tick in ticks:
tt = str(tick.get("tick_time") or "")
@@ -314,7 +322,12 @@ def align_momentum_entry_from_ticks(
fill_px = px * (1.0 + slip_pct / 100.0) if slip_pct > 0 else px
tt = str(tick.get("tick_time") or "")
et = tt[:14] if len(tt) >= 14 else bar_key
return fill_px, et, "ws_ticks"
try:
from kis_trader.backtest.optuna_feed_trace import tick_source_label
return fill_px, et, tick_source_label(tick)
except Exception:
return fill_px, et, "ws_ticks"
return fo, bar_key, "ohlc_open"