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:
@@ -1801,7 +1801,7 @@ class BreakoutStrategy(BaseStrategy):
|
||||
gap = 15.0 if get_env_bool("SCAN_REJECT_LOG_VERBOSE", False) else 60.0
|
||||
if time.time() - last >= gap:
|
||||
self._no_price_log[code] = time.time()
|
||||
self.logger.info("🔍 [탈락-가격없음] %s(%s) B안 WS시세 없음", name, code)
|
||||
self._scan_log("info", code, "🔍 [탈락-가격없음] %s(%s) B안 WS시세 없음", name, code)
|
||||
return None
|
||||
|
||||
forming = None
|
||||
@@ -1831,7 +1831,7 @@ class BreakoutStrategy(BaseStrategy):
|
||||
)
|
||||
self._cb_prof_mark(_cb, "engine")
|
||||
if reason:
|
||||
self.logger.info("🔍 [%s] %s(%s) %s", reason, name, code, msg or "")
|
||||
self._scan_log("info", code, "🔍 [%s] %s(%s) %s", reason, name, code, msg or "")
|
||||
return None
|
||||
if not signal:
|
||||
return None
|
||||
@@ -1842,7 +1842,7 @@ class BreakoutStrategy(BaseStrategy):
|
||||
reason, msg, signal = check_buy_signal_breakout_live(confirmed, params)
|
||||
self._cb_prof_mark(_cb, "engine")
|
||||
if reason:
|
||||
self.logger.info("🔍 [%s] %s(%s) %s", reason, name, code, msg or "")
|
||||
self._scan_log("info", code, "🔍 [%s] %s(%s) %s", reason, name, code, msg or "")
|
||||
return None
|
||||
if not signal:
|
||||
return None
|
||||
@@ -1855,7 +1855,7 @@ class BreakoutStrategy(BaseStrategy):
|
||||
)
|
||||
self._cb_prof_mark(_cb, "mid_enroll")
|
||||
if _defer:
|
||||
self.logger.info("🔍 [%s] %s(%s)", _defer, name, code)
|
||||
self._scan_log("info", code, "🔍 [%s] %s(%s)", _defer, name, code)
|
||||
return None
|
||||
if align_on and entry_open > 0:
|
||||
from kis_trader.engine.tail_tick_replay import live_align_entry_price
|
||||
@@ -1879,7 +1879,7 @@ class BreakoutStrategy(BaseStrategy):
|
||||
last = self._no_price_log.get(code, 0)
|
||||
if time.time() - last >= 60:
|
||||
self._no_price_log[code] = time.time()
|
||||
self.logger.info("🔍 [가격없음] %s(%s)", name, code)
|
||||
self._scan_log("info", code, "🔍 [가격없음] %s(%s)", name, code)
|
||||
else:
|
||||
self.logger.debug("🔍 [가격없음] %s(%s)", name, code)
|
||||
return None
|
||||
@@ -1981,10 +1981,16 @@ class BreakoutStrategy(BaseStrategy):
|
||||
if not hasattr(self, "_sell_no_price_log"):
|
||||
self._sell_no_price_log = {}
|
||||
self._sell_no_price_log[code] = time.time()
|
||||
self.logger.warning(
|
||||
"⚠️ [매도-가격없음] %s(%s) 마지막 WS·REST·폴백 없음 → 매도 판단 보류",
|
||||
name, code,
|
||||
)
|
||||
feed_lab = ""
|
||||
try:
|
||||
if hasattr(self.ws, "get_tick_feed_label"):
|
||||
feed_lab = str(self.ws.get_tick_feed_label(code) or "").strip()
|
||||
except Exception:
|
||||
feed_lab = ""
|
||||
self.logger.warning(
|
||||
"⚠️ [매도-가격없음] %s(%s) WS·REST·폴백 없음 (R:%s) → 매도 판단 보류",
|
||||
name, code, feed_lab or "?",
|
||||
)
|
||||
continue
|
||||
|
||||
# 최고가·세션저점 갱신 (모멘텀·백테 intrabar 와 동일 — 폴링 사이 저점도 손절·트레일에 반영)
|
||||
|
||||
Reference in New Issue
Block a user