From d633439ae2da7c163da3793e9462d720d686c9a1 Mon Sep 17 00:00:00 2001 From: Tommy Date: Tue, 11 Aug 2026 19:41:22 -0400 Subject: [PATCH] Disable MAStock strategy; harden restart_bot kill logic --- config.py | 2 +- restart_bot.sh | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/config.py b/config.py index fdec04a..9499326 100644 --- a/config.py +++ b/config.py @@ -35,7 +35,7 @@ class IBConfig: @dataclass class StockStrategyConfig: - enabled: bool = True + enabled: bool = False # MAStock disabled 2026-08-11: +101.66(ShortTerm)/-19.98(MeanRev)/-65.47(MAStock) since 08-03 symbols: list[str] = field(default_factory=lambda: ["AMZN", "AAPL", "NVDA", "NOK"]) currency: str = "USD" exchange: str = "SMART" diff --git a/restart_bot.sh b/restart_bot.sh index 3c657ed..9f2ef9a 100755 --- a/restart_bot.sh +++ b/restart_bot.sh @@ -7,8 +7,21 @@ LOG_FILE="$BOT_DIR/trading_bot.log" echo "=== IB Trading Bot Starter ===" echo "BOT_DIR: $BOT_DIR" -# Step 1: Kill any existing bot process -pkill -f "main.py" 2>/dev/null || true +# Step 1: Kill any existing bot process (TERM first, escalate to KILL if stuck) +PIDS=$(pgrep -f "main.py" || true) +if [ -n "$PIDS" ]; then + echo "Old bot PID(s): $PIDS, sending SIGTERM..." + pkill -f "main.py" 2>/dev/null || true + for _ in $(seq 1 10); do + if ! pgrep -f "main.py" >/dev/null 2>&1; then break; fi + sleep 1 + done + if pgrep -f "main.py" >/dev/null 2>&1; then + echo "Still alive after 10s, sending SIGKILL..." + pkill -9 -f "main.py" 2>/dev/null || true + sleep 1 + fi +fi echo "[1/2] Stopped old bot process (if any)" # Step 2: Start the trading bot (setsid so it survives this shell exiting)