stability
This commit is contained in:
@ -74,6 +74,11 @@ class COBIntegration:
|
||||
self.cob_signals[symbol] = []
|
||||
self.liquidity_alerts[symbol] = []
|
||||
self.arbitrage_opportunities[symbol] = []
|
||||
|
||||
# Idempotence and task tracking
|
||||
self._started: bool = False
|
||||
self._analysis_task: Optional[asyncio.Task] = None
|
||||
self._signal_task: Optional[asyncio.Task] = None
|
||||
|
||||
logger.info("COB Integration initialized with Enhanced WebSocket support")
|
||||
logger.info(f"Symbols: {self.symbols}")
|
||||
@ -81,6 +86,11 @@ class COBIntegration:
|
||||
async def start(self):
|
||||
"""Start COB integration with Enhanced WebSocket"""
|
||||
logger.info(" Starting COB Integration with Enhanced WebSocket")
|
||||
|
||||
# Prevent duplicate start
|
||||
if self._started:
|
||||
logger.warning("COB Integration already started - skipping duplicate start")
|
||||
return
|
||||
|
||||
# Initialize Enhanced WebSocket first
|
||||
try:
|
||||
@ -106,11 +116,14 @@ class COBIntegration:
|
||||
# Set cob_provider to None to indicate we're using Enhanced WebSocket only
|
||||
self.cob_provider = None
|
||||
|
||||
# Start analysis threads
|
||||
asyncio.create_task(self._continuous_cob_analysis())
|
||||
asyncio.create_task(self._continuous_signal_generation())
|
||||
# Start analysis threads (store tasks; avoid duplicates)
|
||||
if self._analysis_task is None or self._analysis_task.done():
|
||||
self._analysis_task = asyncio.create_task(self._continuous_cob_analysis())
|
||||
if self._signal_task is None or self._signal_task.done():
|
||||
self._signal_task = asyncio.create_task(self._continuous_signal_generation())
|
||||
|
||||
logger.info(" COB Integration started successfully with Enhanced WebSocket")
|
||||
self._started = True
|
||||
|
||||
async def _on_enhanced_cob_update(self, symbol: str, cob_data: Dict):
|
||||
"""Handle COB updates from Enhanced WebSocket"""
|
||||
@ -854,9 +867,7 @@ class COBIntegration:
|
||||
def _initialize_cob_integration(self):
|
||||
"""Initialize COB integration with high-frequency data handling"""
|
||||
logger.info("Initializing COB integration...")
|
||||
if not COB_INTEGRATION_AVAILABLE:
|
||||
logger.warning("COB integration not available - skipping initialization")
|
||||
return
|
||||
# Proceed without external feature flag; availability handled by exceptions
|
||||
|
||||
try:
|
||||
if not hasattr(self.orchestrator, 'cob_integration') or self.orchestrator.cob_integration is None:
|
||||
|
Reference in New Issue
Block a user