dYdX
The dYdX adapter.
Config
Define the dYdX configuration classes.
class DYDXDataClientConfig
Bases: LiveDataClientConfig
Configuration for DYDXDataClient
instances.
testnet : If the client is connecting to the dYdX testnet API.
wallet_address : str | None
is_testnet : bool
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.
wallet_address
: The dYdX wallet address.
If None
then will source DYDX_WALLET_ADDRESS or
DYDX_TESTNET_WALLET_ADDRESS environment variables.
subaccount : The subaccount number. The venue creates subaccount 0 by default.
mnemonic
: 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 : The HTTP client custom endpoint override.
base_url_ws : The WebSocket client custom endpoint override.
is_testnet : If the client is connecting to the dYdX testnet API.
max_retries : The maximum number of times a submit, cancel or modify order request will be retried.
retry_delay : The delay (seconds) between retries. Short delays with frequent retries may result in account bans.
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
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.
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.