|
@@ -49,7 +49,9 @@ class TradingEngine:
|
|
|
|
|
|
async def async_init(self):
|
|
async def async_init(self):
|
|
"""Asynchronously initialize the trading engine components."""
|
|
"""Asynchronously initialize the trading engine components."""
|
|
|
|
+ logger.info("🚀 Starting asynchronous initialization of TradingEngine...")
|
|
await self._initialize_stats_async()
|
|
await self._initialize_stats_async()
|
|
|
|
+ logger.info("✅ Asynchronous initialization of TradingEngine complete.")
|
|
|
|
|
|
async def _initialize_stats_async(self):
|
|
async def _initialize_stats_async(self):
|
|
"""Fetch initial data asynchronously after the loop has started."""
|
|
"""Fetch initial data asynchronously after the loop has started."""
|
|
@@ -62,9 +64,10 @@ class TradingEngine:
|
|
balance = self.client.get_balance()
|
|
balance = self.client.get_balance()
|
|
if balance and balance.get('total'):
|
|
if balance and balance.get('total'):
|
|
usdc_balance = float(balance['total'].get('USDC', 0))
|
|
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:
|
|
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):
|
|
def set_market_monitor(self, market_monitor):
|
|
"""Set the market monitor reference for accessing cached data."""
|
|
"""Set the market monitor reference for accessing cached data."""
|