dYdX
The dYdX adapter.
Config
Define the dYdX configuration classes.
class DYDXDataClientConfig
Bases: LiveDataClientConfig
Configuration for DYDXDataClient
instances.
- Parameters:
- wallet_address (str , optional) – The dYdX wallet address.
If
None
then will source DYDX_WALLET_ADDRESS or DYDX_TESTNET_WALLET_ADDRESS environment variables. - testnet (bool , default False) – If the client is connecting to the dYdX testnet API.
- update_instruments_interval_mins (PositiveInt or None , default 60) – The interval (minutes) between reloading instruments from the venue.
- wallet_address (str , optional) – The dYdX wallet address.
If
wallet_address : str | None
is_testnet : bool
update_instruments_interval_mins : Annotated[int, msgspec.Meta(gt=0)] | None
dict() → dict[str, Any]
Return a dictionary representation of the configuration.
- Return type: dict[str, Any]
classmethod fully_qualified_name() → str
Return the fully qualified name for the NautilusConfig class.
- Return type: str
handle_revised_bars : bool
property id : str
Return the hashed identifier for the configuration.
- Return type: str
instrument_provider : InstrumentProviderConfig
json() → bytes
Return serialized JSON encoded bytes.
- Return type: bytes
json_primitives() → dict[str, Any]
Return a dictionary representation of the configuration with JSON primitive types as values.
- Return type: dict[str, Any]
classmethod parse(raw: bytes | str) → Any
Return a decoded object of the given cls.
- Parameters:
- cls (type) – The type to decode to.
- raw (bytes or str) – The raw bytes or JSON string to decode.
- Return type: Any
routing : RoutingConfig
validate() → bool
Return whether the configuration can be represented as valid JSON.
- Return type: bool
class DYDXExecClientConfig
Bases: LiveExecClientConfig
Configuration for DYDXExecutionClient
instances.
- Parameters:
- wallet_address (str , optional) – The dYdX wallet address.
If
None
then will source DYDX_WALLET_ADDRESS or DYDX_TESTNET_WALLET_ADDRESS environment variables. - subaccount (int , optional) – The subaccount number. The venue creates subaccount 0 by default.
- mnemonic (str , optional) – The mnemonic string which is used to generate the private key.
The private key is used to sign transactions like submitting orders.
If
None
then will source DYDX_MNEMONIC or DYDX_TESTNET_MNEMONIC environment variables. - base_url_http (str , optional) – The HTTP client custom endpoint override.
- base_url_ws (str , optional) – The WebSocket client custom endpoint override.
- is_testnet (bool , default False) – If the client is connecting to the dYdX testnet API.
- max_retries (PositiveInt , optional) – The maximum number of times a submit, cancel or modify order request will be retried.
- retry_delay (PositiveFloat , optional) – The delay (seconds) between retries. Short delays with frequent retries may result in account bans.
- wallet_address (str , optional) – The dYdX wallet address.
If
wallet_address : str | None
subaccount : int
mnemonic : str | None
base_url_http : str | None
base_url_ws : str | None
is_testnet : bool
max_retries : Annotated[int, msgspec.Meta(gt=0)] | None
retry_delay : Annotated[float, msgspec.Meta(gt=0.0)] | None
dict() → dict[str, Any]
Return a dictionary representation of the configuration.
- Return type: dict[str, Any]
classmethod fully_qualified_name() → str
Return the fully qualified name for the NautilusConfig class.
- Return type: str
property id : str
Return the hashed identifier for the configuration.
- Return type: str
instrument_provider : InstrumentProviderConfig
json() → bytes
Return serialized JSON encoded bytes.
- Return type: bytes
json_primitives() → dict[str, Any]
Return a dictionary representation of the configuration with JSON primitive types as values.
- Return type: dict[str, Any]
classmethod parse(raw: bytes | str) → Any
Return a decoded object of the given cls.
- Parameters:
- cls (type) – The type to decode to.
- raw (bytes or str) – The raw bytes or JSON string to decode.
- Return type: Any
routing : RoutingConfig
validate() → bool
Return whether the configuration can be represented as valid JSON.
- Return type: bool
Factories
Provide factories to construct data and execution clients for dYdX.
get_dydx_grcp_client(is_testnet: bool = False) → DYDXAccountGRPCAPI
Return a dYdX GRPC client.
get_dydx_http_client(clock: LiveClock, base_url: str | None = None, is_testnet: bool = False) → DYDXHttpClient
Cache and return a dYdX HTTP client with the given key and secret.
If a cached client with matching parameters already exists, the cached client will be returned.
- Parameters:
- clock (LiveClock) – The clock for the client.
- base_url (str , optional) – The base URL for the API endpoints.
- is_testnet (bool , default False) – If the client is connecting to the testnet API.
- Return type: DYDXHttpClient
get_dydx_instrument_provider(client: DYDXHttpClient, clock: LiveClock, config: InstrumentProviderConfig, wallet_address: str, is_testnet: bool) → DYDXInstrumentProvider
Cache and return a dYdX instrument provider.
If a cached provider already exists, then that provider will be returned.
- Parameters:
- client (BybitHttpClient) – The client for the instrument provider.
- clock (LiveClock) – The clock for the instrument provider.
- config (InstrumentProviderConfig) – The configuration for the instrument provider.
- wallet_address (str) – The wallet address containing the crypto assets.
- is_testnet (bool) – Whether the testnet of dYdX is used.
- Return type: DYDXInstrumentProvider
class DYDXLiveDataClientFactory
Bases: LiveDataClientFactory
Provides a Bybit live data client factory.
static create(loop: AbstractEventLoop, name: str, config: DYDXDataClientConfig, msgbus: MessageBus, cache: Cache, clock: LiveClock) → DYDXDataClient
Create a new dYdX data client.
- Parameters:
- loop (asyncio.AbstractEventLoop) – The event loop for the client.
- name (str) – The custom client ID.
- config (DYDXDataClientConfig) – The client configuration.
- msgbus (MessageBus) – The message bus for the client.
- cache (Cache) – The cache for the client.
- clock (LiveClock) – The clock for the instrument provider.
- Return type: DYDXDataClient
class DYDXLiveExecClientFactory
Bases: LiveExecClientFactory
Provides a dYdX live execution client factory.
static create(loop: AbstractEventLoop, name: str, config: DYDXExecClientConfig, msgbus: MessageBus, cache: Cache, clock: LiveClock) → DYDXExecutionClient
Create a new dYdX execution client.
- Parameters:
- loop (asyncio.AbstractEventLoop) – The event loop for the client.
- name (str) – The custom client ID.
- config (DYDXExecClientConfig) – The client configuration.
- msgbus (MessageBus) – The message bus for the client.
- cache (Cache) – The cache for the client.
- clock (LiveClock) – The clock for the client.
- Return type: DYDXExecutionClient
Enums
Define common enumerations for the dYdX adapter.
class DYDXLiquidity
Bases: Enum
Represents a dYdX liquidity type.
TAKER = 'TAKER'
MAKER = 'MAKER'
class DYDXFillType
Bases: Enum
Represents a dYdX fill type.
LIMIT = 'LIMIT'
LIQUIDATED = 'LIQUIDATED'
LIQUIDATION = 'LIQUIDATION'
DELEVERAGED = 'DELEVERAGED'
OFFSETTING = 'OFFSETTING'
class DYDXMarketType
Bases: Enum
Represents a dYdX market type.
PERPETUAL = 'PERPETUAL'
SPOT = 'SPOT'
class DYDXPerpetualPositionStatus
Bases: Enum
Represents a dYdX position status.
OPEN = 'OPEN'
CLOSED = 'CLOSED'
LIQUIDATED = 'LIQUIDATED'
class DYDXOrderStatus
Bases: Enum
Represents a dYdX order status.
OPEN = 'OPEN'
FILLED = 'FILLED'
CANCELED = 'CANCELED'
BEST_EFFORT_CANCELED = 'BEST_EFFORT_CANCELED'
UNTRIGGERED = 'UNTRIGGERED'
BEST_EFFORT_OPENED = 'BEST_EFFORT_OPENED'
class DYDXTimeInForce
Bases: Enum
Represents a dYdX time in force setting.
GTT = 'GTT'
FOK = 'FOK'
IOC = 'IOC'
class DYDXPositionSide
Bases: Enum
Represents a dYdX position side.
LONG = 'LONG'
SHORT = 'SHORT'
class DYDXEndpointType
Bases: Enum
Represents a dYdX endpoint perpetual market status.