nautilus_architect_ax/
config.rs1use nautilus_model::identifiers::{AccountId, TraderId};
19
20#[derive(Clone, Debug)]
22pub struct AxDataClientConfig {
23 pub api_key: Option<String>,
25 pub api_secret: Option<String>,
27 pub is_sandbox: bool,
29 pub base_url_http: Option<String>,
31 pub base_url_ws_public: Option<String>,
33 pub base_url_ws_private: Option<String>,
35 pub http_proxy_url: Option<String>,
37 pub ws_proxy_url: Option<String>,
39 pub http_timeout_secs: Option<u64>,
41 pub max_retries: Option<u32>,
43 pub retry_delay_initial_ms: Option<u64>,
45 pub retry_delay_max_ms: Option<u64>,
47 pub heartbeat_interval_secs: Option<u64>,
49 pub recv_window_ms: Option<u64>,
51 pub update_instruments_interval_mins: Option<u64>,
53}
54
55impl Default for AxDataClientConfig {
56 fn default() -> Self {
57 Self {
58 api_key: None,
59 api_secret: None,
60 is_sandbox: false,
61 base_url_http: None,
62 base_url_ws_public: None,
63 base_url_ws_private: None,
64 http_proxy_url: None,
65 ws_proxy_url: None,
66 http_timeout_secs: Some(60),
67 max_retries: Some(3),
68 retry_delay_initial_ms: Some(1_000),
69 retry_delay_max_ms: Some(10_000),
70 heartbeat_interval_secs: Some(20),
71 recv_window_ms: Some(5_000),
72 update_instruments_interval_mins: Some(60),
73 }
74 }
75}
76
77impl AxDataClientConfig {
78 #[must_use]
80 pub fn new() -> Self {
81 Self::default()
82 }
83
84 #[must_use]
86 pub fn has_api_credentials(&self) -> bool {
87 let has_key = self.api_key.is_some() || std::env::var("AX_API_KEY").is_ok();
88 let has_secret = self.api_secret.is_some() || std::env::var("AX_API_SECRET").is_ok();
89 has_key && has_secret
90 }
91
92 #[must_use]
94 pub fn http_base_url(&self) -> String {
95 self.base_url_http.clone().unwrap_or_else(|| {
96 if self.is_sandbox {
97 "https://gateway.sandbox.architect.exchange/api".to_string()
98 } else {
99 "https://gateway.architect.exchange/api".to_string()
100 }
101 })
102 }
103
104 #[must_use]
106 pub fn ws_public_url(&self) -> String {
107 self.base_url_ws_public.clone().unwrap_or_else(|| {
108 if self.is_sandbox {
109 "wss://gateway.sandbox.architect.exchange/md/ws".to_string()
110 } else {
111 "wss://gateway.architect.exchange/md/ws".to_string()
112 }
113 })
114 }
115
116 #[must_use]
118 pub fn ws_private_url(&self) -> String {
119 self.base_url_ws_private.clone().unwrap_or_else(|| {
120 if self.is_sandbox {
121 "wss://gateway.sandbox.architect.exchange/orders/ws".to_string()
122 } else {
123 "wss://gateway.architect.exchange/orders/ws".to_string()
124 }
125 })
126 }
127}
128
129#[derive(Clone, Debug)]
131pub struct AxExecClientConfig {
132 pub trader_id: TraderId,
134 pub account_id: AccountId,
136 pub api_key: Option<String>,
138 pub api_secret: Option<String>,
140 pub is_sandbox: bool,
142 pub base_url_http: Option<String>,
144 pub base_url_orders: Option<String>,
146 pub base_url_ws_private: Option<String>,
148 pub http_proxy_url: Option<String>,
150 pub ws_proxy_url: Option<String>,
152 pub http_timeout_secs: Option<u64>,
154 pub max_retries: Option<u32>,
156 pub retry_delay_initial_ms: Option<u64>,
158 pub retry_delay_max_ms: Option<u64>,
160 pub heartbeat_interval_secs: Option<u64>,
162 pub recv_window_ms: Option<u64>,
164}
165
166impl Default for AxExecClientConfig {
167 fn default() -> Self {
168 Self {
169 trader_id: TraderId::from("TRADER-001"),
170 account_id: AccountId::from("AX-001"),
171 api_key: None,
172 api_secret: None,
173 is_sandbox: true,
174 base_url_http: None,
175 base_url_orders: None,
176 base_url_ws_private: None,
177 http_proxy_url: None,
178 ws_proxy_url: None,
179 http_timeout_secs: Some(60),
180 max_retries: Some(3),
181 retry_delay_initial_ms: Some(1_000),
182 retry_delay_max_ms: Some(10_000),
183 heartbeat_interval_secs: Some(30),
184 recv_window_ms: Some(5_000),
185 }
186 }
187}
188
189impl AxExecClientConfig {
190 #[must_use]
192 pub fn new() -> Self {
193 Self::default()
194 }
195
196 #[must_use]
198 pub fn has_api_credentials(&self) -> bool {
199 let has_key = self.api_key.is_some() || std::env::var("AX_API_KEY").is_ok();
200 let has_secret = self.api_secret.is_some() || std::env::var("AX_API_SECRET").is_ok();
201 has_key && has_secret
202 }
203
204 #[must_use]
206 pub fn http_base_url(&self) -> String {
207 self.base_url_http.clone().unwrap_or_else(|| {
208 if self.is_sandbox {
209 "https://gateway.sandbox.architect.exchange/api".to_string()
210 } else {
211 "https://gateway.architect.exchange/api".to_string()
212 }
213 })
214 }
215
216 #[must_use]
218 pub fn orders_base_url(&self) -> String {
219 self.base_url_orders.clone().unwrap_or_else(|| {
220 if self.is_sandbox {
221 "https://gateway.sandbox.architect.exchange/orders".to_string()
222 } else {
223 "https://gateway.architect.exchange/orders".to_string()
224 }
225 })
226 }
227
228 #[must_use]
230 pub fn ws_private_url(&self) -> String {
231 self.base_url_ws_private.clone().unwrap_or_else(|| {
232 if self.is_sandbox {
233 "wss://gateway.sandbox.architect.exchange/orders/ws".to_string()
234 } else {
235 "wss://gateway.architect.exchange/orders/ws".to_string()
236 }
237 })
238 }
239}