dYdX
The dYdX cryptocurrency decentralized exchange integration adapter.
This subpackage provides instrument provider, data and execution client configurations, factories, and common constants/functions for connecting to and interacting with the dYdX API.
For convenience, the most commonly used symbols are re-exported at the subpackage’s
top level, so downstream code can simply import from nautilus_trader.adapters.dydx.
class DYDXDataClientConfig
Bases: LiveDataClientConfig
Configuration for DYDXDataClient instances.
- Parameters:
- wallet_address (str , optional) – The dYdX wallet address.
If 
Nonethen 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.
 - max_retries (PositiveInt , optional) – The maximum number of retries for HTTP retries or websocket reconnects.
 - retry_delay_initial_ms (PositiveInt , optional) – The initial delay (milliseconds) between retries. Short delays with frequent retries may result in account bans.
 - retry_delay_max_ms (PositiveInt , optional) – The maximum delay (milliseconds) between retries.
 - proxy_url (str , optional) – The proxy URL for HTTP requests.
 
 - wallet_address (str , optional) – The dYdX wallet address.
If 
 
is_testnet : bool
max_retries : Annotated[int, msgspec.Meta(gt=0)] | None
proxy_url : str | None
retry_delay_initial_ms : Annotated[int, msgspec.Meta(gt=0)] | None
retry_delay_max_ms : Annotated[int, msgspec.Meta(gt=0)] | None
update_instruments_interval_mins : Annotated[int, msgspec.Meta(gt=0)] | None
wallet_address : str | 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 json_schema() → dict[str, Any]
Generate a JSON schema for this configuration class.
- 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 
Nonethen 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 
Nonethen 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_initial_ms (PositiveInt , optional) – The initial delay (milliseconds) between retries. Short delays with frequent retries may result in account bans.
 - retry_delay_max_ms (PositiveInt , optional) – The maximum delay (milliseconds) between retries.
 - proxy_url (str , optional) – The proxy URL for HTTP requests.
 
 - wallet_address (str , optional) – The dYdX wallet address.
If 
 
base_url_http : str | None
base_url_ws : str | None
is_testnet : bool
max_retries : Annotated[int, msgspec.Meta(gt=0)] | None
mnemonic : str | None
proxy_url : str | None
retry_delay_initial_ms : Annotated[int, msgspec.Meta(gt=0)] | None
retry_delay_max_ms : Annotated[int, msgspec.Meta(gt=0)] | None
subaccount : int
wallet_address : str | 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 json_schema() → dict[str, Any]
Generate a JSON schema for this configuration class.
- 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 DYDXInstrumentProvider
Bases: InstrumentProvider
Provides Nautilus instrument definitions from dYdX.
- Parameters:
- client (DYDXHttpClient) – The dYdX HTTP client.
 - clock (LiveClock) – The clock instance.
 
 
add(instrument: Instrument) → None
Add the given instrument to the provider.
- Parameters: instrument (Instrument) – The instrument to add.
 
add_bulk(instruments: list[Instrument]) → None
Add the given instruments bulk to the provider.
- Parameters: instruments (list [Instrument ]) – The instruments to add.
 
add_currency(currency: Currency) → None
Add the given currency to the provider.
- Parameters: currency (Currency) – The currency to add.
 
property count : int
Return the count of instruments held by the provider.
- Return type: int
 
currencies() → dict[str, Currency]
Return all currencies held by the instrument provider.
- Return type: dict[str, Currency]
 
currency(code: str) → Currency | None
Return the currency with the given code (if found).
- Parameters: code (str) – The currency code.
 - Return type:
Currency or 
None - Raises: ValueError – If code is not a valid string.
 
find(instrument_id: InstrumentId) → Instrument | None
Return the instrument for the given instrument ID (if found).
- Parameters: instrument_id (InstrumentId) – The ID for the instrument
 - Return type:
