fixes
This commit is contained in:
@ -23,7 +23,11 @@ import asyncio
|
||||
import json
|
||||
import logging
|
||||
import time
|
||||
import websockets
|
||||
try:
|
||||
import websockets
|
||||
except ImportError:
|
||||
# Fallback for environments where websockets is not available
|
||||
websockets = None
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
from datetime import datetime, timedelta
|
||||
@ -106,7 +110,7 @@ class MultiExchangeCOBProvider:
|
||||
to create a consolidated view of market liquidity and pricing.
|
||||
"""
|
||||
|
||||
def __init__(self, symbols: List[str] = None, bucket_size_bps: float = 1.0):
|
||||
def __init__(self, symbols: Optional[List[str]] = None, bucket_size_bps: float = 1.0):
|
||||
"""
|
||||
Initialize Multi-Exchange COB Provider
|
||||
|
||||
@ -461,6 +465,8 @@ class MultiExchangeCOBProvider:
|
||||
ws_url = f"{config.websocket_url}{config.symbols_mapping[symbol].lower()}@depth20@100ms"
|
||||
logger.info(f"Connecting to Binance WebSocket: {ws_url}")
|
||||
|
||||
if websockets is None:
|
||||
raise ImportError("websockets module not available")
|
||||
async with websockets.connect(ws_url) as websocket:
|
||||
self.exchange_order_books[symbol]['binance']['connected'] = True
|
||||
logger.info(f"Connected to Binance order book stream for {symbol}")
|
||||
@ -537,7 +543,7 @@ class MultiExchangeCOBProvider:
|
||||
except Exception as e:
|
||||
logger.error(f"Error adding trade to SVP: {e}")
|
||||
|
||||
def get_session_volume_profile(self, symbol: str, bucket_size: float = None) -> Dict:
|
||||
def get_session_volume_profile(self, symbol: str, bucket_size: Optional[float] = None) -> Dict:
|
||||
"""Get session volume profile for a symbol"""
|
||||
try:
|
||||
if bucket_size is None:
|
||||
@ -690,6 +696,8 @@ class MultiExchangeCOBProvider:
|
||||
ws_url = f"{config.websocket_url}{config.symbols_mapping[symbol].lower()}@trade"
|
||||
logger.info(f"Connecting to Binance trade stream: {ws_url}")
|
||||
|
||||
if websockets is None:
|
||||
raise ImportError("websockets module not available")
|
||||
async with websockets.connect(ws_url) as websocket:
|
||||
logger.info(f"Connected to Binance trade stream for {symbol}")
|
||||
|
||||
|
Reference in New Issue
Block a user