瀏覽代碼

Temporarily disable copy trading functionality due to blocking issues

- Commented out the initialization and command handlers for CopyTradingCommands in TelegramTradingBot.
- Disabled the copy trading monitor in MonitoringCoordinator to prevent blocking behavior.
- Updated logging to reflect the disabled state of the copy trading monitor.
Carles Sentis 5 天之前
父節點
當前提交
4e43e56f90
共有 3 個文件被更改,包括 18 次插入43 次删除
  1. 12 40
      src/bot/core.py
  2. 5 2
      src/monitoring/monitoring_coordinator.py
  3. 1 1
      trading_bot.py

+ 12 - 40
src/bot/core.py

@@ -31,7 +31,8 @@ from src.commands.info.risk import RiskCommands
 from src.commands.info.price import PriceCommands
 from src.commands.info.balance_adjustments import BalanceAdjustmentsCommands
 from src.commands.info.commands import CommandsInfo
-from src.commands.copy_trading_commands import CopyTradingCommands
+# DISABLE AGAIN: Copy trading still causing blocking issues
+# from src.commands.copy_trading_commands import CopyTradingCommands
 
 logger = logging.getLogger(__name__)
 
@@ -71,7 +72,8 @@ class TelegramTradingBot:
         self.price_cmds = PriceCommands(self.trading_engine, self.notification_manager)
         self.balance_adjustments_cmds = BalanceAdjustmentsCommands(self.trading_engine, self.notification_manager)
         self.commands_cmds = CommandsInfo(self.trading_engine, self.notification_manager)
-        self.copy_trading_cmds = CopyTradingCommands(self.monitoring_coordinator)
+        # DISABLE AGAIN: Copy trading still causing blocking issues
+        # self.copy_trading_cmds = CopyTradingCommands(self.monitoring_coordinator)
 
         # Create a class to hold all info commands
         class InfoCommandsHandler:
@@ -154,9 +156,6 @@ class TelegramTradingBot:
         self.application.add_handler(CommandHandler("commands", self.commands_cmds.commands_command))
         self.application.add_handler(CommandHandler("c", self.commands_cmds.commands_command))  # Alias
         
-        # Copy trading commands (single command with subcommands)
-        self.application.add_handler(CommandHandler("copy", self.copy_trading_cmds.copy_command))
-        
         # Management commands
         self.application.add_handler(CommandHandler("monitoring", self.management_commands.monitoring_command))
         self.application.add_handler(CommandHandler("alarm", self.management_commands.alarm_command))
@@ -172,7 +171,7 @@ class TelegramTradingBot:
         # Callback and message handlers
         self.application.add_handler(CallbackQueryHandler(self.trading_commands.button_callback))
         self.application.add_handler(MessageHandler(
-            filters.Regex(r'^(LONG|SHORT|EXIT|SL|TP|LEVERAGE|BALANCE|POSITIONS|ORDERS|STATS|MARKET|PERFORMANCE|DAILY|WEEKLY|MONTHLY|RISK|ALARM|MONITORING|LOGS|DEBUG|VERSION|COMMANDS|KEYBOARD|COO|COPY)'),
+            filters.Regex(r'^(LONG|SHORT|EXIT|SL|TP|LEVERAGE|BALANCE|POSITIONS|ORDERS|STATS|MARKET|PERFORMANCE|DAILY|WEEKLY|MONTHLY|RISK|ALARM|MONITORING|LOGS|DEBUG|VERSION|COMMANDS|KEYBOARD|COO)'),
             self.handle_keyboard_command
         ))
         
@@ -207,40 +206,23 @@ class TelegramTradingBot:
             "DEBUG": self.management_commands.debug_command,
             "VERSION": self.management_commands.version_command,
             "KEYBOARD": self.management_commands.keyboard_command,
-            "COPY": self._handle_copy_status_keyboard,
         }
 
         command_func = command_map.get(command_text)
         if command_func:
-            # For COPY command, handle specially
-            if command_text == "COPY":
-                await command_func(update, context)
-            else:
-                # We need to simulate a command call, so we'll prepend "/"
-                # to the message text to make it look like a real command.
-                original_text = update.message.text
-                update.message.text = f"/{original_text.lower()}"
-                await command_func(update, context)
-                # Restore original text
-                update.message.text = original_text
+            # We need to simulate a command call, so we'll prepend "/"
+            # to the message text to make it look like a real command.
+            original_text = update.message.text
+            update.message.text = f"/{original_text.lower()}"
+            await command_func(update, context)
+            # Restore original text
+            update.message.text = original_text
         else:
             logger.warning(f"Unknown keyboard command: {command_text}")
             await self.notification_manager.send_generic_notification(
                 f"Unknown command: {command_text}", chat_id=update.effective_chat.id
             )
 
-    async def _handle_copy_status_keyboard(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
-        """Handle COPY keyboard command by showing copy trading status."""
-        # Create a mock context with status args to avoid modifying original
-        from types import SimpleNamespace
-        
-        # Create a simple object that mimics the context for copy commands
-        mock_context = SimpleNamespace()
-        mock_context.args = ["status"]
-        mock_context.bot = context.bot
-        
-        await self.copy_trading_cmds.copy_command(update, mock_context)
-
     async def start_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
         """Handle the /start command."""
         logger.info(f"/start command triggered by chat_id: {update.effective_chat.id}")
@@ -313,11 +295,6 @@ class TelegramTradingBot:
 • /alarm {Config.DEFAULT_TRADING_TOKEN} - Show all {Config.DEFAULT_TRADING_TOKEN} alarms
 • /alarm 3 - Remove alarm ID 3
 
-<b>🔄 Copy Trading:</b>
-• /copy status - View copy trading status & configuration
-• /copy start [address] - Start copying a target trader's positions
-• /copy stop - Stop copy trading (session data preserved)
-
 <b>🔄 Automatic Monitoring:</b>
 • Real-time order fill alerts
 • Position opened/closed notifications  
@@ -413,11 +390,6 @@ For support, contact your bot administrator.
 • /debug - Bot internal state (troubleshooting)
 • /sync force - Clear local data and resync with exchange
 
-🔄 <b>Copy Trading:</b>
-• /copy status - View copy trading status & configuration
-• /copy start [address] - Start copying a target trader's positions
-• /copy stop - Stop copy trading (session data preserved)
-
 For support or issues, check the logs or contact the administrator.
         """
         

+ 5 - 2
src/monitoring/monitoring_coordinator.py

@@ -43,8 +43,11 @@ class MonitoringCoordinator:
         # Initialize copy trading monitor if available
         if COPY_TRADING_AVAILABLE:
             try:
-                self.copy_trading_monitor = CopyTradingMonitor(hl_client, notification_manager)
-                logger.info("✅ Copy trading monitor initialized (with non-blocking state manager)")
+                # DISABLE AGAIN: Still causing blocking issues
+                # self.copy_trading_monitor = CopyTradingMonitor(hl_client, notification_manager)
+                # logger.info("✅ Copy trading monitor initialized (with non-blocking state manager)")
+                self.copy_trading_monitor = None
+                logger.info("🚫 Copy trading monitor disabled - still causing blocking")
             except Exception as e:
                 logger.error(f"❌ Failed to initialize copy trading monitor: {e}")
                 self.copy_trading_monitor = None

+ 1 - 1
trading_bot.py

@@ -14,7 +14,7 @@ from datetime import datetime
 from pathlib import Path
 
 # Bot version
-BOT_VERSION = "3.0.322"
+BOT_VERSION = "3.0.323"
 
 # Add src directory to Python path
 sys.path.insert(0, str(Path(__file__).parent / "src"))