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_model::identifiers::AccountId;
17use nautilus_network::websocket::TransportBackend;
18use pyo3::pymethods;
19
20use crate::{
21    common::enums::AxEnvironment,
22    config::{AxDataClientConfig, AxExecutionClientConfig},
23};
24
25#[pymethods]
26#[pyo3_stub_gen::derive::gen_stub_pymethods]
27impl AxDataClientConfig {
28    /// Configuration for the AX Exchange live data client.
29    #[new]
30    #[expect(clippy::too_many_arguments)]
31    #[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))]
32    fn py_new(
33        api_key: Option<String>,
34        api_secret: Option<String>,
35        environment: Option<AxEnvironment>,
36        base_url_http: Option<String>,
37        base_url_ws_public: Option<String>,
38        base_url_ws_private: Option<String>,
39        proxy_url: Option<String>,
40        http_timeout_secs: Option<u64>,
41        max_retries: Option<u32>,
42        retry_delay_initial_ms: Option<u64>,
43        retry_delay_max_ms: Option<u64>,
44        heartbeat_interval_secs: Option<u64>,
45        recv_window_ms: Option<u64>,
46        update_instruments_interval_mins: Option<u64>,
47        funding_rate_poll_interval_mins: Option<u64>,
48        transport_backend: Option<TransportBackend>,
49    ) -> Self {
50        let default = Self::default();
51        Self {
52            api_key,
53            api_secret,
54            environment: environment.unwrap_or(default.environment),
55            base_url_http,
56            base_url_ws_public,
57            base_url_ws_private,
58            proxy_url,
59            http_timeout_secs: http_timeout_secs.unwrap_or(default.http_timeout_secs),
60            max_retries: max_retries.unwrap_or(default.max_retries),
61            retry_delay_initial_ms: retry_delay_initial_ms
62                .unwrap_or(default.retry_delay_initial_ms),
63            retry_delay_max_ms: retry_delay_max_ms.unwrap_or(default.retry_delay_max_ms),
64            heartbeat_interval_secs: heartbeat_interval_secs
65                .unwrap_or(default.heartbeat_interval_secs),
66            recv_window_ms: recv_window_ms.unwrap_or(default.recv_window_ms),
67            update_instruments_interval_mins: update_instruments_interval_mins
68                .unwrap_or(default.update_instruments_interval_mins),
69            funding_rate_poll_interval_mins: funding_rate_poll_interval_mins
70                .unwrap_or(default.funding_rate_poll_interval_mins),
71            transport_backend: transport_backend.unwrap_or(default.transport_backend),
72        }
73    }
74
75    #[getter]
76    const fn has_proxy_url(&self) -> bool {
77        self.proxy_url.is_some()
78    }
79
80    fn __repr__(&self) -> String {
81        stringify!(AxDataClientConfig).to_string()
82    }
83
84    fn __str__(&self) -> String {
85        stringify!(AxDataClientConfig).to_string()
86    }
87}
88
89#[pymethods]
90#[pyo3_stub_gen::derive::gen_stub_pymethods]
91impl AxExecutionClientConfig {
92    /// Configuration for the AX Exchange live execution client.
93    #[new]
94    #[expect(clippy::too_many_arguments)]
95    #[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))]
96    fn py_new(
97        account_id: Option<AccountId>,
98        api_key: Option<String>,
99        api_secret: Option<String>,
100        environment: Option<AxEnvironment>,
101        base_url_http: Option<String>,
102        base_url_orders: Option<String>,
103        base_url_ws_private: Option<String>,
104        proxy_url: Option<String>,
105        http_timeout_secs: Option<u64>,
106        max_retries: Option<u32>,
107        retry_delay_initial_ms: Option<u64>,
108        retry_delay_max_ms: Option<u64>,
109        heartbeat_interval_secs: Option<u64>,
110        recv_window_ms: Option<u64>,
111        cancel_on_disconnect: Option<bool>,
112        transport_backend: Option<TransportBackend>,
113    ) -> Self {
114        let default = Self::default();
115        Self {
116            account_id: account_id.unwrap_or(default.account_id),
117            api_key,
118            api_secret,
119            environment: environment.unwrap_or(default.environment),
120            base_url_http,
121            base_url_orders,
122            base_url_ws_private,
123            proxy_url,
124            http_timeout_secs: http_timeout_secs.unwrap_or(default.http_timeout_secs),
125            max_retries: max_retries.unwrap_or(default.max_retries),
126            retry_delay_initial_ms: retry_delay_initial_ms
127                .unwrap_or(default.retry_delay_initial_ms),
128            retry_delay_max_ms: retry_delay_max_ms.unwrap_or(default.retry_delay_max_ms),
129            heartbeat_interval_secs: heartbeat_interval_secs
130                .unwrap_or(default.heartbeat_interval_secs),
131            recv_window_ms: recv_window_ms.unwrap_or(default.recv_window_ms),
132            cancel_on_disconnect: cancel_on_disconnect.unwrap_or(default.cancel_on_disconnect),
133            transport_backend: transport_backend.unwrap_or(default.transport_backend),
134        }
135    }
136
137    #[getter]
138    const fn has_proxy_url(&self) -> bool {
139        self.proxy_url.is_some()
140    }
141
142    fn __repr__(&self) -> String {
143        stringify!(AxExecutionClientConfig).to_string()
144    }
145
146    fn __str__(&self) -> String {
147        stringify!(AxExecutionClientConfig).to_string()
148    }
149}