1use nautilus_model::identifiers::AccountId;
19use nautilus_network::websocket::TransportBackend;
20use pyo3::pymethods;
21use rust_decimal::Decimal;
22
23use crate::{
24 common::enums::DeriveEnvironment,
25 config::{DeriveDataClientConfig, DeriveExecutionClientConfig},
26};
27
28#[pymethods]
29#[pyo3_stub_gen::derive::gen_stub_pymethods]
30impl DeriveDataClientConfig {
31 #[new]
33 #[pyo3(signature = (
34 base_url_rest = None,
35 base_url_ws = None,
36 proxy_url = None,
37 environment = None,
38 http_timeout_secs = None,
39 ws_timeout_secs = None,
40 update_instruments_interval_mins = None,
41 currencies = None,
42 include_expired = None,
43 auto_load_missing_instruments = None,
44 transport_backend = None,
45 ))]
46 #[expect(clippy::too_many_arguments)]
47 fn py_new(
48 base_url_rest: Option<String>,
49 base_url_ws: Option<String>,
50 proxy_url: Option<String>,
51 environment: Option<DeriveEnvironment>,
52 http_timeout_secs: Option<u64>,
53 ws_timeout_secs: Option<u64>,
54 update_instruments_interval_mins: Option<u64>,
55 currencies: Option<Vec<String>>,
56 include_expired: Option<bool>,
57 auto_load_missing_instruments: Option<bool>,
58 transport_backend: Option<TransportBackend>,
59 ) -> Self {
60 let defaults = Self::default();
61 Self {
62 base_url_rest,
63 base_url_ws,
64 proxy_url,
65 environment: environment.unwrap_or(defaults.environment),
66 http_timeout_secs: http_timeout_secs.unwrap_or(defaults.http_timeout_secs),
67 ws_timeout_secs,
68 update_instruments_interval_mins: update_instruments_interval_mins
69 .unwrap_or(defaults.update_instruments_interval_mins),
70 currencies: currencies.unwrap_or(defaults.currencies),
71 include_expired: include_expired.unwrap_or(defaults.include_expired),
72 auto_load_missing_instruments: auto_load_missing_instruments
73 .unwrap_or(defaults.auto_load_missing_instruments),
74 transport_backend: transport_backend.unwrap_or(defaults.transport_backend),
75 }
76 }
77
78 #[getter]
79 const fn has_proxy_url(&self) -> bool {
80 self.proxy_url.is_some()
81 }
82
83 fn __repr__(&self) -> String {
84 stringify!(DeriveDataClientConfig).to_string()
85 }
86}
87
88#[pymethods]
89#[pyo3_stub_gen::derive::gen_stub_pymethods]
90impl DeriveExecutionClientConfig {
91 #[new]
93 #[pyo3(signature = (
94 account_id = None,
95 wallet_address = None,
96 session_key = None,
97 subaccount_id = None,
98 base_url_rest = None,
99 base_url_ws = None,
100 proxy_url = None,
101 environment = None,
102 http_timeout_secs = None,
103 max_retries = None,
104 retry_delay_initial_ms = None,
105 retry_delay_max_ms = None,
106 ws_timeout_secs = None,
107 max_fee_per_contract = None,
108 domain_separator = None,
109 action_typehash = None,
110 trade_module_address = None,
111 signature_expiry_secs = None,
112 market_order_slippage_bps = None,
113 max_matching_requests_per_second = None,
114 max_per_instrument_matching_requests_per_second = None,
115 transport_backend = None,
116 ))]
117 #[expect(clippy::too_many_arguments)]
118 fn py_new(
119 account_id: Option<AccountId>,
120 wallet_address: Option<String>,
121 session_key: Option<String>,
122 subaccount_id: Option<u64>,
123 base_url_rest: Option<String>,
124 base_url_ws: Option<String>,
125 proxy_url: Option<String>,
126 environment: Option<DeriveEnvironment>,
127 http_timeout_secs: Option<u64>,
128 max_retries: Option<u32>,
129 retry_delay_initial_ms: Option<u64>,
130 retry_delay_max_ms: Option<u64>,
131 ws_timeout_secs: Option<u64>,
132 max_fee_per_contract: Option<Decimal>,
133 domain_separator: Option<String>,
134 action_typehash: Option<String>,
135 trade_module_address: Option<String>,
136 signature_expiry_secs: Option<u64>,
137 market_order_slippage_bps: Option<u32>,
138 max_matching_requests_per_second: Option<u32>,
139 max_per_instrument_matching_requests_per_second: Option<u32>,
140 transport_backend: Option<TransportBackend>,
141 ) -> Self {
142 let defaults = Self::default();
143 Self {
144 account_id: account_id.unwrap_or(defaults.account_id),
145 wallet_address,
146 session_key,
147 subaccount_id,
148 base_url_rest,
149 base_url_ws,
150 proxy_url,
151 environment: environment.unwrap_or(defaults.environment),
152 http_timeout_secs: http_timeout_secs.unwrap_or(defaults.http_timeout_secs),
153 max_retries: max_retries.unwrap_or(defaults.max_retries),
154 retry_delay_initial_ms: retry_delay_initial_ms
155 .unwrap_or(defaults.retry_delay_initial_ms),
156 retry_delay_max_ms: retry_delay_max_ms.unwrap_or(defaults.retry_delay_max_ms),
157 ws_timeout_secs,
158 max_fee_per_contract,
159 transport_backend: transport_backend.unwrap_or(defaults.transport_backend),
160 domain_separator,
161 action_typehash,
162 trade_module_address,
163 signature_expiry_secs: signature_expiry_secs.unwrap_or(defaults.signature_expiry_secs),
164 market_order_slippage_bps: market_order_slippage_bps
165 .unwrap_or(defaults.market_order_slippage_bps),
166 max_matching_requests_per_second,
167 max_per_instrument_matching_requests_per_second,
168 }
169 }
170
171 #[getter]
172 const fn has_proxy_url(&self) -> bool {
173 self.proxy_url.is_some()
174 }
175
176 fn __repr__(&self) -> String {
177 stringify!(DeriveExecutionClientConfig).to_string()
178 }
179}