Repository: nautechsystems/nautilus_trader
File: nautilus_trader/adapters/hyperliquid/data.py (Python)

Code before:

def _get_hyperliquid_ws_url(is_testnet: bool = False) -> str:
    """
    Get the appropriate Hyperliquid WebSocket URL.
    """
    if is_testnet:
        return "wss://api.hyperliquid-testnet.xyz/ws"
    return "wss://api.hyperliquid.xyz/ws"


# -------------------------------------------------------------------------------------------------
# Data Client
# -------------------------------------------------------------------------------------------------


class HyperliquidDataClient(LiveMarketDataClient):
    """
    Provides a data client for the Hyperliquid decentralized exchange.

    Parameters
    ----------
    loop : asyncio.AbstractEventLoop
        The event loop for the client.
    client : Any
        The Hyperliquid HTTP client (will be nautilus_pyo3.HyperliquidHttpClient when available).
    msgbus : MessageBus
        The message bus for the client.
    cache : Cache
        The cache for the client.
    clock : LiveClock
        The clock for the client.
    instrument_provider : HyperliquidInstrumentProvider
        The instrument provider.
    config : HyperliquidDataClientConfig
        The configuration for the client.
    name : str, optional
        The custom client ID.

    """

    def __init__(
        self,
        loop: asyncio.AbstractEventLoop,
        client: Any,  # TODO: Replace with nautilus_pyo3.HyperliquidHttpClient when available
        msgbus: MessageBus,
        cache: Cache,
        clock: LiveClock,
        instrument_provider: HyperliquidInstrumentProvider,
        config: HyperliquidDataClientConfig,
        name: str | None = None,
    ) -> None:

Review comment (suggestion):
We could make this `nautilus_pyo3.HyperliquidHttpClient` now and add to the `nautilus_pyo3.pyi` type stubs (if it's being exported with PyO3).

Code after:
# -------------------------------------------------------------------------------------------------


def _get_hyperliquid_ws_url(is_testnet: bool = False) -> str:
    """
    Get the appropriate Hyperliquid WebSocket URL.
    """
    if is_testnet:
        return "wss://api.hyperliquid-testnet.xyz/ws"
    return "wss://api.hyperliquid.xyz/ws"


# -------------------------------------------------------------------------------------------------
# Data Client
# -------------------------------------------------------------------------------------------------


class HyperliquidDataClient(LiveMarketDataClient):
    """
    Provides a data client for the Hyperliquid decentralized exchange.

    Parameters
    ----------
    loop : asyncio.AbstractEventLoop
        The event loop for the client.
    client : Any
        The Hyperliquid HTTP client (will be nautilus_pyo3.HyperliquidHttpClient when available).
    msgbus : MessageBus
        The message bus for the client.
    cache : Cache
        The cache for the client.
    clock : LiveClock
        The clock for the client.
    instrument_provider : HyperliquidInstrumentProvider
        The instrument provider.
    config : HyperliquidDataClientConfig
        The configuration for the client.
    name : str, optional
        The custom client ID.

    """

    def __init__(
        self,
        loop: asyncio.AbstractEventLoop,
        client: Any,  # TODO: Replace with nautilus_pyo3.HyperliquidHttpClient when available
        msgbus: MessageBus,
        cache: Cache,
        clock: LiveClock,
        instrument_provider: HyperliquidInstrumentProvider,
        config: HyperliquidDataClientConfig,