#!/bin/bash
# Usage: v12_run.sh <asset> <window> [--live] [--wallet wallets/w1.env]
# Example: v12_run.sh btc 5 --live
# Example: v12_run.sh btc 5 --live --wallet wallets/w1.env

ASSET="${1:?usage: v12_run.sh <asset> <window> [--live] [--wallet <path>]}"
WINDOW="${2:?usage: v12_run.sh <asset> <window>}"
shift 2

cd /var/www/html/Poly || exit 1

while true; do
    echo "[$(date '+%Y-%m-%d %H:%M:%S')] Starting V12 ${ASSET} ${WINDOW}m $*"
    python3 -m v12.main --asset "$ASSET" --window "$WINDOW" "$@"
    EXIT_CODE=$?
    echo "[$(date '+%Y-%m-%d %H:%M:%S')] Bot exited (code=$EXIT_CODE), restarting in 5s..."
    sleep 5
done
