#!/bin/bash # One-shot task: gracefully stop the trading bot just before market close (15:59 ET), # so no signals can fire after hours and queue orders for the next open. # Self-removes from crontab after running. BOT_DIR="$(cd "$(dirname "$0")" && pwd)" LOG="$BOT_DIR/trading_bot.log" echo "=== $(date) EOD stop requested ===" >> "$LOG" if pkill -TERM -f "python.*main\.py"; then echo "$(date) SIGTERM sent to bot (graceful shutdown, may take up to 60s)" >> "$LOG" else echo "$(date) no bot process found" >> "$LOG" fi # self-remove from crontab (one-shot task) crontab -l 2>/dev/null | grep -v "stop_bot_eod" | crontab -