#!/bin/bash
# [2026-10-24] waiter: after the Star flow download + the Star simulation -> build the whole-10-year list and download its flow
# (open_window/flow_tick/, massive_flow_tick.py --list; restarted after the close when market hours stop it).
cd /var/www/screener/trade/reports/ev3
until grep -q "STAR_QUEUE_DONE" star_flow.log 2>/dev/null && grep -q "SIMFULL_DONE" simstar_2y.log 2>/dev/null; do sleep 120; done
nice -n 19 python3 build_full10y_list.py > full10y_list.log 2>&1
until grep -q "FLOW_TICK_DONE" full10y_flow.log 2>/dev/null; do
  H=$(TZ=America/New_York date +%H%M); D=$(TZ=America/New_York date +%u)
  if [ "$D" -le 5 ] && [ "$H" -ge 0910 ] && [ "$H" -lt 1605 ]; then sleep 300; continue; fi
  (cd ../open_window && nice -n 19 python3 massive_flow_tick.py --list ../ev3/full10y_list.json) >> full10y_flow.log 2>&1
  sleep 60
done
echo "FULL10Y_QUEUE_DONE $(date)" >> full10y_flow.log