Instrument or 
None 
get_all() → dict[InstrumentId, Instrument]
Return all loaded instruments as a map keyed by instrument ID.
If no instruments loaded, will return an empty dict.
- Return type: dict[InstrumentId, Instrument]
 
async initialize(reload: bool = False) → None
Initialize the instrument provider.
- Parameters: reload (bool , default False) – If True, then will always reload instruments. If False, then will immediately return if already loaded.
 
list_all() → list[Instrument]
Return all loaded instruments.
- Return type: list[Instrument]
 
load(instrument_id: InstrumentId, filters: dict | None = None) → None
Load the instrument for the given ID into the provider, optionally applying the given filters.
- Parameters:
- instrument_id (InstrumentId) – The instrument ID to load.
 - filters (frozendict *[*str , Any ] or dict *[*str , Any ] , optional) – The venue specific instrument loading filters to apply.
 
 
load_all(filters: dict | None = None) → None
Load the latest instruments into the provider, optionally applying the given filters.
- Parameters: filters (frozendict *[*str , Any ] or dict *[*str , Any ] , optional) – The venue specific instrument loading filters to apply.
 
async load_all_async(filters: dict[str, Any] | None = None) → None
Load all instruments asynchronously, optionally applying filters.
async load_async(instrument_id: InstrumentId, filters: dict | None = None) → None
Load a single instrument by its ID.
load_ids(instrument_ids: list[InstrumentId], filters: dict | None = None) → None
Load the instruments for the given IDs into the provider, optionally applying the given filters.
- Parameters:
- instrument_ids (list [InstrumentId ]) – The instrument IDs to load.
 - filters (frozendict *[*str , Any ] or dict *[*str , Any ] , optional) – The venue specific instrument loading filters to apply.
 
 
async load_ids_async(instrument_ids: list[InstrumentId], filters: dict | None = None) → None
Load specific instruments by their IDs.
class DYDXLiveDataClientFactory
Bases: LiveDataClientFactory
Provides a dYdX 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
 
class DYDXOrderTags
Bases: NautilusConfig
Used to attach to Nautilus Order Tags for dYdX specific order parameters.
is_short_term_order : bool
market_order_price : Price | None
num_blocks_open : int
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
 
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 json_schema() → dict[str, Any]
Generate a JSON schema for this configuration class.
- 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
 
validate() → bool
Return whether the configuration can be represented as valid JSON.
- Return type: bool
 
property value : str
get_dydx_grcp_client(is_testnet: bool = False) → DYDXAccountGRPCAPI
Return a dYdX GRPC client.
- Parameters: is_testnet (bool , default False) – Whether to use the testnet or production endpoint.
 - Returns: The dYdX GRPC client.
 - Return type: DYDXAccountGRPCAPI
 
get_dydx_http_client(clock: LiveClock, base_url: str | None = None, is_testnet: bool = False, proxy_url: str | None = None) → DYDXHttpClient
Cache and return a dYdX HTTP client.
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.
 - proxy_url (str , optional) – The proxy URL for HTTP requests.
 
 - 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 (DYDXHttpClient) – 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
 
Config
Define the dYdX configuration classes.
class DYDXDataClientConfig
Bases: LiveDataClientConfig
Configuration for DYDXDataClient instances.
- Parameters:
- wallet_address (str , optional) – The dYdX wallet address.
If 
Nonethen 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.
 - max_retries (PositiveInt , optional) – The maximum number of retries for HTTP retries or websocket reconnects.
 - retry_delay_initial_ms (PositiveInt , optional) – The initial delay (milliseconds) between retries. Short delays with frequent retries may result in account bans.
 - retry_delay_max_ms (PositiveInt , optional) – The maximum delay (milliseconds) between retries.
 - proxy_url (str , optional) – The proxy URL for HTTP requests.
 
 - 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
