diff --git a/core/bot.py b/core/bot.py index 8941a54..1a250f6 100644 --- a/core/bot.py +++ b/core/bot.py @@ -54,7 +54,7 @@ class TradingBot: 10. Repeat """ - def __init__(self): + def __init__(self, start_paused: bool = False): self.settings = get_settings() self._running = False self._shutdown_event = asyncio.Event() @@ -99,7 +99,7 @@ class TradingBot: self._cycle_count = 0 self._last_news_check: Optional[datetime] = None self._last_regime = None - self._trading_paused = False + self._trading_paused = start_paused def _setup_logging(self): """Configure loguru logging.""" @@ -169,9 +169,13 @@ class TradingBot: balance_str = f"${account['balance']:,.2f}" if account else "N/A" active_profile = self.settings.active_mode.capitalize() profile_emoji = {"Safe": "🟢", "Moderate": "🟡", "Aggressive": "🔴"}.get(active_profile, "⚪") + + status_title = "STANDBY (Trading Off)" if self._trading_paused else "RUNNING" + trading_state_desc = "🟡 STANDBY — Tap [▶️ Start Trading] or send /startbot from your phone to start trading" if self._trading_paused else "🟢 ACTIVE & SCANNING" + await self.telegram.send_bot_status( - "RUNNING", - f"Mode: {mode}\nBalance: {balance_str}\nSymbol: XAUUSD\nTrading Profile: {profile_emoji} {active_profile}" + status_title, + f"Mode: {mode}\nBalance: {balance_str}\nSymbol: XAUUSD\nTrading Profile: {profile_emoji} {active_profile}\nState: {trading_state_desc}" ) # Start interactive 2-way Telegram polling in background diff --git a/main.py b/main.py index 1905414..f397000 100644 --- a/main.py +++ b/main.py @@ -48,7 +48,12 @@ def parse_args(): parser.add_argument( "--telegram", action="store_true", - help="Start interactive Telegram Command Center only", + help="Start interactive Telegram Command Center only (in standby mode)", + ) + parser.add_argument( + "--standby", + action="store_true", + help="Start bot in standby mode (Telegram active, trading paused until started via Telegram)", ) parser.add_argument( "--demo", @@ -122,34 +127,15 @@ def start_dashboard(): def run_telegram(): - """Run interactive Telegram Command Center in standalone mode with native long-polling.""" - from notifications.telegram_bot import TelegramNotifier - from core.mt5_connector import MT5Connector + """Start the full Trading Bot in Standby Mode with 2-way Telegram Command Center active.""" + from core.bot import TradingBot logger.info("=" * 60) - logger.info(" Starting Telegram Command Center (Standalone Mode)") + logger.info(" Starting XAUUSD Bot in Standby Mode (Telegram Controlled)") logger.info("=" * 60) - mt5 = MT5Connector() - mt5.connect(max_retries=1, retry_delay=1) - - from strategies.regime_detector import RegimeDetector - from analysis.technical import TechnicalAnalyzer - - class StandaloneBot: - def __init__(self, mt5_conn): - self.mt5 = mt5_conn - self.regime_detector = RegimeDetector() - self.technical = TechnicalAnalyzer() - self._last_regime = None - self._trading_paused = False - - bot_wrapper = StandaloneBot(mt5) - notifier = TelegramNotifier(bot_instance=bot_wrapper) - try: - notifier.run_standalone() - except KeyboardInterrupt: - logger.info("Telegram Bot terminated by user") + bot = TradingBot(start_paused=True) + asyncio.run(bot.start()) def run_backtest(): @@ -206,7 +192,8 @@ def main(): # Start the live trading bot from core.bot import TradingBot - bot = TradingBot() + start_paused = getattr(args, "standby", False) + bot = TradingBot(start_paused=start_paused) asyncio.run(bot.start()) diff --git a/run_standby.bat b/run_standby.bat new file mode 100644 index 0000000..deb39c8 --- /dev/null +++ b/run_standby.bat @@ -0,0 +1,3 @@ +@echo off +call run.bat --standby +pause diff --git a/start_bot_background.vbs b/start_bot_background.vbs index f47ac9e..f2ba22e 100644 --- a/start_bot_background.vbs +++ b/start_bot_background.vbs @@ -1,3 +1,3 @@ Set WshShell = CreateObject("WScript.Shell") WshShell.CurrentDirectory = "c:\Users\Mazonia\Desktop\XAUUSD-AI-Trading-Bot" -WshShell.Run "cmd.exe /c run_bot.bat", 0, False +WshShell.Run "cmd.exe /c run_standby.bat", 0, False