소스 검색

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 3 주 전
부모
커밋
41bf441177
2개의 변경된 파일6개의 추가작업 그리고 3개의 파일을 삭제
  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"))