#!/bin/bash
# Usage: v15_run.sh <asset> <window> [--live] [--wallet <path>]
# Example: v15_run.sh btc 5 --live
# Example: v15_run.sh eth 5 --live --wallet ../.env

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

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

while true; do
    echo "[$(date '+%Y-%m-%d %H:%M:%S')] Starting V15 ${ASSET} ${WINDOW}m $*"
    python3 -m v15.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
