Browse Source

Increment BOT_VERSION to 2.2.150 and enhance notification messages for market orders.

- Updated BOT_VERSION for the upcoming release.
- Improved notification messages in NotificationManager to handle cases where the price is not known, providing clearer communication for market orders.
- Ensured consistent formatting for both LONG and SHORT position notifications, enhancing user experience.
Carles Sentis 22 hours ago
parent
commit
5705bf03c3
2 changed files with 34 additions and 16 deletions
  1. 33 15
      src/notifications/notification_manager.py
  2. 1 1
      trading_bot.py

+ 33 - 15
src/notifications/notification_manager.py

@@ -28,16 +28,25 @@ class NotificationManager:
             # Use TokenDisplayFormatter for consistent formatting
             formatter = get_formatter() # Get formatter
             
-            price_str = formatter.format_price_with_symbol(price, token)
             amount_str = formatter.format_amount(amount, token)
-            value_str = formatter.format_price_with_symbol(amount * price, token)
             order_id_str = order_details.get('id', 'N/A')
             
-            message = (
-                f"✅ Successfully opened <b>LONG</b> position for {amount_str} {token} at ~{price_str}\n\n"
-                f"💰 Value: {value_str}\n"
-                f"🆔 Order ID: <code>{order_id_str}</code>"
-            )
+            if price is not None:
+                price_str = formatter.format_price_with_symbol(price, token)
+                value_str = formatter.format_price_with_symbol(amount * price, token)
+                message = (
+                    f"✅ Successfully opened <b>LONG</b> position for {amount_str} {token} at ~{price_str}\n\n"
+                    f"💰 Value: {value_str}\n"
+                    f"🆔 Order ID: <code>{order_id_str}</code>"
+                )
+            else:
+                # Handle market order where price is not known yet
+                message = (
+                    f"✅ Successfully submitted <b>LONG</b> market order for {amount_str} {token}.\n\n"
+                    f"⏳ Awaiting fill confirmation for final price and value.\n"
+                    f"🆔 Order ID: <code>{order_id_str}</code>"
+                )
+
             if trade_lifecycle_id:
                 message += f"\n🆔 Lifecycle ID: <code>{trade_lifecycle_id[:8]}...</code>"
 
@@ -54,16 +63,25 @@ class NotificationManager:
         try:
             formatter = get_formatter() # Get formatter
             
-            price_str = formatter.format_price_with_symbol(price, token)
             amount_str = formatter.format_amount(amount, token)
-            value_str = formatter.format_price_with_symbol(amount * price, token)
             order_id_str = order_details.get('id', 'N/A')
-            
-            message = (
-                f"✅ Successfully opened <b>SHORT</b> position for {amount_str} {token} at ~{price_str}\n\n"
-                f"💰 Value: {value_str}\n"
-                f"🆔 Order ID: <code>{order_id_str}</code>"
-            )
+
+            if price is not None:
+                price_str = formatter.format_price_with_symbol(price, token)
+                value_str = formatter.format_price_with_symbol(amount * price, token)
+                message = (
+                    f"✅ Successfully opened <b>SHORT</b> position for {amount_str} {token} at ~{price_str}\n\n"
+                    f"💰 Value: {value_str}\n"
+                    f"🆔 Order ID: <code>{order_id_str}</code>"
+                )
+            else:
+                # Handle market order where price is not known yet
+                message = (
+                    f"✅ Successfully submitted <b>SHORT</b> market order for {amount_str} {token}.\n\n"
+                    f"⏳ Awaiting fill confirmation for final price and value.\n"
+                    f"🆔 Order ID: <code>{order_id_str}</code>"
+                )
+
             if trade_lifecycle_id:
                 message += f"\n🆔 Lifecycle ID: <code>{trade_lifecycle_id[:8]}...</code>"
 

+ 1 - 1
trading_bot.py

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