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

@@ -144,7 +144,10 @@ def align_entry_price_from_ticks(
ticks: List[Dict[str, Any]],
fallback_open: float,
) -> Tuple[float, str]:
"""신호 직후(진입봉) 첫 체결 틱 가격 (없으면 시가)."""
"""신호 직후(진입봉) 첫 체결 틱 가격 (없으면 시가).
Returns source: ``ws_ticks:<vendor>`` | ``ohlc_open`` (옵투나 피드 추적용).
"""
fo = float(fallback_open or 0)
if not ticks:
return fo, "ohlc_open"
@@ -152,18 +155,31 @@ def align_entry_price_from_ticks(
try:
from kis_trader.backtest.shared_ticks import TickColumnView
if isinstance(ticks, TickColumnView):
_price = ticks.owner._price
owner = ticks.owner
_price = owner._price
_source = getattr(owner, "_source", None)
for i in ticks.iter_idx():
price = float(_price[i])
if price > 0:
return price, "ws_ticks"
vendor = ""
if _source is not None:
try:
vendor = _source[i].decode("utf-8").strip().lower()
except Exception:
vendor = ""
return price, (f"ws_ticks:{vendor}" if vendor else "ws_ticks")
return fo, "ohlc_open"
except Exception:
pass
for tick in ticks:
price = float(tick.get("price") or 0)
if price > 0:
return price, "ws_ticks"
try:
from kis_trader.backtest.optuna_feed_trace import tick_source_label
return price, tick_source_label(tick)
except Exception:
return price, "ws_ticks"
return fo, "ohlc_open"