2025-05-31 20:49:31 +08:00
|
|
|
"""
|
|
|
|
|
Exchange registry for supported exchanges.
|
|
|
|
|
|
|
|
|
|
This module contains the registry of supported exchanges and their capabilities,
|
|
|
|
|
separated to avoid circular import issues.
|
|
|
|
|
"""
|
|
|
|
|
|
2025-06-07 14:29:09 +08:00
|
|
|
from utils.logger import get_logger
|
|
|
|
|
from .exceptions import ExchangeNotSupportedError
|
|
|
|
|
|
|
|
|
|
# Initialize logger
|
|
|
|
|
logger = get_logger('exchanges')
|
|
|
|
|
|
2025-05-31 20:49:31 +08:00
|
|
|
# Exchange registry for factory pattern
|
|
|
|
|
EXCHANGE_REGISTRY = {
|
|
|
|
|
'okx': {
|
|
|
|
|
'collector': 'data.exchanges.okx.collector.OKXCollector',
|
|
|
|
|
'websocket': 'data.exchanges.okx.websocket.OKXWebSocketClient',
|
|
|
|
|
'name': 'OKX',
|
|
|
|
|
'supported_pairs': ['BTC-USDT', 'ETH-USDT', 'SOL-USDT', 'DOGE-USDT', 'TON-USDT'],
|
|
|
|
|
'supported_data_types': ['trade', 'orderbook', 'ticker', 'candles']
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2025-06-07 14:29:09 +08:00
|
|
|
def get_supported_exchanges() -> list:
|
2025-05-31 20:49:31 +08:00
|
|
|
"""Get list of supported exchange names."""
|
2025-06-07 14:29:09 +08:00
|
|
|
exchanges = list(EXCHANGE_REGISTRY.keys())
|
|
|
|
|
logger.debug(f"Available exchanges: {exchanges}")
|
|
|
|
|
return exchanges
|
2025-05-31 20:49:31 +08:00
|
|
|
|
|
|
|
|
|
2025-06-07 14:29:09 +08:00
|
|
|
def get_exchange_info(exchange_name: str) -> dict:
|
|
|
|
|
"""
|
|
|
|
|
Get information about a specific exchange.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
exchange_name: Name of the exchange
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
Dictionary containing exchange information
|
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
ExchangeNotSupportedError: If exchange is not found in registry
|
|
|
|
|
"""
|
|
|
|
|
exchange_name = exchange_name.lower()
|
|
|
|
|
exchange_info = EXCHANGE_REGISTRY.get(exchange_name)
|
|
|
|
|
|
|
|
|
|
if not exchange_info:
|
|
|
|
|
error_msg = f"Exchange '{exchange_name}' not found in registry"
|
|
|
|
|
logger.error(error_msg)
|
|
|
|
|
raise ExchangeNotSupportedError(error_msg)
|
|
|
|
|
|
|
|
|
|
logger.debug(f"Retrieved info for exchange: {exchange_name}")
|
|
|
|
|
return exchange_info
|