max_retries : Annotated[int, msgspec.Meta(gt=0)] | None
retry_delay_initial_ms : Annotated[int, msgspec.Meta(gt=0)] | None
retry_delay_max_ms : Annotated[int, msgspec.Meta(gt=0)] | None
proxy_url : str | 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 json_schema() → dict[str, Any]
Generate a JSON schema for this configuration class.
- 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 
Nonethen 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 
Nonethen 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_initial_ms (PositiveInt , optional) – The initial delay (milliseconds) between retries. Short delays with frequent retries may result in account bans.
 - retry_delay_max_ms (PositiveInt , optional) – The maximum delay (milliseconds) between retries.
 - proxy_url (str , optional) – The proxy URL for HTTP requests.
 
 - 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_initial_ms : Annotated[int, msgspec.Meta(gt=0)] | None
retry_delay_max_ms : Annotated[int, msgspec.Meta(gt=0)] | None
proxy_url : str | 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 json_schema() → dict[str, Any]
Generate a JSON schema for this configuration class.
- 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.
- Parameters: is_testnet (bool , default False) – Whether to use the testnet or production endpoint.
 - Returns: The dYdX GRPC client.
 - Return type: DYDXAccountGRPCAPI
 
get_dydx_http_client(clock: LiveClock, base_url: str | None = None, is_testnet: bool = False, proxy_url: str | None = None) → DYDXHttpClient
Cache and return a dYdX HTTP client.
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.
 - proxy_url (str , optional) – The proxy URL for HTTP requests.
 
 - 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 (DYDXHttpClient) – 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 dYdX 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 DYDXChannel
Bases: Enum
Represents a dYdX websocket channel.
TRADES = 'v4_trades'
ORDERBOOK = 'v4_orderbook'
CANDLES = 'v4_candles'
MARKETS = 'v4_markets'
SUBACCOUNTS = 'v4_subaccounts'
BLOCK_HEIGHT = 'v4_block_height'
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.
NONE = 'NONE'
ASSET = 'ASSET'
MARKET = 'MARKET'
ACCOUNT = 'ACCOUNT'
TRADE = 'TRADE'
POSITION = 'POSITION'
class DYDXPerpetualMarketStatus
Bases: Enum
Represents a dYdX endpoint perpetual market status.
ACTIVE = 'ACTIVE'
PAUSED = 'PAUSED'
CANCEL_ONLY = 'CANCEL_ONLY'
POST_ONLY = 'POST_ONLY'
INITIALIZING = 'INITIALIZING'
FINAL_SETTLEMENT = 'FINAL_SETTLEMENT'
class DYDXPerpetualMarketType
Bases: Enum
Represents a dYdX endpoint perpetual market type.
CROSS = 'CROSS'
ISOLATED = 'ISOLATED'
class DYDXOrderSide
Bases: Enum
Represents a dYdX order side type.
BUY = 'BUY'
SELL = 'SELL'
class DYDXOrderType
Bases: Enum
Represents a dYdX order type.
LIMIT = 'LIMIT'
MARKET = 'MARKET'
STOP_LIMIT = 'STOP_LIMIT'
STOP_MARKET = 'STOP_MARKET'
TRAILING_STOP = 'TRAILING_STOP'
TAKE_PROFIT = 'TAKE_PROFIT'
TAKE_PROFIT_MARKET = 'TAKE_PROFIT_MARKET'
LIQUIDATED = 'LIQUIDATED'
DELEVERAGED = 'DELEVERAGED'
class DYDXCandlesResolution
Bases: Enum
Represent the kline resolution for dYdX.
ONE_MINUTE = '1MIN'
FIVE_MINUTES = '5MINS'
FIFTEEN_MINUTES = '15MINS'
THIRTY_MINUTES = '30MINS'
ONE_HOUR = '1HOUR'
FOUR_HOURS = '4HOURS'
ONE_DAY = '1DAY'
class DYDXTransferType
Bases: Enum
Represent the different transfer types.
TRANSFER_IN = 'TRANSFER_IN'
TRANSFER_OUT = 'TRANSFER_OUT'
DEPOSIT = 'DEPOSIT'
WITHDRAWAL = 'WITHDRAWAL'
class DYDXEnumParser
Bases: object
Convert dYdX enums to Nautilus enums.
parse_dydx_order_type(order_type: DYDXOrderType) → OrderType
Convert a DYDX order type to a Nautilus order type.
parse_nautilus_order_type(order_type: OrderType) → DYDXOrderType
Convert a Nautilus order type to a DYDX order type.
parse_dydx_order_side(order_side: DYDXOrderSide | None) → OrderSide
Convert a DYDX order side to a Nautilus order side.
parse_nautilus_order_side(order_side: OrderSide) → DYDXOrderSide | None
Convert a Nautilus order side to a DYDX order side.
parse_dydx_order_status(order_status: DYDXOrderStatus) → OrderStatus
Convert a DYDX order status to a Nautilus order status.
parse_dydx_time_in_force(time_in_force: DYDXTimeInForce) → TimeInForce
Convert a DYDX time in force to a Nautilus time in force.
parse_dydx_liquidity_side(liquidity_side: DYDXLiquidity) → LiquiditySide
Convert a DYDX liquidity side to a Nautilus liquidity side.
parse_dydx_position_side(position_side: DYDXPositionSide) → PositionSide
Convert a DYDX position side to a Nautilus position side.
parse_dydx_kline(bar_type: BarType) → DYDXCandlesResolution
Convert a Nautilus bar type to a dYdX candles resolution.
Providers
Instrument provider for the dYdX venue.
class DYDXInstrumentProvider
Bases: InstrumentProvider
Provides Nautilus instrument definitions from dYdX.
- Parameters:
- client (DYDXHttpClient) – The dYdX HTTP client.
 - clock (LiveClock) – The clock instance.
 
 
