feat: WebSocket connection
This commit is contained in:
68
modules/config.py
Normal file
68
modules/config.py
Normal file
@@ -0,0 +1,68 @@
|
||||
"""
|
||||
Configuration management for the cryptocurrency trading platform.
|
||||
"""
|
||||
|
||||
import os
|
||||
from typing import Optional
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Load environment variables from .env file
|
||||
load_dotenv()
|
||||
|
||||
|
||||
def get_redis_url() -> str:
|
||||
"""
|
||||
Get Redis connection URL from environment variables.
|
||||
|
||||
Returns:
|
||||
Redis connection URL
|
||||
"""
|
||||
return os.getenv("REDIS_URL", "redis://localhost:6379/0")
|
||||
|
||||
|
||||
def get_timescaledb_url() -> str:
|
||||
"""
|
||||
Get TimescaleDB connection URL from environment variables.
|
||||
|
||||
Returns:
|
||||
TimescaleDB connection URL
|
||||
"""
|
||||
return os.getenv("TIMESCALEDB_URL", "postgresql://localhost:5432/trading")
|
||||
|
||||
|
||||
def get_supported_exchanges() -> list:
|
||||
"""
|
||||
Get list of supported exchanges from environment variables.
|
||||
|
||||
Returns:
|
||||
List of supported exchange names
|
||||
"""
|
||||
exchanges = os.getenv("SUPPORTED_EXCHANGES", "binance")
|
||||
return [ex.strip() for ex in exchanges.split(",") if ex.strip()]
|
||||
|
||||
|
||||
def get_exchange_config(exchange_name: str) -> dict:
|
||||
"""
|
||||
Get configuration for a specific exchange.
|
||||
|
||||
Args:
|
||||
exchange_name: Name of the exchange
|
||||
|
||||
Returns:
|
||||
Exchange configuration dictionary
|
||||
"""
|
||||
config = {
|
||||
"binance": {
|
||||
"ws_url": "wss://stream.binance.com:9443",
|
||||
"api_url": "https://api.binance.com",
|
||||
"max_concurrent_connections": 1000,
|
||||
},
|
||||
"okx": {
|
||||
"ws_url": "wss://ws.okx.com:8443",
|
||||
"api_url": "https://www.okx.com",
|
||||
"max_concurrent_connections": 1000,
|
||||
}
|
||||
}
|
||||
|
||||
return config.get(exchange_name.lower(), {})
|
||||
Reference in New Issue
Block a user