#!/bin/bash
# [2026-09-26] 20-day tick replay: setup J vs J + entry_rules PASS gate (+ 15-min lockout variant).
# Candidate lists = the 20-day bar study's rebuilt 9:28 top 30 (tick20/cands). Every signal taken (max 99).
cd /var/www/screener/trade
T=/var/www/screener/trade/reports/open_window/tick20
J="--max-positions 99 --giveback-room-exit --giveback-room-min-cents 15 --giveback-room-ratio 0.25 --entry-slope-bars 0 --setup-plan --plan-context --plan-real-targets --min-stop-style k --min-stop-k 0.25 --resistance-stall-exit --max-ext-open --plan-min-rr 2.0"
for f in $T/cands/*.json; do
  d=$(basename $f .json)
  for v in base gate gate15; do
    case $v in
      base) X="";;
      gate) X="--shadow-gate pass";;
      gate15) X="--shadow-gate pass --shadow-gate-block-minutes 15";;
    esac
    s=$(date +%s)
    nice -n 10 python3 simulate.py --date $d $J --candidates-file $f --shadow-log $T/shadow_$v $X > $T/out/${v}_$d.out 2>&1
    echo "$v $d $(grep 'total:' $T/out/${v}_$d.out) [$(( $(date +%s) - s ))s]"
  done
done
echo TICK20_DONE