async load_all_async(filters: dict[str, Any] | None = None) → None
Load all instruments asynchronously, optionally applying filters.
async load_ids_async(instrument_ids: list[InstrumentId], filters: dict | None = None) → None
Load specific instruments by their IDs.
async load_async(instrument_id: InstrumentId, filters: dict | None = None) → None
Load a single instrument by its ID.
add(instrument: Instrument) → None
Add the given instrument to the provider.
- Parameters: instrument (Instrument) – The instrument to add.
 
add_bulk(instruments: list[Instrument]) → None
Add the given instruments bulk to the provider.
- Parameters: instruments (list [Instrument ]) – The instruments to add.
 
add_currency(currency: Currency) → None
Add the given currency to the provider.
- Parameters: currency (Currency) – The currency to add.
 
property count : int
Return the count of instruments held by the provider.
- Return type: int
 
currencies() → dict[str, Currency]
Return all currencies held by the instrument provider.
- Return type: dict[str, Currency]
 
currency(code: str) → Currency | None
Return the currency with the given code (if found).
- Parameters: code (str) – The currency code.
 - Return type:
Currency or 
None - Raises: ValueError – If code is not a valid string.
 
find(instrument_id: InstrumentId) → Instrument | None
Return the instrument for the given instrument ID (if found).
- Parameters: instrument_id (InstrumentId) – The ID for the instrument
 - Return type:
Instrument or 
None 
get_all() → dict[InstrumentId, Instrument]
Return all loaded instruments as a map keyed by instrument ID.
If no instruments loaded, will return an empty dict.
- Return type: dict[InstrumentId, Instrument]
 
async initialize(reload: bool = False) → None
Initialize the instrument provider.
- Parameters: reload (bool , default False) – If True, then will always reload instruments. If False, then will immediately return if already loaded.
 
list_all() → list[Instrument]
Return all loaded instruments.
- Return type: list[Instrument]
 
load(instrument_id: InstrumentId, filters: dict | None = None) → None
Load the instrument for the given ID into the provider, optionally applying the given filters.
- Parameters:
- instrument_id (InstrumentId) – The instrument ID to load.
 - filters (frozendict *[*str , Any ] or dict *[*str , Any ] , optional) – The venue specific instrument loading filters to apply.
 
 
