dark mode. new COB style
This commit is contained in:
@ -46,12 +46,17 @@ import aiohttp.resolver
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# goal: use top 10 exchanges
|
||||
# https://www.coingecko.com/en/exchanges
|
||||
|
||||
class ExchangeType(Enum):
|
||||
BINANCE = "binance"
|
||||
COINBASE = "coinbase"
|
||||
KRAKEN = "kraken"
|
||||
HUOBI = "huobi"
|
||||
BITFINEX = "bitfinex"
|
||||
BYBIT = "bybit"
|
||||
BITGET = "bitget"
|
||||
|
||||
@dataclass
|
||||
class ExchangeOrderBookLevel:
|
||||
@ -288,6 +293,24 @@ class MultiExchangeCOBProvider:
|
||||
rate_limits={'requests_per_minute': 1000}
|
||||
)
|
||||
|
||||
# Bybit configuration
|
||||
configs[ExchangeType.BYBIT.value] = ExchangeConfig(
|
||||
exchange_type=ExchangeType.BYBIT,
|
||||
weight=0.18,
|
||||
websocket_url="wss://stream.bybit.com/v5/public/spot",
|
||||
rest_api_url="https://api.bybit.com",
|
||||
symbols_mapping={'BTC/USDT': 'BTCUSDT', 'ETH/USDT': 'ETHUSDT'},
|
||||
rate_limits={'requests_per_minute': 1200}
|
||||
)
|
||||
# Bitget configuration
|
||||
configs[ExchangeType.BITGET.value] = ExchangeConfig(
|
||||
exchange_type=ExchangeType.BITGET,
|
||||
weight=0.12,
|
||||
websocket_url="wss://ws.bitget.com/spot/v1/stream",
|
||||
rest_api_url="https://api.bitget.com",
|
||||
symbols_mapping={'BTC/USDT': 'BTCUSDT_SPBL', 'ETH/USDT': 'ETHUSDT_SPBL'},
|
||||
rate_limits={'requests_per_minute': 1200}
|
||||
)
|
||||
return configs
|
||||
|
||||
async def start_streaming(self):
|
||||
@ -459,6 +482,10 @@ class MultiExchangeCOBProvider:
|
||||
await self._stream_huobi_orderbook(symbol, config)
|
||||
elif exchange_name == ExchangeType.BITFINEX.value:
|
||||
await self._stream_bitfinex_orderbook(symbol, config)
|
||||
elif exchange_name == ExchangeType.BYBIT.value:
|
||||
await self._stream_bybit_orderbook(symbol, config)
|
||||
elif exchange_name == ExchangeType.BITGET.value:
|
||||
await self._stream_bitget_orderbook(symbol, config)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error streaming {exchange_name} for {symbol}: {e}")
|
||||
@ -467,7 +494,9 @@ class MultiExchangeCOBProvider:
|
||||
async def _stream_binance_orderbook(self, symbol: str, config: ExchangeConfig):
|
||||
"""Stream order book data from Binance"""
|
||||
try:
|
||||
ws_url = f"{config.websocket_url}{config.symbols_mapping[symbol].lower()}@depth@1000ms"
|
||||
# Use partial book depth stream with maximum levels - Binance format
|
||||
# @depth20@100ms gives us 20 levels at 100ms, but we also have REST API for full depth
|
||||
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 or websockets_connect is None:
|
||||
|
Reference in New Issue
Block a user