from __future__ import annotations from nautilus_trader.config import LiveDataClientConfig from nautilus_trader.config import PositiveInt from .config import BingxInstrumentProviderConfig from .config import require_mainnet_opt_in from .enums import BINGX_VENUE from .enums import BingxEnvironment class BingxDataClientConfig(LiveDataClientConfig, frozen=True): """ Configuration for the BingX live market data client. """ venue = BINGX_VENUE environment: BingxEnvironment = BingxEnvironment.VST allow_mainnet: bool = False base_url_ws_market: str | None = None http_timeout_secs: PositiveInt = 10 instrument_provider: BingxInstrumentProviderConfig = BingxInstrumentProviderConfig(load_all=True) use_book_ticker: bool = True use_incr_depth: bool = True depth_level: PositiveInt = 20 ws_reconnect_initial_ms: PositiveInt = 500 ws_reconnect_max_ms: PositiveInt = 10_000 def validate_mainnet_opt_in(self) -> None: require_mainnet_opt_in(self.environment, self.allow_mainnet, context="BingX data client") def __post_init__(self) -> None: import enum if isinstance(self.environment, enum.Enum): env_val = self.environment.value else: env_val = str(self.environment) if env_val.upper() == "LIVE" and not self.allow_mainnet: raise ValueError( "BingXDataClientConfig: LIVE environment requires allow_mainnet=True. " "Pass allow_mainnet=True explicitly to opt in." )