Skip to main content

nautilus_architect_ax/python/
config.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2026 Nautech Systems Pty Ltd. All rights reserved.
3//  https://nautechsystems.io
4//
5//  Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6//  You may not use this file except in compliance with the License.
7//  You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9//  Unless required by applicable law or agreed to in writing, software
10//  distributed under the License is distributed on an "AS IS" BASIS,
11//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//  See the License for the specific language governing permissions and
13//  limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16use nautilus_core::string::secret::SecretString;
17use nautilus_model::identifiers::AccountId;
18use nautilus_network::websocket::TransportBackend;
19use pyo3::pymethods;
20
21use crate::{
22    common::enums::AxEnvironment,
23    config::{AxDataClientConfig, AxExecutionClientConfig},
24};
25
26#[pymethods]
27#[pyo3_stub_gen::derive::gen_stub_pymethods]
28impl AxDataClientConfig {
29    /// Configuration for the AX Exchange live data client.
30    #[new]
31    #[expect(clippy::too_many_arguments)]
32    #[pyo3(signature = (api_key=None, api_secret=None, environment=None, base_url_http=None, base_url_ws_public=None, base_url_ws_private=None, proxy_url=None, http_timeout_secs=None, max_retries=None, retry_delay_initial_ms=None, retry_delay_max_ms=None, heartbeat_interval_secs=None, recv_window_ms=None, update_instruments_interval_mins=None, funding_rate_poll_interval_mins=None, transport_backend=None))]
33    fn py_new(
34        api_key: Option<String>,
35        api_secret: Option<String>,
36        environment: Option<AxEnvironment>,
37        base_url_http: Option<String>,
38        base_url_ws_public: Option<String>,
39        base_url_ws_private: Option<String>,
40        proxy_url: Option<String>,
41        http_timeout_secs: Option<u64>,
42        max_retries: Option<u32>,
43        retry_delay_initial_ms: Option<u64>,
44        retry_delay_max_ms: Option<u64>,
45        heartbeat_interval_secs: Option<u64>,
46        recv_window_ms: Option<u64>,
47        update_instruments_interval_mins: Option<u64>,
48        funding_rate_poll_interval_mins: Option<u64>,
49        transport_backend: Option<TransportBackend>,
50    ) -> Self {
51        let default = Self::default();
52        Self {
53            api_key: api_key.map(SecretString::from),
54            api_secret: api_secret.map(SecretString::from),
55            environment: environment.unwrap_or(default.environment),
56            base_url_http,
57            base_url_ws_public,
58            base_url_ws_private,
59            proxy_url: proxy_url.map(SecretString::from),
60            http_timeout_secs: http_timeout_secs.unwrap_or(default.http_timeout_secs),
61            max_retries: max_retries.unwrap_or(default.max_retries),
62            retry_delay_initial_ms: retry_delay_initial_ms
63                .unwrap_or(default.retry_delay_initial_ms),
64            retry_delay_max_ms: retry_delay_max_ms.unwrap_or(default.retry_delay_max_ms),
65            heartbeat_interval_secs: heartbeat_interval_secs
66                .unwrap_or(default.heartbeat_interval_secs),
67            recv_window_ms: recv_window_ms.unwrap_or(default.recv_window_ms),
68            update_instruments_interval_mins: update_instruments_interval_mins
69                .unwrap_or(default.update_instruments_interval_mins),
70            funding_rate_poll_interval_mins: funding_rate_poll_interval_mins
71                .unwrap_or(default.funding_rate_poll_interval_mins),
72            transport_backend: transport_backend.unwrap_or(default.transport_backend),
73        }
74    }
75
76    #[getter]
77    const fn has_proxy_url(&self) -> bool {
78        self.proxy_url.is_some()
79    }
80
81    fn __repr__(&self) -> String {
82        stringify!(AxDataClientConfig).to_string()
83    }
84
85    fn __str__(&self) -> String {
86        stringify!(AxDataClientConfig).to_string()
87    }
88}
89
90#[pymethods]
91#[pyo3_stub_gen::derive::gen_stub_pymethods]
92impl AxExecutionClientConfig {
93    /// Configuration for the AX Exchange live execution client.
94    #[new]
95    #[expect(clippy::too_many_arguments)]
96    #[pyo3(signature = (account_id=None, api_key=None, api_secret=None, environment=None, base_url_http=None, base_url_orders=None, base_url_ws_private=None, proxy_url=None, http_timeout_secs=None, max_retries=None, retry_delay_initial_ms=None, retry_delay_max_ms=None, heartbeat_interval_secs=None, recv_window_ms=None, cancel_on_disconnect=None, transport_backend=None))]
97    fn py_new(
98        account_id: Option<AccountId>,
99        api_key: Option<String>,
100        api_secret: Option<String>,
101        environment: Option<AxEnvironment>,
102        base_url_http: Option<String>,
103        base_url_orders: Option<String>,
104        base_url_ws_private: Option<String>,
105        proxy_url: Option<String>,
106        http_timeout_secs: Option<u64>,
107        max_retries: Option<u32>,
108        retry_delay_initial_ms: Option<u64>,
109        retry_delay_max_ms: Option<u64>,
110        heartbeat_interval_secs: Option<u64>,
111        recv_window_ms: Option<u64>,
112        cancel_on_disconnect: Option<bool>,
113        transport_backend: Option<TransportBackend>,
114    ) -> Self {
115        let default = Self::default();
116        Self {
117            account_id: account_id.unwrap_or(default.account_id),
118            api_key: api_key.map(SecretString::from),
119            api_secret: api_secret.map(SecretString::from),
120            environment: environment.unwrap_or(default.environment),
121            base_url_http,
122            base_url_orders,
123            base_url_ws_private,
124            proxy_url: proxy_url.map(SecretString::from),
125            http_timeout_secs: http_timeout_secs.unwrap_or(default.http_timeout_secs),
126            max_retries: max_retries.unwrap_or(default.max_retries),
127            retry_delay_initial_ms: retry_delay_initial_ms
128                .unwrap_or(default.retry_delay_initial_ms),
129            retry_delay_max_ms: retry_delay_max_ms.unwrap_or(default.retry_delay_max_ms),
130            heartbeat_interval_secs: heartbeat_interval_secs
131                .unwrap_or(default.heartbeat_interval_secs),
132            recv_window_ms: recv_window_ms.unwrap_or(default.recv_window_ms),
133            cancel_on_disconnect: cancel_on_disconnect.unwrap_or(default.cancel_on_disconnect),
134            transport_backend: transport_backend.unwrap_or(default.transport_backend),
135        }
136    }
137
138    #[getter]
139    const fn has_proxy_url(&self) -> bool {
140        self.proxy_url.is_some()
141    }
142
143    fn __repr__(&self) -> String {
144        stringify!(AxExecutionClientConfig).to_string()
145    }
146
147    fn __str__(&self) -> String {
148        stringify!(AxExecutionClientConfig).to_string()
149    }
150}