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:
@@ -18,6 +18,7 @@ START="${START:-2026-07-20}"
|
||||
END="${END:-2026-07-21}"
|
||||
MODE="${MODE:-tpe}"
|
||||
TRIALS="${TRIALS:-200}"
|
||||
STUDY_TRIALS="${STUDY_TRIALS:-}"
|
||||
MIN_TRADES="${MIN_TRADES:-1}"
|
||||
# 탐색 게이트 OFF — TPE 학습. 사후 후보는 JSON results_gated (REPORT_MIN_*)
|
||||
MIN_WIN_RATE="${MIN_WIN_RATE:-0}"
|
||||
@@ -40,7 +41,7 @@ MASTER="logs/optuna_4strat_tpe_${START}_${END}_${TS0}_master.log"
|
||||
|
||||
{
|
||||
echo "======== Optuna 4전략 TPE 순차 시작 $(date -Is) ========"
|
||||
echo "START=$START END=$END MODE=$MODE TRIALS=$TRIALS"
|
||||
echo "START=$START END=$END MODE=$MODE TRIALS=$TRIALS STUDY_TRIALS=${STUDY_TRIALS:-}"
|
||||
echo "STRATEGIES=$STRATEGIES"
|
||||
echo "TAIL_OPTUNA_ENTRY_MODES=$TAIL_OPTUNA_ENTRY_MODES"
|
||||
echo "BREAKOUT_OPTUNA_SL_MODES=$BREAKOUT_OPTUNA_SL_MODES"
|
||||
@@ -80,6 +81,17 @@ run_one() {
|
||||
} | tee -a "$MASTER"
|
||||
echo "$log" > "logs/optuna_${strat}_tpe_latest.logpath"
|
||||
echo "$study" > "logs/optuna_${strat}_tpe_latest.study"
|
||||
# 웹 진행률: 전역 latest.study 가 이전 전략에 남으면 바가 1번에서 멈춤 → 잡별 파일
|
||||
if [[ -n "${OPTUNA_SEQ_ACTIVE_FILE:-}" ]]; then
|
||||
extra="${entry_mode:-${sl_mode:-}}"
|
||||
{
|
||||
echo "strategy=$strat"
|
||||
echo "study=$study"
|
||||
echo "entry_mode=${entry_mode:-}"
|
||||
echo "sl_mode=${sl_mode:-}"
|
||||
echo "extra=${extra}"
|
||||
} > "$OPTUNA_SEQ_ACTIVE_FILE"
|
||||
fi
|
||||
|
||||
set +e
|
||||
set +e
|
||||
@@ -98,6 +110,9 @@ run_one() {
|
||||
--sort-by "$sort_by"
|
||||
--universe-history-source "$UNIVERSE_HISTORY_SOURCE"
|
||||
)
|
||||
if [[ -n "${STUDY_TRIALS:-}" && "${STUDY_TRIALS}" != "0" ]]; then
|
||||
cmd_args+=(--study-trials "$STUDY_TRIALS")
|
||||
fi
|
||||
if [[ "$strat" == "tail" && -n "$entry_mode" ]]; then
|
||||
cmd_args+=(--entry-mode "$entry_mode")
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user