|
@@ -31,8 +31,7 @@ from src.commands.info.risk import RiskCommands
|
|
from src.commands.info.price import PriceCommands
|
|
from src.commands.info.price import PriceCommands
|
|
from src.commands.info.balance_adjustments import BalanceAdjustmentsCommands
|
|
from src.commands.info.balance_adjustments import BalanceAdjustmentsCommands
|
|
from src.commands.info.commands import CommandsInfo
|
|
from src.commands.info.commands import CommandsInfo
|
|
-# TEMPORARY: Disable copy trading commands to prevent blocking I/O
|
|
|
|
-# from src.commands.copy_trading_commands import CopyTradingCommands
|
|
|
|
|
|
+from src.commands.copy_trading_commands import CopyTradingCommands
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@@ -72,8 +71,7 @@ class TelegramTradingBot:
|
|
self.price_cmds = PriceCommands(self.trading_engine, self.notification_manager)
|
|
self.price_cmds = PriceCommands(self.trading_engine, self.notification_manager)
|
|
self.balance_adjustments_cmds = BalanceAdjustmentsCommands(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.commands_cmds = CommandsInfo(self.trading_engine, self.notification_manager)
|
|
- # TEMPORARY: Disable copy trading commands to prevent blocking I/O
|
|
|
|
- # self.copy_trading_cmds = CopyTradingCommands(self.monitoring_coordinator)
|
|
|
|
|
|
+ self.copy_trading_cmds = CopyTradingCommands(self.monitoring_coordinator)
|
|
|
|
|
|
# Create a class to hold all info commands
|
|
# Create a class to hold all info commands
|
|
class InfoCommandsHandler:
|
|
class InfoCommandsHandler:
|
|
@@ -156,6 +154,9 @@ class TelegramTradingBot:
|
|
self.application.add_handler(CommandHandler("commands", self.commands_cmds.commands_command))
|
|
self.application.add_handler(CommandHandler("commands", self.commands_cmds.commands_command))
|
|
self.application.add_handler(CommandHandler("c", self.commands_cmds.commands_command)) # Alias
|
|
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
|
|
# Management commands
|
|
self.application.add_handler(CommandHandler("monitoring", self.management_commands.monitoring_command))
|
|
self.application.add_handler(CommandHandler("monitoring", self.management_commands.monitoring_command))
|
|
self.application.add_handler(CommandHandler("alarm", self.management_commands.alarm_command))
|
|
self.application.add_handler(CommandHandler("alarm", self.management_commands.alarm_command))
|
|
@@ -171,7 +172,7 @@ class TelegramTradingBot:
|
|
# Callback and message handlers
|
|
# Callback and message handlers
|
|
self.application.add_handler(CallbackQueryHandler(self.trading_commands.button_callback))
|
|
self.application.add_handler(CallbackQueryHandler(self.trading_commands.button_callback))
|
|
self.application.add_handler(MessageHandler(
|
|
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)'),
|
|
|
|
|
|
+ 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)'),
|
|
self.handle_keyboard_command
|
|
self.handle_keyboard_command
|
|
))
|
|
))
|
|
|
|
|
|
@@ -206,6 +207,7 @@ class TelegramTradingBot:
|
|
"DEBUG": self.management_commands.debug_command,
|
|
"DEBUG": self.management_commands.debug_command,
|
|
"VERSION": self.management_commands.version_command,
|
|
"VERSION": self.management_commands.version_command,
|
|
"KEYBOARD": self.management_commands.keyboard_command,
|
|
"KEYBOARD": self.management_commands.keyboard_command,
|
|
|
|
+ "COPY": self._handle_copy_status_keyboard,
|
|
}
|
|
}
|
|
|
|
|
|
command_func = command_map.get(command_text)
|
|
command_func = command_map.get(command_text)
|
|
@@ -221,6 +223,12 @@ class TelegramTradingBot:
|
|
f"Unknown command: {command_text}", chat_id=update.effective_chat.id
|
|
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."""
|
|
|
|
+ # Set context.args to simulate /copy status
|
|
|
|
+ context.args = ["status"]
|
|
|
|
+ await self.copy_trading_cmds.copy_command(update, context)
|
|
|
|
+
|
|
async def start_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
async def start_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
"""Handle the /start command."""
|
|
"""Handle the /start command."""
|
|
logger.info(f"/start command triggered by chat_id: {update.effective_chat.id}")
|
|
logger.info(f"/start command triggered by chat_id: {update.effective_chat.id}")
|
|
@@ -294,9 +302,9 @@ class TelegramTradingBot:
|
|
• /alarm 3 - Remove alarm ID 3
|
|
• /alarm 3 - Remove alarm ID 3
|
|
|
|
|
|
<b>🔄 Copy Trading:</b>
|
|
<b>🔄 Copy Trading:</b>
|
|
-• /copy_status - View copy trading status & session info
|
|
|
|
-• /copy_start [address] - Start copying a target trader
|
|
|
|
-• /copy_stop - Stop copy trading (preserves session)
|
|
|
|
|
|
+• /copy status - View copy trading status & session info
|
|
|
|
+• /copy start [address] - Start copying a target trader
|
|
|
|
+• /copy stop - Stop copy trading (preserves session)
|
|
|
|
|
|
<b>🔄 Automatic Monitoring:</b>
|
|
<b>🔄 Automatic Monitoring:</b>
|
|
• Real-time order fill alerts
|
|
• Real-time order fill alerts
|
|
@@ -394,9 +402,9 @@ For support, contact your bot administrator.
|
|
• /sync force - Clear local data and resync with exchange
|
|
• /sync force - Clear local data and resync with exchange
|
|
|
|
|
|
🔄 <b>Copy Trading:</b>
|
|
🔄 <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)
|
|
|
|
|
|
+• /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.
|
|
For support or issues, check the logs or contact the administrator.
|
|
"""
|
|
"""
|