#!/bin/bash
set -euo pipefail
cd /home/hoon/kis_bot
mkdir -p logs
TS=$(date +%Y%m%d_%H%M%S)
STUDY="scalp_fine_20260715_${TS}"
LOG="logs/param_search_optuna_scalp_fine_${TS}.log"
echo "$LOG" > logs/param_search_optuna_scalp_fine_latest.logpath
echo "$STUDY" > logs/param_search_optuna_scalp_fine_latest.study

# 모멘텀과 동일: 거래일 2026-07-15 · fine 200 · 호가 OFF · apply-best
# 포트 한도 = config_scalp 병합 (SCALP_TOTAL_BUDGET_KRW=120만) — env_config 단독 금지(600만 버그)
nohup python3 -u kis_trader/backtest/param_search_optuna.py \
  --strategy scalp \
  --mode fine \
  --start 2026-07-15 \
  --end 2026-07-15 \
  --trials 200 \
  --min_trades 1 \
  --min_win_rate 0 \
  --min_pf 0 \
  --sort-by score \
  --orderbook-filter off \
  --no-progress \
  --apply-best \
  --study-name "$STUDY" \
  > "$LOG" 2>&1 &
echo "PID=$!"
echo "STUDY=$STUDY"
echo "LOG=$LOG"
echo "tail -f /home/hoon/kis_bot/$LOG"