load_all(filters: dict | None = None) → None
Load the latest instruments into the provider, optionally applying the given filters.
- Parameters: filters (frozendict *[*str , Any ] or dict *[*str , Any ] , optional) – The venue specific instrument loading filters to apply.
 
load_ids(instrument_ids: list[InstrumentId], filters: dict | None = None) → None
Load the instruments for the given IDs into the provider, optionally applying the given filters.
- Parameters:
- instrument_ids (list [InstrumentId ]) – The instrument IDs to load.
 - filters (frozendict *[*str , Any ] or dict *[*str , Any ] , optional) – The venue specific instrument loading filters to apply.
 
 
Data
Provide a data client for the dYdX decentralized cypto exchange.
class DYDXDataClient
Bases: LiveMarketDataClient
Provide a data client for the dYdX decentralized cypto exchange.
- Parameters:
- loop (asyncio.AbstractEventLoop) – The event loop for the client.
 - client (DYDXHttpClient) – The dYdX HTTP client.
 - msgbus (MessageBus) – The message bus for the client.
 - cache (Cache) – The cache for the client.
 - clock (LiveClock) – The clock for the client.
 - instrument_provider (DYDXInstrumentProvider) – The instrument provider.
 - ws_base_url (str) – The product base url for the WebSocket client.
 - config (DYDXDataClientConfig) – The configuration for the client.
 - name (str , optional) – The custom client ID.
 
 
async cancel_pending_tasks(timeout_secs: float = 5.0) → None
Cancel all pending tasks and await their cancellation.
- Parameters: timeout_secs (float , default 5.0) – The timeout in seconds to wait for tasks to cancel.
 
connect() → None
Connect the client.
create_task(coro: ~collections.abc.Coroutine, log_msg: str | None = None, actions: ~collections.abc.Callable | None = None, success_msg: str | None = None, success_color: ~nautilus_trader.core.rust.common.LogColor = <LogColor.NORMAL: 0>) → Task | None
Run the given coroutine with error handling and optional callback actions when done.
- Parameters:
- coro (Coroutine) – The coroutine to run.
 - log_msg (str , optional) – The log message for the task.
 - actions (Callable , optional) – The actions callback to run when the coroutine is done.
 - success_msg (str , optional) – The log message to write on actions success.
 - success_color (LogColor, default 
NORMAL) – The log message color for actions success. 
 - Return type: asyncio.Task
 
degrade(self) → void
Degrade the component.
While executing on_degrade() any exception will be logged and reraised, then the component
will remain in a DEGRADING state.
WARNING
Do not override.
If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.
disconnect() → None
Disconnect the client.
dispose(self) → void
Dispose of the component.
While executing on_dispose() any exception will be logged and reraised, then the component
will remain in a DISPOSING state.
WARNING
Do not override.
If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.
fault(self) → void
Fault the component.
Calling this method multiple times has the same effect as calling it once (it is idempotent). Once called, it cannot be reversed, and no other methods should be called on this instance.
While executing on_fault() any exception will be logged and reraised, then the component
will remain in a FAULTING state.
WARNING
Do not override.
If the component is not in a valid state from which to execute this method, then the component state will not change, and an error will be logged.
classmethod fully_qualified_name(cls) → str
Return the fully qualified name for the components class.
- Return type: str
 
id
The components ID.
- Returns: ComponentId
 
is_connected
If the client is connected.
- Returns: bool
 
is_degraded
bool
Return whether the current component state is DEGRADED.
- Return type: bool
 - Type: Component.is_degraded
 
is_disposed
bool
Return whether the current component state is DISPOSED.
- Return type: bool
 - Type: Component.is_disposed
 
is_faulted
bool
Return whether the current component state is FAULTED.
- Return type: bool
 - Type: Component.is_faulted