Эх сурвалжийг харах

Increment BOT_VERSION to 2.2.148 and enhance price formatting in TokenDisplayFormatter.

- Updated BOT_VERSION for the upcoming release.
- Added handling for None price values in the format_price method, returning "N/A" for better user experience.
- Improved error handling in price formatting to ensure graceful fallbacks in case of formatting failures.
Carles Sentis 2 өдөр өмнө
parent
commit
ef5602bf16

+ 9 - 1
src/utils/token_display_formatter.py

@@ -156,6 +156,9 @@ class TokenDisplayFormatter:
         """
         Format a price with appropriate decimal places.
         """
+        if price is None:
+            return "N/A"  # Handle None price gracefully
+
         try:
             decimal_places = 2 # Default if no token
             if token:
@@ -172,7 +175,12 @@ class TokenDisplayFormatter:
             return f"{price:,.{decimal_places}f}"
         except Exception as e:
             logger.error(f"❌ Error formatting price {price} for {token}: {e}")
-            return f"{price:,.2f}"
+            # Fallback for other errors, assuming price is not None here due to the check above
+            # If it could still be an issue, provide a very basic fallback.
+            try:
+                return f"{price:,.2f}"
+            except: # Final fallback if even basic formatting fails
+                return str(price) # Convert to string as last resort
 
     def format_price_with_symbol(self, price: float, token: str = None) -> str:
         """

+ 1 - 1
trading_bot.py

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