|
@@ -23,13 +23,19 @@ class NotificationManager:
|
|
async def send_long_success_notification(self, query, token: str, token_amount: float,
|
|
async def send_long_success_notification(self, query, token: str, token_amount: float,
|
|
actual_price: float, order: Dict[str, Any],
|
|
actual_price: float, order: Dict[str, Any],
|
|
stop_loss_price: Optional[float] = None):
|
|
stop_loss_price: Optional[float] = None):
|
|
- """Send notification for successful long order."""
|
|
|
|
|
|
+ """Send notification for successful long order placement."""
|
|
order_id = order.get('id', 'N/A')
|
|
order_id = order.get('id', 'N/A')
|
|
- order_type = "Market" if not order.get('price') else "Limit"
|
|
|
|
|
|
+ order_type = order.get('type', 'Unknown').title()
|
|
|
|
+
|
|
|
|
+ # Handle None actual_price for market orders
|
|
|
|
+ if actual_price is None:
|
|
|
|
+ actual_price = 0.0
|
|
|
|
+ price_display = "Market Price"
|
|
|
|
+ price_value = "TBD"
|
|
|
|
+ else:
|
|
|
|
+ price_display = "Limit Price" if order_type == "Limit" else "Est. Price"
|
|
|
|
+ price_value = f"${actual_price:,.2f}"
|
|
|
|
|
|
- # 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"
|
|
status_message = "ORDER PLACED" if order_type == "Limit" else "ORDER SUBMITTED"
|
|
|
|
|
|
success_message = f"""
|
|
success_message = f"""
|
|
@@ -39,12 +45,20 @@ class NotificationManager:
|
|
• Token: {token}
|
|
• Token: {token}
|
|
• Direction: LONG (Buy)
|
|
• Direction: LONG (Buy)
|
|
• Amount: {token_amount:.6f} {token}
|
|
• Amount: {token_amount:.6f} {token}
|
|
-• {price_label}: ${actual_price:,.2f}
|
|
|
|
|
|
+• {price_display}: {price_value}
|
|
• Order Type: {order_type}
|
|
• Order Type: {order_type}
|
|
• Order ID: <code>{order_id}</code>
|
|
• Order ID: <code>{order_id}</code>
|
|
|
|
|
|
-💰 <b>Order Summary:</b>
|
|
|
|
-• Order Value: ${token_amount * actual_price:,.2f}
|
|
|
|
|
|
+💰 <b>Order Summary:</b>"""
|
|
|
|
+
|
|
|
|
+ if actual_price > 0:
|
|
|
|
+ success_message += f"""
|
|
|
|
+• Order Value: ${token_amount * actual_price:,.2f}"""
|
|
|
|
+ else:
|
|
|
|
+ success_message += f"""
|
|
|
|
+• Order Value: Market execution"""
|
|
|
|
+
|
|
|
|
+ success_message += f"""
|
|
• Status: {status_message} ✅
|
|
• Status: {status_message} ✅
|
|
• Time: {datetime.now().strftime('%H:%M:%S')}"""
|
|
• Time: {datetime.now().strftime('%H:%M:%S')}"""
|
|
|
|
|
|
@@ -57,7 +71,7 @@ class NotificationManager:
|
|
success_message += f"""
|
|
success_message += f"""
|
|
|
|
|
|
💡 <b>Note:</b> Limit order placed on exchange
|
|
💡 <b>Note:</b> Limit order placed on exchange
|
|
-• Will fill when market price reaches ${actual_price:,.2f}"""
|
|
|
|
|
|
+• Will fill when market price reaches {price_value}"""
|
|
|
|
|
|
if stop_loss_price:
|
|
if stop_loss_price:
|
|
success_message += f"""
|
|
success_message += f"""
|
|
@@ -76,18 +90,26 @@ class NotificationManager:
|
|
"""
|
|
"""
|
|
|
|
|
|
await query.edit_message_text(success_message, parse_mode='HTML')
|
|
await query.edit_message_text(success_message, parse_mode='HTML')
|
|
- logger.info(f"Long order placed: {token_amount:.6f} {token} @ ${actual_price:,.2f} ({order_type})")
|
|
|
|
|
|
+
|
|
|
|
+ log_price = f"${actual_price:,.2f}" if actual_price > 0 else "Market"
|
|
|
|
+ logger.info(f"Long order placed: {token_amount:.6f} {token} @ {log_price} ({order_type})")
|
|
|
|
|
|
async def send_short_success_notification(self, query, token: str, token_amount: float,
|
|
async def send_short_success_notification(self, query, token: str, token_amount: float,
|
|
actual_price: float, order: Dict[str, Any],
|
|
actual_price: float, order: Dict[str, Any],
|
|
stop_loss_price: Optional[float] = None):
|
|
stop_loss_price: Optional[float] = None):
|
|
- """Send notification for successful short order."""
|
|
|
|
|
|
+ """Send notification for successful short order placement."""
|
|
order_id = order.get('id', 'N/A')
|
|
order_id = order.get('id', 'N/A')
|
|
- order_type = "Market" if not order.get('price') else "Limit"
|
|
|
|
|
|
+ order_type = order.get('type', 'Unknown').title()
|
|
|
|
+
|
|
|
|
+ # Handle None actual_price for market orders
|
|
|
|
+ if actual_price is None:
|
|
|
|
+ actual_price = 0.0
|
|
|
|
+ price_display = "Market Price"
|
|
|
|
+ price_value = "TBD"
|
|
|
|
+ else:
|
|
|
|
+ price_display = "Limit Price" if order_type == "Limit" else "Est. Price"
|
|
|
|
+ price_value = f"${actual_price:,.2f}"
|
|
|
|
|
|
- # 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"
|
|
status_message = "ORDER PLACED" if order_type == "Limit" else "ORDER SUBMITTED"
|
|
|
|
|
|
success_message = f"""
|
|
success_message = f"""
|
|
@@ -97,12 +119,20 @@ class NotificationManager:
|
|
• Token: {token}
|
|
• Token: {token}
|
|
• Direction: SHORT (Sell)
|
|
• Direction: SHORT (Sell)
|
|
• Amount: {token_amount:.6f} {token}
|
|
• Amount: {token_amount:.6f} {token}
|
|
-• {price_label}: ${actual_price:,.2f}
|
|
|
|
|
|
+• {price_display}: {price_value}
|
|
• Order Type: {order_type}
|
|
• Order Type: {order_type}
|
|
• Order ID: <code>{order_id}</code>
|
|
• Order ID: <code>{order_id}</code>
|
|
|
|
|
|
-💰 <b>Order Summary:</b>
|
|
|
|
-• Order Value: ${token_amount * actual_price:,.2f}
|
|
|
|
|
|
+💰 <b>Order Summary:</b>"""
|
|
|
|
+
|
|
|
|
+ if actual_price > 0:
|
|
|
|
+ success_message += f"""
|
|
|
|
+• Order Value: ${token_amount * actual_price:,.2f}"""
|
|
|
|
+ else:
|
|
|
|
+ success_message += f"""
|
|
|
|
+• Order Value: Market execution"""
|
|
|
|
+
|
|
|
|
+ success_message += f"""
|
|
• Status: {status_message} ✅
|
|
• Status: {status_message} ✅
|
|
• Time: {datetime.now().strftime('%H:%M:%S')}"""
|
|
• Time: {datetime.now().strftime('%H:%M:%S')}"""
|
|
|
|
|
|
@@ -115,7 +145,7 @@ class NotificationManager:
|
|
success_message += f"""
|
|
success_message += f"""
|
|
|
|
|
|
💡 <b>Note:</b> Limit order placed on exchange
|
|
💡 <b>Note:</b> Limit order placed on exchange
|
|
-• Will fill when market price reaches ${actual_price:,.2f}"""
|
|
|
|
|
|
+• Will fill when market price reaches {price_value}"""
|
|
|
|
|
|
if stop_loss_price:
|
|
if stop_loss_price:
|
|
success_message += f"""
|
|
success_message += f"""
|
|
@@ -134,7 +164,9 @@ class NotificationManager:
|
|
"""
|
|
"""
|
|
|
|
|
|
await query.edit_message_text(success_message, parse_mode='HTML')
|
|
await query.edit_message_text(success_message, parse_mode='HTML')
|
|
- logger.info(f"Short order placed: {token_amount:.6f} {token} @ ${actual_price:,.2f} ({order_type})")
|
|
|
|
|
|
+
|
|
|
|
+ log_price = f"${actual_price:,.2f}" if actual_price > 0 else "Market"
|
|
|
|
+ logger.info(f"Short order placed: {token_amount:.6f} {token} @ {log_price} ({order_type})")
|
|
|
|
|
|
async def send_exit_success_notification(self, query, token: str, position_type: str,
|
|
async def send_exit_success_notification(self, query, token: str, position_type: str,
|
|
contracts: float, actual_price: float,
|
|
contracts: float, actual_price: float,
|