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