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

@@ -220,6 +220,33 @@ def rerun_postprocess_on_json(path: str, *, ob_n_trials: int = 0) -> Dict[str, A
topn = data.get("postprocess_topn") or {}
n = len(topn.get("postprocess_by_anchor") or [])
logger.info("📌 후처리 재저장 %s anchors=%d overfit=%s", p, n, topn.get("apply_overfit_pct"))
try:
from kis_trader.backtest.optuna_study_store import (
count_study_states,
save_payload,
)
import optuna
from kis_trader.backtest.optuna_common import resolve_optuna_storage_url
sname = str(data.get("optuna_study_name") or "")
n_c = int(data.get("optuna_n_complete") or 0)
if sname:
try:
st = optuna.load_study(
study_name=sname,
storage=resolve_optuna_storage_url(None),
)
n_c, _nr, n_f = count_study_states(st)
except Exception:
n_f = n_c
save_payload(
study_name=sname,
out_data=data,
n_complete=n_f if n_f else n_c,
pp_status="done",
)
except Exception as exc:
logger.warning("⚠️ optuna_study_result 반영 실패: %s", exc)
return {"ok": True, "path": str(p), "anchors": n, "run_ob_whipsaw": True}
finally:
if ctx is not None: