#!/bin/bash
# Auto-restart wrapper for V11 bots.
# Usage: v11_run.sh <asset> <window> [--live]
# Example: v11_run.sh eth 5 --live

ASSET="${1:?usage: v11_run.sh <asset> <window> [--live]}"
WINDOW="${2:?usage: v11_run.sh <asset> <window> [--live]}"
LIVE="${3:-}"

cd /var/www/html/MetaHedge/BOTTEST || exit 1

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