48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import asyncio
|
||
|
|
|
||
|
|
from nautilus_trader.cache.cache import Cache
|
||
|
|
from nautilus_trader.common.component import LiveClock
|
||
|
|
from nautilus_trader.common.component import MessageBus
|
||
|
|
from nautilus_trader.live.factories import LiveDataClientFactory
|
||
|
|
|
||
|
|
from .config import BingxExecClientConfig
|
||
|
|
from .data_client import BingxMarketDataClient
|
||
|
|
from .data_config import BingxDataClientConfig
|
||
|
|
from .http import BingxHttpClient
|
||
|
|
from .instrument_provider import BingxInstrumentProvider
|
||
|
|
|
||
|
|
|
||
|
|
class BingxLiveDataClientFactory(LiveDataClientFactory):
|
||
|
|
@staticmethod
|
||
|
|
def create( # type: ignore[override]
|
||
|
|
loop: asyncio.AbstractEventLoop,
|
||
|
|
name: str,
|
||
|
|
config: BingxDataClientConfig,
|
||
|
|
msgbus: MessageBus,
|
||
|
|
cache: Cache,
|
||
|
|
clock: LiveClock,
|
||
|
|
) -> BingxMarketDataClient:
|
||
|
|
config.validate_mainnet_opt_in()
|
||
|
|
exec_cfg = BingxExecClientConfig(
|
||
|
|
api_key=None,
|
||
|
|
secret_key=None,
|
||
|
|
environment=config.environment,
|
||
|
|
allow_mainnet=config.allow_mainnet,
|
||
|
|
http_timeout_secs=config.http_timeout_secs,
|
||
|
|
instrument_provider=config.instrument_provider,
|
||
|
|
)
|
||
|
|
client = BingxHttpClient(exec_cfg)
|
||
|
|
provider = BingxInstrumentProvider(client=client, config=config.instrument_provider)
|
||
|
|
return BingxMarketDataClient(
|
||
|
|
loop=loop,
|
||
|
|
client=client,
|
||
|
|
msgbus=msgbus,
|
||
|
|
cache=cache,
|
||
|
|
clock=clock,
|
||
|
|
instrument_provider=provider,
|
||
|
|
config=config,
|
||
|
|
name=name,
|
||
|
|
)
|