Browse Source

Update trading bot version and enhance stats handling in management commands

- Incremented bot version to 3.0.316.
- Improved handling of trading statistics by ensuring all required keys exist with safe defaults.
- Updated the display of trading stats to use the new variable assignments for better clarity and maintainability.
Carles Sentis 5 ngày trước cách đây
mục cha
commit
8abd74402e
2 tập tin đã thay đổi với 15 bổ sung7 xóa
  1. 14 6
      src/commands/management_commands.py
  2. 1 1
      trading_bot.py

+ 14 - 6
src/commands/management_commands.py

@@ -461,14 +461,22 @@ Will trigger when {token} price moves {alarm['direction']} {target_price_str}
             stats = self.trading_engine.get_stats()
             if stats:
                 basic_stats = stats.get_basic_stats()
+                # Ensure all required keys exist with safe defaults
+                total_trades = basic_stats.get('total_trades', 0)
+                completed_trades = basic_stats.get('completed_trades', 0)
+                days_active = basic_stats.get('days_active', 0)
+                start_date = basic_stats.get('start_date', 'Unknown')
             else:
-                basic_stats = {'total_trades': 0, 'completed_trades': 0, 'days_active': 0, 'start_date': 'Unknown'}
+                total_trades = 0
+                completed_trades = 0
+                days_active = 0
+                start_date = 'Unknown'
             
             version_text = f"""
 🤖 <b>Trading Bot Version & System Info</b>
 
 📱 <b>Bot Information:</b>
-• Version: <code>2.1.2</code>
+• Version: <code>3.0.316</code>
 • Network: {'Testnet' if Config.HYPERLIQUID_TESTNET else 'Mainnet'}
 • Uptime: {uptime_info}
 • Default Token: {Config.DEFAULT_TRADING_TOKEN}
@@ -479,10 +487,10 @@ Will trigger when {token} price moves {alarm['direction']} {target_price_str}
 • Architecture: {platform.machine()}
 
 📊 <b>Trading Stats:</b>
-• Total Orders: {basic_stats['total_trades']}
-• Completed Trades: {basic_stats['completed_trades']}
-• Days Active: {basic_stats['days_active']}
-• Start Date: {basic_stats['start_date']}
+• Total Orders: {total_trades}
+• Completed Trades: {completed_trades}
+• Days Active: {days_active}
+• Start Date: {start_date}
 
 🔄 <b>Monitoring Status:</b>
 • Monitoring System: {'✅ Active' if monitoring_active else '❌ Inactive'}

+ 1 - 1
trading_bot.py

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