#!/bin/bash
# Usage: v11b_run.sh <asset> <window> [--live] [--wallet wallets/w2.env] [--thresh-mult 1.25]
# Example: v11b_run.sh btc 5 --live
# Example: v11b_run.sh btc 5 --live --wallet wallets/w2.env --thresh-mult 1.25

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

cd /var/www/html || exit 1

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