Explorar o código

Enhance asynchronous initialization in TradingEngine with improved logging. Added start and completion logs for async initialization and updated error logging to include exception details when setting the initial balance.

Carles Sentis hai 4 días
pai
achega
41bf441177
Modificáronse 2 ficheiros con 6 adicións e 3 borrados
  1. 5 2
      src/trading/trading_engine.py
  2. 1 1
      trading_bot.py

+ 5 - 2
src/trading/trading_engine.py

@@ -49,7 +49,9 @@ class TradingEngine:
             
     async def async_init(self):
         """Asynchronously initialize the trading engine components."""
+        logger.info("🚀 Starting asynchronous initialization of TradingEngine...")
         await self._initialize_stats_async()
+        logger.info("✅ Asynchronous initialization of TradingEngine complete.")
 
     async def _initialize_stats_async(self):
         """Fetch initial data asynchronously after the loop has started."""
@@ -62,9 +64,10 @@ class TradingEngine:
             balance = self.client.get_balance()
             if balance and balance.get('total'):
                 usdc_balance = float(balance['total'].get('USDC', 0))
-                await self.stats.set_initial_balance(usdc_balance)
+                # The set_initial_balance method is synchronous
+                self.stats.set_initial_balance(usdc_balance)
         except Exception as e:
-            logger.error(f"Could not set initial balance during async init: {e}")
+            logger.error(f"Could not set initial balance during async init: {e}", exc_info=True)
     
     def set_market_monitor(self, market_monitor):
         """Set the market monitor reference for accessing cached data."""

+ 1 - 1
trading_bot.py

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