Architect AX¶
AX Exchange integration adapter.
This subpackage provides an instrument provider, data and execution clients, configurations, data types and constants for connecting to and interacting with the AX Exchange 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.architect_ax.
- class AxDataClientConfig¶
Bases:
LiveDataClientConfigConfiguration for
AxDataClientinstances.- Parameters:
api_key (str, optional) – The AX Exchange API key. If
Nonethen will source the AX_API_KEY environment variable.api_secret (str, optional) – The AX Exchange API secret. If
Nonethen will source the AX_API_SECRET environment variable.environment (AxEnvironment, default AxEnvironment.SANDBOX) – The AX Exchange environment to connect to (Sandbox or Production).
base_url_http (str, optional) – The base URL for the AX Exchange HTTP API. If
Nonethen will use the URL for the configured environment.base_url_ws (str, optional) – The base URL for the AX Exchange WebSocket API. If
Nonethen will use the URL for the configured environment.proxy_url (str, optional) – The proxy URL for HTTP and WebSocket transports.
http_timeout_secs (PositiveInt, optional) – HTTP request timeout in seconds.
max_retries (PositiveInt, optional) – Maximum retry attempts for requests.
retry_delay_initial_ms (PositiveInt, optional) – Initial delay (milliseconds) between retries.
retry_delay_max_ms (PositiveInt, optional) – Maximum delay (milliseconds) between retries.
update_instruments_interval_mins (PositiveInt, optional) – The interval (minutes) between reloading instruments from the venue.
funding_rate_poll_interval_mins (PositiveInt, optional) – The interval (minutes) between polling for funding rate updates.
- api_key: str | None¶
- api_secret: str | None¶
- environment: AxEnvironment¶
- base_url_http: str | None¶
- base_url_ws: str | None¶
- proxy_url: str | None¶
- transport_backend: TransportBackend | None¶
- http_timeout_secs: 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¶
- update_instruments_interval_mins: Annotated[int, msgspec.Meta(gt=0)] | None¶
- funding_rate_poll_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
References
- 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 AxEnvironment¶
Bases:
objectAX Exchange API environment.
- PRODUCTION = <AxEnvironment.PRODUCTION: '1'>¶
- SANDBOX = <AxEnvironment.SANDBOX: '0'>¶
- classmethod from_str(data)¶
- name¶
- value¶
- class AxExecClientConfig¶
Bases:
LiveExecClientConfigConfiguration for
AxExecutionClientinstances.- Parameters:
api_key (str, optional) – The AX Exchange API key. If
Nonethen will source the AX_API_KEY environment variable.api_secret (str, optional) – The AX Exchange API secret. If
Nonethen will source the AX_API_SECRET environment variable.environment (AxEnvironment, default AxEnvironment.SANDBOX) – The AX Exchange environment to connect to (Sandbox or Production).
base_url_http (str, optional) – The base URL for the AX Exchange HTTP API. If
Nonethen will use the URL for the configured environment.base_url_ws (str, optional) – The base URL for the AX Exchange WebSocket API. If
Nonethen will use the URL for the configured environment.proxy_url (str, optional) – The proxy URL for HTTP and WebSocket transports.
http_timeout_secs (PositiveInt, optional) – HTTP request timeout in seconds.
max_retries (PositiveInt, optional) – Maximum retry attempts for requests.
retry_delay_initial_ms (PositiveInt, optional) – Initial delay (milliseconds) between retries.
retry_delay_max_ms (PositiveInt, optional) – Maximum delay (milliseconds) between retries.
- api_key: str | None¶
- api_secret: str | None¶
- environment: AxEnvironment¶
- base_url_http: str | None¶
- base_url_ws: str | None¶
- proxy_url: str | None¶
- transport_backend: TransportBackend | None¶
- http_timeout_secs: 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¶
- 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
References
- 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 AxInstrumentProvider¶
Bases:
InstrumentProviderProvides Nautilus instrument definitions from AX Exchange.
- Parameters:
client (nautilus_pyo3.AxHttpClient) – The AX Exchange HTTP client.
config (InstrumentProviderConfig, optional) – The instrument provider configuration, by default None.
maker_fee (Decimal, optional) – The maker fee to apply to loaded instruments.
taker_fee (Decimal, optional) – The taker fee to apply to loaded instruments.
- instruments_pyo3() list[Any]¶
Return all AX Exchange PyO3 instrument definitions held by the provider.
- Return type:
list[nautilus_pyo3.Instrument]
- async load_all_async(filters: dict | None = None) None¶
Load the latest instruments into the provider asynchronously, optionally applying the given filters.
- 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_async(instrument_id: InstrumentId, filters: dict | None = None) None¶
Load the instrument for the given ID into the provider asynchronously, optionally applying the given filters.
The default implementation delegates to
load_ids_async. Subclasses with per-instrument fetch capability should override this method.- 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_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 the instruments for the given IDs into the provider, optionally applying the given filters.
The default implementation calls
load_all_async(since many venue APIs only support bulk fetches) and then filters the provider to retain only the requested instruments plus any previously loaded ones.Subclasses with per-instrument fetch capability should override this method.
- 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.
- class AxLiveDataClientFactory¶
Bases:
LiveDataClientFactoryProvides an AX Exchange live data client factory.
- static create(loop: AbstractEventLoop, name: str, config: AxDataClientConfig, msgbus: MessageBus, cache: Cache, clock: LiveClock) AxDataClient¶
Create a new AX Exchange data client.
- Parameters:
loop (asyncio.AbstractEventLoop) – The event loop for the client.
name (str) – The custom client ID.
config (AxDataClientConfig) – 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:
AxDataClient
- class AxLiveExecClientFactory¶
Bases:
LiveExecClientFactoryProvides an AX Exchange live execution client factory.
- static create(loop: AbstractEventLoop, name: str, config: AxExecClientConfig, msgbus: MessageBus, cache: Cache, clock: LiveClock) AxExecutionClient¶
Create a new AX Exchange execution client.
- Parameters:
loop (asyncio.AbstractEventLoop) – The event loop for the client.
name (str) – The custom client ID.
config (AxExecClientConfig) – 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:
AxExecutionClient
- class AxMarketDataLevel¶
Bases:
objectMarket data subscription level.
The AX API uses LEVEL_1, LEVEL_2, LEVEL_3 on the wire (with underscore before the digit). Serde and strum per-variant renames handle the wire and string formats correctly, however PyO3’s rename_all does not insert an underscore at letter-digit boundaries, so the Python variant names are LEVEL1, LEVEL2, LEVEL3 (without underscore).
# References - <https://docs.architect.exchange/api-reference/marketdata/md-ws>
- LEVEL1 = <AxMarketDataLevel.LEVEL_1: '0'>¶
- LEVEL2 = <AxMarketDataLevel.LEVEL_2: '1'>¶
- LEVEL3 = <AxMarketDataLevel.LEVEL_3: '2'>¶
- TRADES = <AxMarketDataLevel.TRADES: '3'>¶
- classmethod from_str(data)¶
- name¶
- value¶
- get_cached_ax_http_client(api_key: str | None = None, api_secret: str | None = None, base_url: str | None = None, orders_base_url: str | None = None, environment: AxEnvironment = <AxEnvironment.SANDBOX: '0'>, timeout_secs: int | None = None, max_retries: int | None = None, retry_delay_ms: int | None = None, retry_delay_max_ms: int | None = None, proxy_url: str | None = None) AxHttpClient¶
Cache and return an AX Exchange HTTP client.
If a cached client with matching parameters already exists, the cached client will be returned.
- Parameters:
api_key (str, optional) – The API key for the client.
api_secret (str, optional) – The API secret for the client.
base_url (str, optional) – The base URL for the API endpoints.
orders_base_url (str, optional) – The base URL for the orders API endpoints.
environment (AxEnvironment, default AxEnvironment.SANDBOX) – The AX Exchange environment (Sandbox or Production).
timeout_secs (int, optional) – The timeout for HTTP requests in seconds.
max_retries (int, optional) – The maximum number of retry attempts for failed requests.
retry_delay_ms (int, optional) – The initial delay (milliseconds) between retries.
retry_delay_max_ms (int, optional) – The maximum delay (milliseconds) between retries.
proxy_url (str, optional) – The proxy URL for HTTP requests.
- Return type:
AxHttpClient
- get_cached_ax_instrument_provider(client: AxHttpClient, config: InstrumentProviderConfig | None = None) AxInstrumentProvider¶
Cache and return an AX Exchange instrument provider.
If a cached provider already exists, then that provider will be returned.
- Parameters:
client (AxHttpClient) – The AX Exchange HTTP client.
config (InstrumentProviderConfig, optional) – The instrument provider configuration, by default None.
- Return type: