|
@@ -27,29 +27,56 @@ class NotificationManager:
|
|
|
order_id = order.get('id', 'N/A')
|
|
|
order_type = "Market" if not order.get('price') else "Limit"
|
|
|
|
|
|
+ # For the new system, actual_price is the requested price for limit orders
|
|
|
+ # or estimated price for market orders
|
|
|
+ price_label = "Limit Price" if order_type == "Limit" else "Est. Price"
|
|
|
+ status_message = "ORDER PLACED" if order_type == "Limit" else "ORDER SUBMITTED"
|
|
|
+
|
|
|
success_message = f"""
|
|
|
-✅ <b>Long Position Opened Successfully!</b>
|
|
|
+✅ <b>Long Order Placed Successfully!</b>
|
|
|
|
|
|
📊 <b>Order Details:</b>
|
|
|
• Token: {token}
|
|
|
• Direction: LONG (Buy)
|
|
|
• Amount: {token_amount:.6f} {token}
|
|
|
-• Entry Price: ${actual_price:,.2f}
|
|
|
+• {price_label}: ${actual_price:,.2f}
|
|
|
• Order Type: {order_type}
|
|
|
• Order ID: <code>{order_id}</code>
|
|
|
|
|
|
-💰 <b>Trade Summary:</b>
|
|
|
-• Position Value: ${token_amount * actual_price:,.2f}
|
|
|
-• Status: FILLED ✅
|
|
|
-• Time: {datetime.now().strftime('%H:%M:%S')}
|
|
|
+💰 <b>Order Summary:</b>
|
|
|
+• Order Value: ${token_amount * actual_price:,.2f}
|
|
|
+• Status: {status_message} ✅
|
|
|
+• Time: {datetime.now().strftime('%H:%M:%S')}"""
|
|
|
+
|
|
|
+ if order_type == "Market":
|
|
|
+ success_message += f"""
|
|
|
+
|
|
|
+💡 <b>Note:</b> Market order submitted for execution
|
|
|
+• Actual fill price will be determined by market"""
|
|
|
+ else:
|
|
|
+ success_message += f"""
|
|
|
+
|
|
|
+💡 <b>Note:</b> Limit order placed on exchange
|
|
|
+• Will fill when market price reaches ${actual_price:,.2f}"""
|
|
|
+
|
|
|
+ if stop_loss_price:
|
|
|
+ success_message += f"""
|
|
|
+
|
|
|
+🛑 <b>Pending Stop Loss:</b> ${stop_loss_price:,.2f}
|
|
|
+• Status: Will activate when main order fills
|
|
|
+• Protection: Automatic position closure"""
|
|
|
+ else:
|
|
|
+ success_message += f"""
|
|
|
|
|
|
-{f"🛑 <b>Pending Stop Loss:</b> ${stop_loss_price:,.2f}\n• Status: Will activate when order fills\n• Protection: Automatic position closure" if stop_loss_price else "💡 Consider setting a stop loss with /sl {token} [price]"}
|
|
|
+💡 Consider setting a stop loss with /sl {token} [price] after order fills"""
|
|
|
+
|
|
|
+ success_message += f"""
|
|
|
|
|
|
-📊 Use /positions to view your open positions.
|
|
|
+📊 Use /orders to monitor order status | /positions to view positions
|
|
|
"""
|
|
|
|
|
|
await query.edit_message_text(success_message, parse_mode='HTML')
|
|
|
- logger.info(f"Long order executed: {token_amount:.6f} {token} @ ${actual_price:,.2f}")
|
|
|
+ logger.info(f"Long order placed: {token_amount:.6f} {token} @ ${actual_price:,.2f} ({order_type})")
|
|
|
|
|
|
async def send_short_success_notification(self, query, token: str, token_amount: float,
|
|
|
actual_price: float, order: Dict[str, Any],
|
|
@@ -58,29 +85,56 @@ class NotificationManager:
|
|
|
order_id = order.get('id', 'N/A')
|
|
|
order_type = "Market" if not order.get('price') else "Limit"
|
|
|
|
|
|
+ # For the new system, actual_price is the requested price for limit orders
|
|
|
+ # or estimated price for market orders
|
|
|
+ price_label = "Limit Price" if order_type == "Limit" else "Est. Price"
|
|
|
+ status_message = "ORDER PLACED" if order_type == "Limit" else "ORDER SUBMITTED"
|
|
|
+
|
|
|
success_message = f"""
|
|
|
-✅ <b>Short Position Opened Successfully!</b>
|
|
|
+✅ <b>Short Order Placed Successfully!</b>
|
|
|
|
|
|
📊 <b>Order Details:</b>
|
|
|
• Token: {token}
|
|
|
• Direction: SHORT (Sell)
|
|
|
• Amount: {token_amount:.6f} {token}
|
|
|
-• Entry Price: ${actual_price:,.2f}
|
|
|
+• {price_label}: ${actual_price:,.2f}
|
|
|
• Order Type: {order_type}
|
|
|
• Order ID: <code>{order_id}</code>
|
|
|
|
|
|
-💰 <b>Trade Summary:</b>
|
|
|
-• Position Value: ${token_amount * actual_price:,.2f}
|
|
|
-• Status: FILLED ✅
|
|
|
-• Time: {datetime.now().strftime('%H:%M:%S')}
|
|
|
+💰 <b>Order Summary:</b>
|
|
|
+• Order Value: ${token_amount * actual_price:,.2f}
|
|
|
+• Status: {status_message} ✅
|
|
|
+• Time: {datetime.now().strftime('%H:%M:%S')}"""
|
|
|
+
|
|
|
+ if order_type == "Market":
|
|
|
+ success_message += f"""
|
|
|
+
|
|
|
+💡 <b>Note:</b> Market order submitted for execution
|
|
|
+• Actual fill price will be determined by market"""
|
|
|
+ else:
|
|
|
+ success_message += f"""
|
|
|
|
|
|
-{f"🛑 <b>Pending Stop Loss:</b> ${stop_loss_price:,.2f}\n• Status: Will activate when order fills\n• Protection: Automatic position closure" if stop_loss_price else "💡 Consider setting a stop loss with /sl {token} [price]"}
|
|
|
+💡 <b>Note:</b> Limit order placed on exchange
|
|
|
+• Will fill when market price reaches ${actual_price:,.2f}"""
|
|
|
+
|
|
|
+ if stop_loss_price:
|
|
|
+ success_message += f"""
|
|
|
|
|
|
-📊 Use /positions to view your open positions.
|
|
|
+🛑 <b>Pending Stop Loss:</b> ${stop_loss_price:,.2f}
|
|
|
+• Status: Will activate when main order fills
|
|
|
+• Protection: Automatic position closure"""
|
|
|
+ else:
|
|
|
+ success_message += f"""
|
|
|
+
|
|
|
+💡 Consider setting a stop loss with /sl {token} [price] after order fills"""
|
|
|
+
|
|
|
+ success_message += f"""
|
|
|
+
|
|
|
+📊 Use /orders to monitor order status | /positions to view positions
|
|
|
"""
|
|
|
|
|
|
await query.edit_message_text(success_message, parse_mode='HTML')
|
|
|
- logger.info(f"Short order executed: {token_amount:.6f} {token} @ ${actual_price:,.2f}")
|
|
|
+ logger.info(f"Short order placed: {token_amount:.6f} {token} @ ${actual_price:,.2f} ({order_type})")
|
|
|
|
|
|
async def send_exit_success_notification(self, query, token: str, position_type: str,
|
|
|
contracts: float, actual_price: float,
|
|
@@ -93,16 +147,32 @@ class NotificationManager:
|
|
|
# Check if stop losses were cancelled
|
|
|
cancelled_sls = order.get('cancelled_stop_losses', 0)
|
|
|
|
|
|
+ # Check if this is a market order without actual price yet
|
|
|
+ is_market_order_pending = actual_price == 0
|
|
|
+
|
|
|
success_message = f"""
|
|
|
-✅ <b>{position_type} Position Closed Successfully!</b>
|
|
|
+✅ <b>{position_type} Position Exit Order Placed!</b>
|
|
|
|
|
|
📊 <b>Exit Details:</b>
|
|
|
• Token: {token}
|
|
|
• Position: {position_type}
|
|
|
• Action: {action} (Close)
|
|
|
• Amount: {contracts:.6f} {token}
|
|
|
+• Order Type: Market Order
|
|
|
+• Order ID: <code>{order_id}</code>"""
|
|
|
+
|
|
|
+ if is_market_order_pending:
|
|
|
+ success_message += f"""
|
|
|
+
|
|
|
+⏳ <b>Order Status:</b>
|
|
|
+• Status: SUBMITTED ✅
|
|
|
+• Execution: Pending market fill
|
|
|
+• Time: {datetime.now().strftime('%H:%M:%S')}
|
|
|
+
|
|
|
+💡 <b>Note:</b> Actual execution price and P&L will be shown when the order fills."""
|
|
|
+ else:
|
|
|
+ success_message += f"""
|
|
|
• Exit Price: ${actual_price:,.2f}
|
|
|
-• Order ID: <code>{order_id}</code>
|
|
|
|
|
|
💰 <b>Trade Summary:</b>
|
|
|
• Exit Value: ${contracts * actual_price:,.2f}
|
|
@@ -117,14 +187,26 @@ class NotificationManager:
|
|
|
• Cancelled {cancelled_sls} pending stop loss order(s)
|
|
|
• All protective orders removed"""
|
|
|
|
|
|
- success_message += f"""
|
|
|
+ if is_market_order_pending:
|
|
|
+ success_message += f"""
|
|
|
+
|
|
|
+📊 Position exit order submitted successfully
|
|
|
+💡 Use /orders to monitor order status"""
|
|
|
+ else:
|
|
|
+ success_message += f"""
|
|
|
|
|
|
📊 <b>Result:</b> Position fully closed
|
|
|
-💡 Use /stats to view updated performance metrics.
|
|
|
- """
|
|
|
+💡 Use /stats to view updated performance metrics."""
|
|
|
|
|
|
await query.edit_message_text(success_message, parse_mode='HTML')
|
|
|
- logger.info(f"Exit order executed: {contracts:.6f} {token} @ ${actual_price:,.2f} (P&L: ${pnl:,.2f}){f' | Cancelled {cancelled_sls} SLs' if cancelled_sls > 0 else ''}")
|
|
|
+
|
|
|
+ log_message = f"Exit order placed: {contracts:.6f} {token}"
|
|
|
+ if not is_market_order_pending:
|
|
|
+ log_message += f" @ ${actual_price:,.2f} (P&L: ${pnl:,.2f})"
|
|
|
+ if cancelled_sls > 0:
|
|
|
+ log_message += f" | Cancelled {cancelled_sls} SLs"
|
|
|
+
|
|
|
+ logger.info(log_message)
|
|
|
|
|
|
async def send_sl_success_notification(self, query, token: str, position_type: str,
|
|
|
contracts: float, stop_price: float,
|