1use std::{collections::HashMap, hash::BuildHasher, time::Duration};
23
24use nautilus_common::{
25 cache::CacheConfig, enums::Environment, logging::logger::LoggerConfig,
26 msgbus::MessageBusConfig, python::config_error_to_pyvalue_err,
27};
28use nautilus_core::{UUID4, datetime::get_timezone, python::to_pyvalue_err};
29use nautilus_model::{
30 enums::BarIntervalType,
31 identifiers::{ClientId, TraderId, Venue},
32};
33use nautilus_persistence::config::{DataCatalogConfig, StreamingConfig};
34use nautilus_portfolio::config::PortfolioConfig;
35use nautilus_trading::ImportableControllerConfig;
36use pyo3::{
37 Bound, IntoPyObject, Py, PyAny, PyResult, Python, pymethods,
38 types::{PyAnyMethods, PyBytes, PyDict, PyDictMethods, PyTuple},
39};
40
41use crate::config::{
42 DataClientConfig, ExecutionClientConfig, InstrumentProviderConfig, LiveDataEngineConfig,
43 LiveExecutionEngineConfig, LiveNodeConfig, LiveRiskEngineConfig, PluginConfig,
44 QueueMonitorConfig, RoutingConfig, SubmissionRecoveryPolicy, duration_from_secs_f64,
45 parse_rate_limit, validate_max_notional_per_order,
46};
47
48fn coerce_bar_interval_type(value: &Py<PyAny>) -> PyResult<BarIntervalType> {
51 Python::attach(|py| {
52 let bound = value.bind(py);
53 if let Ok(variant) = bound.extract::<BarIntervalType>() {
54 return Ok(variant);
55 }
56
57 let raw = bound.extract::<String>().map_err(|_| {
58 to_pyvalue_err("`time_bars_interval_type` must be a string or BarIntervalType")
59 })?;
60
61 match raw.to_ascii_uppercase().replace('-', "_").as_str() {
62 "LEFT_OPEN" => Ok(BarIntervalType::LeftOpen),
63 "RIGHT_OPEN" => Ok(BarIntervalType::RightOpen),
64 _ => Err(to_pyvalue_err(format!(
65 "invalid `time_bars_interval_type`: {raw:?} (expected 'left-open' or 'right-open')"
66 ))),
67 }
68 })
69}
70
71fn py_to_json_value(bound: &pyo3::Bound<'_, PyAny>) -> PyResult<serde_json::Value> {
73 if let Ok(b) = bound.extract::<bool>() {
75 Ok(serde_json::Value::Bool(b))
76 } else if let Ok(s) = bound.extract::<String>() {
77 Ok(serde_json::Value::String(s))
78 } else if let Ok(i) = bound.extract::<i64>() {
79 Ok(serde_json::Value::Number(serde_json::Number::from(i)))
80 } else if let Ok(f) = bound.extract::<f64>() {
81 Ok(serde_json::Number::from_f64(f)
82 .map_or(serde_json::Value::Null, serde_json::Value::Number))
83 } else if let Ok(dict) = bound.cast::<PyDict>() {
84 let mut obj = serde_json::Map::with_capacity(dict.len());
85 for (key, value) in dict.iter() {
86 obj.insert(key.extract::<String>()?, py_to_json_value(&value)?);
87 }
88
89 Ok(serde_json::Value::Object(obj))
90 } else if let Ok(items) = bound.extract::<Vec<Py<PyAny>>>() {
91 let py = bound.py();
93 let arr: Vec<serde_json::Value> = items
94 .iter()
95 .map(|item| py_to_json_value(item.bind(py)))
96 .collect::<PyResult<_>>()?;
97 Ok(serde_json::Value::Array(arr))
98 } else {
99 let s: String = bound.str()?.extract()?;
101 Ok(serde_json::Value::String(s))
102 }
103}
104
105pub fn json_value_to_py(py: Python<'_>, value: &serde_json::Value) -> PyResult<Py<PyAny>> {
111 match value {
112 serde_json::Value::Null => Ok(py.None()),
113 serde_json::Value::Bool(b) => Ok((*b).into_pyobject(py)?.to_owned().into_any().unbind()),
114 serde_json::Value::Number(n) => {
115 if let Some(i) = n.as_i64() {
116 Ok(i.into_pyobject(py)?.into_any().unbind())
117 } else if let Some(u) = n.as_u64() {
118 Ok(u.into_pyobject(py)?.into_any().unbind())
119 } else if let Some(f) = n.as_f64() {
120 Ok(f.into_pyobject(py)?.into_any().unbind())
121 } else {
122 Ok(n.to_string().into_pyobject(py)?.into_any().unbind())
123 }
124 }
125 serde_json::Value::String(s) => Ok(s.into_pyobject(py)?.into_any().unbind()),
126 serde_json::Value::Array(arr) => {
127 let items: Vec<Py<PyAny>> = arr
128 .iter()
129 .map(|v| json_value_to_py(py, v))
130 .collect::<PyResult<_>>()?;
131 Ok(pyo3::types::PyList::new(py, items)?.into_any().unbind())
132 }
133 serde_json::Value::Object(obj) => {
134 let dict = pyo3::types::PyDict::new(py);
135
136 for (k, v) in obj {
137 dict.set_item(k, json_value_to_py(py, v)?)?;
138 }
139
140 Ok(dict.into_any().unbind())
141 }
142 }
143}
144
145pub fn coerce_json_config<S: BuildHasher>(
151 raw: HashMap<String, Py<PyAny>, S>,
152) -> PyResult<HashMap<String, serde_json::Value>> {
153 Python::attach(|py| -> PyResult<HashMap<String, serde_json::Value>> {
154 let mut result = HashMap::with_capacity(raw.len());
155 for (key, value) in raw {
156 let json_value = py_to_json_value(value.bind(py))?;
157 result.insert(key, json_value);
158 }
159
160 Ok(result)
161 })
162}
163
164fn coerce_max_notional_per_order(
168 raw: HashMap<String, Py<PyAny>>,
169) -> PyResult<HashMap<String, String>> {
170 Python::attach(|py| -> PyResult<HashMap<String, String>> {
171 let mut result = HashMap::with_capacity(raw.len());
172 for (instrument_id, value) in raw {
173 let value_str: String = value.bind(py).str()?.extract()?;
174 result.insert(instrument_id, value_str);
175 }
176
177 Ok(result)
178 })
179}
180
181#[pyo3_stub_gen::derive::gen_stub_pymethods]
182#[pymethods]
183impl LiveDataEngineConfig {
184 #[new]
186 #[expect(clippy::too_many_arguments)]
187 #[allow(
188 clippy::needless_pass_by_value,
189 reason = "PyO3 #[new] requires owned params"
190 )]
191 #[pyo3(signature = (time_bars_build_with_no_updates=None, time_bars_timestamp_on_close=None, time_bars_skip_first_non_full_bar=None, time_bars_interval_type=None, time_bars_build_delay=None, time_bars_origin_offset=None, validate_data_sequence=None, buffer_deltas=None, emit_quotes_from_book=None, emit_quotes_from_book_depths=None, external_clients=None, debug=None, time_bars_time_zone=None))]
192 fn py_new(
193 time_bars_build_with_no_updates: Option<bool>,
194 time_bars_timestamp_on_close: Option<bool>,
195 time_bars_skip_first_non_full_bar: Option<bool>,
196 time_bars_interval_type: Option<Py<PyAny>>,
197 time_bars_build_delay: Option<u64>,
198 time_bars_origin_offset: Option<HashMap<String, u64>>,
199 validate_data_sequence: Option<bool>,
200 buffer_deltas: Option<bool>,
201 emit_quotes_from_book: Option<bool>,
202 emit_quotes_from_book_depths: Option<bool>,
203 external_clients: Option<Vec<ClientId>>,
204 debug: Option<bool>,
205 time_bars_time_zone: Option<String>,
206 ) -> PyResult<Self> {
207 if let Some(name) = &time_bars_time_zone {
208 get_timezone(name).map_err(to_pyvalue_err)?;
209 }
210
211 let default = Self::default();
212
213 let time_bars_interval_type = match time_bars_interval_type {
214 Some(ref obj) => coerce_bar_interval_type(obj)?,
215 None => default.time_bars_interval_type,
216 };
217
218 Ok(Self {
219 time_bars_build_with_no_updates: time_bars_build_with_no_updates
220 .unwrap_or(default.time_bars_build_with_no_updates),
221 time_bars_timestamp_on_close: time_bars_timestamp_on_close
222 .unwrap_or(default.time_bars_timestamp_on_close),
223 time_bars_skip_first_non_full_bar: time_bars_skip_first_non_full_bar
224 .unwrap_or(default.time_bars_skip_first_non_full_bar),
225 time_bars_interval_type,
226 time_bars_build_delay: time_bars_build_delay.unwrap_or(default.time_bars_build_delay),
227 time_bars_origin_offset: time_bars_origin_offset.unwrap_or_default(),
228 time_bars_time_zone,
229 validate_data_sequence: validate_data_sequence
230 .unwrap_or(default.validate_data_sequence),
231 buffer_deltas: buffer_deltas.unwrap_or(default.buffer_deltas),
232 emit_quotes_from_book: emit_quotes_from_book.unwrap_or(default.emit_quotes_from_book),
233 emit_quotes_from_book_depths: emit_quotes_from_book_depths
234 .unwrap_or(default.emit_quotes_from_book_depths),
235 external_clients,
236 debug: debug.unwrap_or(default.debug),
237 qsize: default.qsize,
238 })
239 }
240
241 #[getter]
242 #[pyo3(name = "time_bars_time_zone")]
243 fn py_time_bars_time_zone(&self) -> Option<String> {
244 self.time_bars_time_zone.clone()
245 }
246
247 #[getter]
248 #[pyo3(name = "time_bars_build_with_no_updates")]
249 const fn py_time_bars_build_with_no_updates(&self) -> bool {
250 self.time_bars_build_with_no_updates
251 }
252
253 #[getter]
254 #[pyo3(name = "time_bars_timestamp_on_close")]
255 const fn py_time_bars_timestamp_on_close(&self) -> bool {
256 self.time_bars_timestamp_on_close
257 }
258
259 #[getter]
260 #[pyo3(name = "time_bars_skip_first_non_full_bar")]
261 const fn py_time_bars_skip_first_non_full_bar(&self) -> bool {
262 self.time_bars_skip_first_non_full_bar
263 }
264
265 #[getter]
266 #[pyo3(name = "time_bars_interval_type")]
267 const fn py_time_bars_interval_type(&self) -> BarIntervalType {
268 self.time_bars_interval_type
269 }
270
271 #[getter]
272 #[pyo3(name = "time_bars_build_delay")]
273 const fn py_time_bars_build_delay(&self) -> u64 {
274 self.time_bars_build_delay
275 }
276
277 #[getter]
278 #[pyo3(name = "time_bars_origin_offset")]
279 fn py_time_bars_origin_offset(&self) -> HashMap<String, u64> {
280 self.time_bars_origin_offset.clone()
281 }
282
283 #[getter]
284 #[pyo3(name = "validate_data_sequence")]
285 const fn py_validate_data_sequence(&self) -> bool {
286 self.validate_data_sequence
287 }
288
289 #[getter]
290 #[pyo3(name = "buffer_deltas")]
291 const fn py_buffer_deltas(&self) -> bool {
292 self.buffer_deltas
293 }
294
295 #[getter]
296 #[pyo3(name = "emit_quotes_from_book")]
297 const fn py_emit_quotes_from_book(&self) -> bool {
298 self.emit_quotes_from_book
299 }
300
301 #[getter]
302 #[pyo3(name = "emit_quotes_from_book_depths")]
303 const fn py_emit_quotes_from_book_depths(&self) -> bool {
304 self.emit_quotes_from_book_depths
305 }
306
307 #[getter]
308 #[pyo3(name = "external_clients")]
309 fn py_external_clients(&self) -> Option<Vec<ClientId>> {
310 self.external_clients.clone()
311 }
312
313 #[getter]
314 #[pyo3(name = "debug")]
315 const fn py_debug(&self) -> bool {
316 self.debug
317 }
318
319 fn __repr__(&self) -> String {
320 format!("{self:?}")
321 }
322
323 fn __str__(&self) -> String {
324 format!("{self:?}")
325 }
326}
327
328#[pyo3_stub_gen::derive::gen_stub_pymethods]
329#[pymethods]
330impl LiveRiskEngineConfig {
331 #[new]
333 #[pyo3(signature = (bypass=None, max_order_submit_rate=None, max_order_modify_rate=None, max_notional_per_order=None, full_position_exit_venues=None, debug=None))]
334 fn py_new(
335 bypass: Option<bool>,
336 max_order_submit_rate: Option<String>,
337 max_order_modify_rate: Option<String>,
338 max_notional_per_order: Option<HashMap<String, Py<PyAny>>>,
339 full_position_exit_venues: Option<Vec<Venue>>,
340 debug: Option<bool>,
341 ) -> PyResult<Self> {
342 let default = Self::default();
343 let max_order_submit_rate =
344 max_order_submit_rate.unwrap_or_else(|| default.max_order_submit_rate.clone());
345 let max_order_modify_rate =
346 max_order_modify_rate.unwrap_or_else(|| default.max_order_modify_rate.clone());
347
348 let max_notional_per_order = match max_notional_per_order {
349 Some(raw) => coerce_max_notional_per_order(raw)?,
350 None => HashMap::new(),
351 };
352
353 let full_position_exit_venues = full_position_exit_venues.unwrap_or_default();
354
355 parse_rate_limit(
356 "LiveRiskEngineConfig.max_order_submit_rate",
357 &max_order_submit_rate,
358 )
359 .map_err(config_error_to_pyvalue_err)?;
360 parse_rate_limit(
361 "LiveRiskEngineConfig.max_order_modify_rate",
362 &max_order_modify_rate,
363 )
364 .map_err(config_error_to_pyvalue_err)?;
365 validate_max_notional_per_order(
366 "LiveRiskEngineConfig.max_notional_per_order",
367 &max_notional_per_order,
368 )
369 .map_err(config_error_to_pyvalue_err)?;
370
371 Ok(Self {
372 bypass: bypass.unwrap_or(default.bypass),
373 max_order_submit_rate,
374 max_order_modify_rate,
375 max_notional_per_order,
376 full_position_exit_venues,
377 debug: debug.unwrap_or(default.debug),
378 qsize: default.qsize,
379 })
380 }
381
382 #[getter]
383 #[pyo3(name = "bypass")]
384 const fn py_bypass(&self) -> bool {
385 self.bypass
386 }
387
388 #[getter]
389 #[pyo3(name = "max_order_submit_rate")]
390 fn py_max_order_submit_rate(&self) -> &str {
391 &self.max_order_submit_rate
392 }
393
394 #[getter]
395 #[pyo3(name = "max_order_modify_rate")]
396 fn py_max_order_modify_rate(&self) -> &str {
397 &self.max_order_modify_rate
398 }
399
400 #[getter]
401 #[pyo3(name = "max_notional_per_order")]
402 fn py_max_notional_per_order(&self) -> HashMap<String, String> {
403 self.max_notional_per_order.clone()
404 }
405
406 #[getter]
407 #[pyo3(name = "full_position_exit_venues")]
408 fn py_full_position_exit_venues(&self) -> Vec<Venue> {
409 self.full_position_exit_venues.clone()
410 }
411
412 #[getter]
413 #[pyo3(name = "debug")]
414 const fn py_debug(&self) -> bool {
415 self.debug
416 }
417
418 fn __repr__(&self) -> String {
419 format!("{self:?}")
420 }
421
422 fn __str__(&self) -> String {
423 format!("{self:?}")
424 }
425}
426
427#[pyo3_stub_gen::derive::gen_stub_pymethods]
428#[pymethods]
429impl LiveExecutionEngineConfig {
430 #[new]
432 #[expect(clippy::too_many_arguments)]
433 #[pyo3(signature = (load_cache=None, manage_own_order_books=None, snapshot_positions_interval_secs=None, external_clients=None, allow_overfills=None, reconciliation=None, reconciliation_startup_delay_secs=None, reconciliation_lookback_mins=None, reconciliation_instrument_ids=None, filter_unclaimed_external_orders=None, filter_position_reports=None, filtered_client_order_ids=None, generate_missing_orders=None, inflight_check_interval_ms=None, inflight_check_threshold_ms=None, inflight_check_retries=None, open_check_interval_secs=None, open_check_lookback_mins=Some(60), open_check_threshold_ms=None, open_check_missing_retries=None, open_check_open_only=None, max_single_order_queries_per_cycle=None, single_order_query_delay_ms=None, position_check_interval_secs=None, position_check_lookback_mins=None, position_check_threshold_ms=None, position_check_retries=None, purge_closed_orders_interval_mins=None, purge_closed_orders_buffer_mins=None, purge_closed_positions_interval_mins=None, purge_closed_positions_buffer_mins=None, purge_account_events_interval_mins=None, purge_account_events_lookback_mins=None, own_books_audit_interval_secs=None, debug=None, snapshot_orders=None, snapshot_positions=None, submission_recovery_policy=None, purge_from_database=None))]
434 fn py_new(
435 load_cache: Option<bool>,
436 manage_own_order_books: Option<bool>,
437 snapshot_positions_interval_secs: Option<f64>,
438 external_clients: Option<Vec<ClientId>>,
439 allow_overfills: Option<bool>,
440 reconciliation: Option<bool>,
441 reconciliation_startup_delay_secs: Option<f64>,
442 reconciliation_lookback_mins: Option<u32>,
443 reconciliation_instrument_ids: Option<Vec<String>>,
444 filter_unclaimed_external_orders: Option<bool>,
445 filter_position_reports: Option<bool>,
446 filtered_client_order_ids: Option<Vec<String>>,
447 generate_missing_orders: Option<bool>,
448 inflight_check_interval_ms: Option<u32>,
449 inflight_check_threshold_ms: Option<u32>,
450 inflight_check_retries: Option<u32>,
451 open_check_interval_secs: Option<f64>,
452 open_check_lookback_mins: Option<u32>,
453 open_check_threshold_ms: Option<u32>,
454 open_check_missing_retries: Option<u32>,
455 open_check_open_only: Option<bool>,
456 max_single_order_queries_per_cycle: Option<u32>,
457 single_order_query_delay_ms: Option<u32>,
458 position_check_interval_secs: Option<f64>,
459 position_check_lookback_mins: Option<u32>,
460 position_check_threshold_ms: Option<u32>,
461 position_check_retries: Option<u32>,
462 purge_closed_orders_interval_mins: Option<u32>,
463 purge_closed_orders_buffer_mins: Option<u32>,
464 purge_closed_positions_interval_mins: Option<u32>,
465 purge_closed_positions_buffer_mins: Option<u32>,
466 purge_account_events_interval_mins: Option<u32>,
467 purge_account_events_lookback_mins: Option<u32>,
468 own_books_audit_interval_secs: Option<f64>,
469 debug: Option<bool>,
470 snapshot_orders: Option<bool>,
471 snapshot_positions: Option<bool>,
472 submission_recovery_policy: Option<SubmissionRecoveryPolicy>,
473 purge_from_database: Option<bool>,
474 ) -> PyResult<Self> {
475 let default = Self::default();
476
477 let config = Self {
478 load_cache: load_cache.unwrap_or(default.load_cache),
479 manage_own_order_books: manage_own_order_books
480 .unwrap_or(default.manage_own_order_books),
481 snapshot_orders: snapshot_orders.unwrap_or(default.snapshot_orders),
482 snapshot_positions: snapshot_positions.unwrap_or(default.snapshot_positions),
483 snapshot_positions_interval_secs,
484 external_clients,
485 allow_overfills: allow_overfills.unwrap_or(default.allow_overfills),
486 reconciliation: reconciliation.unwrap_or(default.reconciliation),
487 reconciliation_startup_delay_secs: reconciliation_startup_delay_secs
488 .unwrap_or(default.reconciliation_startup_delay_secs),
489 reconciliation_lookback_mins,
490 reconciliation_instrument_ids,
491 filter_unclaimed_external_orders: filter_unclaimed_external_orders
492 .unwrap_or(default.filter_unclaimed_external_orders),
493 filter_position_reports: filter_position_reports
494 .unwrap_or(default.filter_position_reports),
495 filtered_client_order_ids,
496 generate_missing_orders: generate_missing_orders
497 .unwrap_or(default.generate_missing_orders),
498 inflight_check_interval_ms: inflight_check_interval_ms
499 .unwrap_or(default.inflight_check_interval_ms),
500 inflight_check_threshold_ms: inflight_check_threshold_ms
501 .unwrap_or(default.inflight_check_threshold_ms),
502 inflight_check_retries: inflight_check_retries
503 .unwrap_or(default.inflight_check_retries),
504 submission_recovery_policy: submission_recovery_policy
505 .unwrap_or(default.submission_recovery_policy),
506 open_check_interval_secs,
507 open_check_lookback_mins,
508 open_check_threshold_ms: open_check_threshold_ms
509 .unwrap_or(default.open_check_threshold_ms),
510 open_check_missing_retries: open_check_missing_retries
511 .unwrap_or(default.open_check_missing_retries),
512 open_check_open_only: open_check_open_only.unwrap_or(default.open_check_open_only),
513 max_single_order_queries_per_cycle: max_single_order_queries_per_cycle
514 .unwrap_or(default.max_single_order_queries_per_cycle),
515 single_order_query_delay_ms: single_order_query_delay_ms
516 .unwrap_or(default.single_order_query_delay_ms),
517 position_check_interval_secs,
518 position_check_lookback_mins: position_check_lookback_mins
519 .unwrap_or(default.position_check_lookback_mins),
520 position_check_threshold_ms: position_check_threshold_ms
521 .unwrap_or(default.position_check_threshold_ms),
522 position_check_retries: position_check_retries
523 .unwrap_or(default.position_check_retries),
524 purge_closed_orders_interval_mins,
525 purge_closed_orders_buffer_mins,
526 purge_closed_positions_interval_mins,
527 purge_closed_positions_buffer_mins,
528 purge_account_events_interval_mins,
529 purge_account_events_lookback_mins,
530 purge_from_database: purge_from_database.unwrap_or(default.purge_from_database),
531 debug: debug.unwrap_or(default.debug),
532 own_books_audit_interval_secs,
533 qsize: default.qsize,
534 };
535
536 config
537 .validate_runtime_support()
538 .map_err(config_error_to_pyvalue_err)?;
539 Ok(config)
540 }
541
542 #[getter]
543 #[pyo3(name = "load_cache")]
544 const fn py_load_cache(&self) -> bool {
545 self.load_cache
546 }
547
548 #[getter]
549 #[pyo3(name = "manage_own_order_books")]
550 const fn py_manage_own_order_books(&self) -> bool {
551 self.manage_own_order_books
552 }
553
554 #[getter]
555 #[pyo3(name = "snapshot_orders")]
556 const fn py_snapshot_orders(&self) -> bool {
557 self.snapshot_orders
558 }
559
560 #[getter]
561 #[pyo3(name = "snapshot_positions")]
562 const fn py_snapshot_positions(&self) -> bool {
563 self.snapshot_positions
564 }
565
566 #[getter]
567 #[pyo3(name = "snapshot_positions_interval_secs")]
568 const fn py_snapshot_positions_interval_secs(&self) -> Option<f64> {
569 self.snapshot_positions_interval_secs
570 }
571
572 #[getter]
573 #[pyo3(name = "external_clients")]
574 fn py_external_clients(&self) -> Option<Vec<ClientId>> {
575 self.external_clients.clone()
576 }
577
578 #[getter]
579 #[pyo3(name = "allow_overfills")]
580 const fn py_allow_overfills(&self) -> bool {
581 self.allow_overfills
582 }
583
584 #[getter]
585 #[pyo3(name = "reconciliation")]
586 const fn py_reconciliation(&self) -> bool {
587 self.reconciliation
588 }
589
590 #[getter]
591 #[pyo3(name = "reconciliation_startup_delay_secs")]
592 const fn py_reconciliation_startup_delay_secs(&self) -> f64 {
593 self.reconciliation_startup_delay_secs
594 }
595
596 #[getter]
597 #[pyo3(name = "reconciliation_lookback_mins")]
598 const fn py_reconciliation_lookback_mins(&self) -> Option<u32> {
599 self.reconciliation_lookback_mins
600 }
601
602 #[getter]
603 #[pyo3(name = "reconciliation_instrument_ids")]
604 fn py_reconciliation_instrument_ids(&self) -> Option<Vec<String>> {
605 self.reconciliation_instrument_ids.clone()
606 }
607
608 #[getter]
609 #[pyo3(name = "filter_unclaimed_external_orders")]
610 const fn py_filter_unclaimed_external_orders(&self) -> bool {
611 self.filter_unclaimed_external_orders
612 }
613
614 #[getter]
615 #[pyo3(name = "filter_position_reports")]
616 const fn py_filter_position_reports(&self) -> bool {
617 self.filter_position_reports
618 }
619
620 #[getter]
621 #[pyo3(name = "filtered_client_order_ids")]
622 fn py_filtered_client_order_ids(&self) -> Option<Vec<String>> {
623 self.filtered_client_order_ids.clone()
624 }
625
626 #[getter]
627 #[pyo3(name = "generate_missing_orders")]
628 const fn py_generate_missing_orders(&self) -> bool {
629 self.generate_missing_orders
630 }
631
632 #[getter]
633 #[pyo3(name = "inflight_check_interval_ms")]
634 const fn py_inflight_check_interval_ms(&self) -> u32 {
635 self.inflight_check_interval_ms
636 }
637
638 #[getter]
639 #[pyo3(name = "inflight_check_threshold_ms")]
640 const fn py_inflight_check_threshold_ms(&self) -> u32 {
641 self.inflight_check_threshold_ms
642 }
643
644 #[getter]
645 #[pyo3(name = "submission_recovery_policy")]
646 const fn py_submission_recovery_policy(&self) -> SubmissionRecoveryPolicy {
647 self.submission_recovery_policy
648 }
649
650 #[getter]
651 #[pyo3(name = "inflight_check_retries")]
652 const fn py_inflight_check_retries(&self) -> u32 {
653 self.inflight_check_retries
654 }
655
656 #[getter]
657 #[pyo3(name = "open_check_interval_secs")]
658 const fn py_open_check_interval_secs(&self) -> Option<f64> {
659 self.open_check_interval_secs
660 }
661
662 #[getter]
663 #[pyo3(name = "open_check_lookback_mins")]
664 const fn py_open_check_lookback_mins(&self) -> Option<u32> {
665 self.open_check_lookback_mins
666 }
667
668 #[getter]
669 #[pyo3(name = "open_check_threshold_ms")]
670 const fn py_open_check_threshold_ms(&self) -> u32 {
671 self.open_check_threshold_ms
672 }
673
674 #[getter]
675 #[pyo3(name = "open_check_missing_retries")]
676 const fn py_open_check_missing_retries(&self) -> u32 {
677 self.open_check_missing_retries
678 }
679
680 #[getter]
681 #[pyo3(name = "open_check_open_only")]
682 const fn py_open_check_open_only(&self) -> bool {
683 self.open_check_open_only
684 }
685
686 #[getter]
687 #[pyo3(name = "max_single_order_queries_per_cycle")]
688 const fn py_max_single_order_queries_per_cycle(&self) -> u32 {
689 self.max_single_order_queries_per_cycle
690 }
691
692 #[getter]
693 #[pyo3(name = "single_order_query_delay_ms")]
694 const fn py_single_order_query_delay_ms(&self) -> u32 {
695 self.single_order_query_delay_ms
696 }
697
698 #[getter]
699 #[pyo3(name = "position_check_interval_secs")]
700 const fn py_position_check_interval_secs(&self) -> Option<f64> {
701 self.position_check_interval_secs
702 }
703
704 #[getter]
705 #[pyo3(name = "position_check_lookback_mins")]
706 const fn py_position_check_lookback_mins(&self) -> u32 {
707 self.position_check_lookback_mins
708 }
709
710 #[getter]
711 #[pyo3(name = "position_check_threshold_ms")]
712 const fn py_position_check_threshold_ms(&self) -> u32 {
713 self.position_check_threshold_ms
714 }
715
716 #[getter]
717 #[pyo3(name = "position_check_retries")]
718 const fn py_position_check_retries(&self) -> u32 {
719 self.position_check_retries
720 }
721
722 #[getter]
723 #[pyo3(name = "purge_closed_orders_interval_mins")]
724 const fn py_purge_closed_orders_interval_mins(&self) -> Option<u32> {
725 self.purge_closed_orders_interval_mins
726 }
727
728 #[getter]
729 #[pyo3(name = "purge_closed_orders_buffer_mins")]
730 const fn py_purge_closed_orders_buffer_mins(&self) -> Option<u32> {
731 self.purge_closed_orders_buffer_mins
732 }
733
734 #[getter]
735 #[pyo3(name = "purge_closed_positions_interval_mins")]
736 const fn py_purge_closed_positions_interval_mins(&self) -> Option<u32> {
737 self.purge_closed_positions_interval_mins
738 }
739
740 #[getter]
741 #[pyo3(name = "purge_closed_positions_buffer_mins")]
742 const fn py_purge_closed_positions_buffer_mins(&self) -> Option<u32> {
743 self.purge_closed_positions_buffer_mins
744 }
745
746 #[getter]
747 #[pyo3(name = "purge_account_events_interval_mins")]
748 const fn py_purge_account_events_interval_mins(&self) -> Option<u32> {
749 self.purge_account_events_interval_mins
750 }
751
752 #[getter]
753 #[pyo3(name = "purge_account_events_lookback_mins")]
754 const fn py_purge_account_events_lookback_mins(&self) -> Option<u32> {
755 self.purge_account_events_lookback_mins
756 }
757
758 #[getter]
759 #[pyo3(name = "purge_from_database")]
760 const fn py_purge_from_database(&self) -> bool {
761 self.purge_from_database
762 }
763
764 #[getter]
765 #[pyo3(name = "own_books_audit_interval_secs")]
766 const fn py_own_books_audit_interval_secs(&self) -> Option<f64> {
767 self.own_books_audit_interval_secs
768 }
769
770 #[getter]
771 #[pyo3(name = "debug")]
772 const fn py_debug(&self) -> bool {
773 self.debug
774 }
775
776 fn __repr__(&self) -> String {
777 format!("{self:?}")
778 }
779
780 fn __str__(&self) -> String {
781 format!("{self:?}")
782 }
783}
784
785#[pyo3_stub_gen::derive::gen_stub_pymethods]
786#[pymethods]
787impl RoutingConfig {
788 #[new]
790 #[pyo3(signature = (default=None, venues=None))]
791 fn py_new(default: Option<bool>, venues: Option<Vec<String>>) -> Self {
792 Self {
793 default: default.unwrap_or(false),
794 venues,
795 }
796 }
797
798 fn __repr__(&self) -> String {
799 format!("{self:?}")
800 }
801
802 fn __str__(&self) -> String {
803 format!("{self:?}")
804 }
805
806 #[getter]
807 fn default(&self) -> bool {
808 self.default
809 }
810
811 #[getter]
812 fn venues(&self) -> Option<Vec<String>> {
813 self.venues.clone()
814 }
815}
816
817#[pyo3_stub_gen::derive::gen_stub_pymethods]
818#[pymethods]
819impl InstrumentProviderConfig {
820 #[new]
822 #[allow(
823 clippy::needless_pass_by_value,
824 reason = "PyO3 #[new] requires owned params"
825 )]
826 #[pyo3(signature = (load_all=None, load_ids=None, filters=None, filter_callable=None, log_warnings=None))]
827 fn py_new(
828 load_all: Option<bool>,
829 load_ids: Option<Vec<String>>,
830 filters: Option<HashMap<String, Py<PyAny>>>,
831 filter_callable: Option<String>,
832 log_warnings: Option<bool>,
833 ) -> PyResult<Self> {
834 let default = Self::default();
835
836 let filters = match filters {
837 Some(raw) => coerce_json_config(raw)?,
838 None => HashMap::new(),
839 };
840
841 Ok(Self {
842 load_all: load_all.unwrap_or(default.load_all),
843 load_ids,
844 filters,
845 filter_callable,
846 log_warnings: log_warnings.unwrap_or(default.log_warnings),
847 })
848 }
849
850 fn __repr__(&self) -> String {
851 format!("{self:?}")
852 }
853
854 fn __str__(&self) -> String {
855 format!("{self:?}")
856 }
857
858 #[getter]
859 fn load_all(&self) -> bool {
860 self.load_all
861 }
862
863 #[getter]
864 fn load_ids(&self) -> Option<Vec<String>> {
865 self.load_ids.clone()
866 }
867
868 #[getter]
869 fn filters(&self, py: Python<'_>) -> PyResult<Py<PyAny>> {
870 let dict = pyo3::types::PyDict::new(py);
871
872 for (k, v) in &self.filters {
873 let py_val = json_value_to_py(py, v)?;
874 dict.set_item(k, py_val)?;
875 }
876
877 Ok(dict.into_any().unbind())
878 }
879
880 #[getter]
881 fn filter_callable(&self) -> Option<String> {
882 self.filter_callable.clone()
883 }
884
885 #[getter]
886 fn log_warnings(&self) -> bool {
887 self.log_warnings
888 }
889}
890
891#[pyo3_stub_gen::derive::gen_stub_pymethods]
892#[pymethods]
893impl DataClientConfig {
894 #[new]
896 #[gen_stub(override_return_type(type_repr = "typing.Self", imports = ("typing",)))]
897 #[pyo3(signature = (handle_revised_bars=None, instrument_provider=None, routing=None, **_kwargs))]
898 fn py_new(
899 handle_revised_bars: Option<bool>,
900 instrument_provider: Option<InstrumentProviderConfig>,
901 routing: Option<RoutingConfig>,
902 _kwargs: Option<&Bound<'_, PyDict>>,
903 ) -> Self {
904 Self {
905 handle_revised_bars: handle_revised_bars.unwrap_or(false),
906 instrument_provider: instrument_provider.unwrap_or_default(),
907 routing: routing.unwrap_or_default(),
908 }
909 }
910
911 #[pyo3(signature = ())]
912 fn dict(slf: &Bound<'_, Self>) -> PyResult<Py<PyDict>> {
913 Ok(slf
914 .py()
915 .import("nautilus_trader.live.config")?
916 .getattr("config_values")?
917 .call1((slf,))?
918 .cast::<PyDict>()?
919 .clone()
920 .unbind())
921 }
922
923 #[pyo3(signature = ())]
924 fn json(slf: &Bound<'_, Self>) -> PyResult<Py<PyBytes>> {
925 Ok(slf
926 .py()
927 .import("nautilus_trader.live.config")?
928 .getattr("config_json")?
929 .call1((slf,))?
930 .cast::<PyBytes>()?
931 .clone()
932 .unbind())
933 }
934
935 #[pyo3(signature = (factory=None))]
936 fn to_importable(slf: &Bound<'_, Self>, factory: Option<Py<PyAny>>) -> PyResult<Py<PyAny>> {
937 Ok(slf
938 .py()
939 .import("nautilus_trader.live.config")?
940 .getattr("config_importable")?
941 .call1((slf, factory))?
942 .unbind())
943 }
944
945 fn __repr__(&self) -> String {
946 format!("{self:?}")
947 }
948
949 fn __str__(&self) -> String {
950 format!("{self:?}")
951 }
952
953 #[getter]
954 fn handle_revised_bars(&self) -> bool {
955 self.handle_revised_bars
956 }
957
958 #[getter]
959 fn instrument_provider(&self) -> InstrumentProviderConfig {
960 self.instrument_provider.clone()
961 }
962
963 #[getter]
964 fn routing(&self) -> RoutingConfig {
965 self.routing.clone()
966 }
967}
968
969#[pyo3_stub_gen::derive::gen_stub_pymethods]
970#[pymethods]
971impl ExecutionClientConfig {
972 #[new]
974 #[gen_stub(override_return_type(type_repr = "typing.Self", imports = ("typing",)))]
975 #[pyo3(signature = (instrument_provider=None, routing=None, **_kwargs))]
976 fn py_new(
977 instrument_provider: Option<InstrumentProviderConfig>,
978 routing: Option<RoutingConfig>,
979 _kwargs: Option<Bound<'_, PyDict>>,
980 ) -> Self {
981 Self {
982 instrument_provider: instrument_provider.unwrap_or_default(),
983 routing: routing.unwrap_or_default(),
984 }
985 }
986
987 #[pyo3(signature = ())]
988 fn dict(slf: &Bound<'_, Self>) -> PyResult<Py<PyDict>> {
989 Ok(slf
990 .py()
991 .import("nautilus_trader.live.config")?
992 .getattr("config_values")?
993 .call1((slf,))?
994 .cast::<PyDict>()?
995 .clone()
996 .unbind())
997 }
998
999 #[pyo3(signature = ())]
1000 fn json(slf: &Bound<'_, Self>) -> PyResult<Py<PyBytes>> {
1001 Ok(slf
1002 .py()
1003 .import("nautilus_trader.live.config")?
1004 .getattr("config_json")?
1005 .call1((slf,))?
1006 .cast::<PyBytes>()?
1007 .clone()
1008 .unbind())
1009 }
1010
1011 #[pyo3(signature = (factory=None))]
1012 fn to_importable(slf: &Bound<'_, Self>, factory: Option<Py<PyAny>>) -> PyResult<Py<PyAny>> {
1013 Ok(slf
1014 .py()
1015 .import("nautilus_trader.live.config")?
1016 .getattr("config_importable")?
1017 .call1((slf, factory))?
1018 .unbind())
1019 }
1020
1021 fn __repr__(&self) -> String {
1022 format!("{self:?}")
1023 }
1024
1025 fn __str__(&self) -> String {
1026 format!("{self:?}")
1027 }
1028
1029 #[getter]
1030 fn instrument_provider(&self) -> InstrumentProviderConfig {
1031 self.instrument_provider.clone()
1032 }
1033
1034 #[getter]
1035 fn routing(&self) -> RoutingConfig {
1036 self.routing.clone()
1037 }
1038}
1039
1040#[pyo3_stub_gen::derive::gen_stub_pymethods]
1041#[pymethods]
1042impl PluginConfig {
1043 #[new]
1045 #[pyo3(signature = (path, type_name, config=None, sha256=None))]
1046 fn py_new(
1047 path: String,
1048 type_name: String,
1049 config: Option<HashMap<String, Py<PyAny>>>,
1050 sha256: Option<String>,
1051 ) -> PyResult<Self> {
1052 let config = match config {
1053 Some(config) => coerce_json_config(config)?,
1054 None => HashMap::new(),
1055 };
1056
1057 Ok(Self {
1058 path,
1059 type_name,
1060 config,
1061 sha256,
1062 })
1063 }
1064
1065 #[getter]
1066 fn path(&self) -> &str {
1067 &self.path
1068 }
1069
1070 #[getter]
1071 fn type_name(&self) -> &str {
1072 &self.type_name
1073 }
1074
1075 #[getter]
1076 fn config(&self, py: Python<'_>) -> PyResult<Py<PyDict>> {
1077 let dict = PyDict::new(py);
1078
1079 for (key, value) in &self.config {
1080 dict.set_item(key, json_value_to_py(py, value)?)?;
1081 }
1082
1083 Ok(dict.unbind())
1084 }
1085
1086 #[getter]
1087 fn sha256(&self) -> Option<&str> {
1088 self.sha256.as_deref()
1089 }
1090}
1091
1092#[pyo3_stub_gen::derive::gen_stub_pymethods]
1093#[pymethods]
1094impl QueueMonitorConfig {
1095 #[new]
1097 const fn py_new(
1098 queue_depth_trigger: usize,
1099 queue_depth_clear: usize,
1100 mean_dispatch_ns_trigger: u64,
1101 mean_dispatch_ns_clear: u64,
1102 ) -> Self {
1103 Self {
1104 queue_depth_trigger,
1105 queue_depth_clear,
1106 mean_dispatch_ns_trigger,
1107 mean_dispatch_ns_clear,
1108 }
1109 }
1110
1111 fn __repr__(&self) -> String {
1112 format!("{self:?}")
1113 }
1114
1115 fn __str__(&self) -> String {
1116 format!("{self:?}")
1117 }
1118
1119 #[getter]
1120 const fn queue_depth_trigger(&self) -> usize {
1121 self.queue_depth_trigger
1122 }
1123
1124 #[getter]
1125 const fn queue_depth_clear(&self) -> usize {
1126 self.queue_depth_clear
1127 }
1128
1129 #[getter]
1130 const fn mean_dispatch_ns_trigger(&self) -> u64 {
1131 self.mean_dispatch_ns_trigger
1132 }
1133
1134 #[getter]
1135 const fn mean_dispatch_ns_clear(&self) -> u64 {
1136 self.mean_dispatch_ns_clear
1137 }
1138}
1139
1140#[pyo3_stub_gen::derive::gen_stub_pymethods]
1141#[pymethods]
1142impl LiveNodeConfig {
1143 #[new]
1145 #[expect(clippy::too_many_arguments)]
1146 #[pyo3(signature = (environment=None, trader_id=None, load_state=None, save_state=None, shutdown_on_error=None, logging=None, instance_id=None, timeout_connection_secs=None, timeout_reconciliation_secs=None, timeout_portfolio_secs=None, timeout_disconnection_secs=None, delay_post_stop_secs=None, timeout_shutdown_secs=None, cache=None, msgbus=None, portfolio=None, queue_monitor=None, loop_debug=None, data_engine=None, risk_engine=None, exec_engine=None, controller=None, plugins=None, streaming=None, catalogs=None, *, data_clients=None, exec_clients=None))]
1147 fn py_new(
1148 environment: Option<Environment>,
1149 trader_id: Option<TraderId>,
1150 load_state: Option<bool>,
1151 save_state: Option<bool>,
1152 shutdown_on_error: Option<bool>,
1153 logging: Option<LoggerConfig>,
1154 instance_id: Option<UUID4>,
1155 timeout_connection_secs: Option<f64>,
1156 timeout_reconciliation_secs: Option<f64>,
1157 timeout_portfolio_secs: Option<f64>,
1158 timeout_disconnection_secs: Option<f64>,
1159 delay_post_stop_secs: Option<f64>,
1160 timeout_shutdown_secs: Option<f64>,
1161 cache: Option<CacheConfig>,
1162 msgbus: Option<MessageBusConfig>,
1163 portfolio: Option<PortfolioConfig>,
1164 queue_monitor: Option<QueueMonitorConfig>,
1165 loop_debug: Option<bool>,
1166 data_engine: Option<LiveDataEngineConfig>,
1167 risk_engine: Option<LiveRiskEngineConfig>,
1168 exec_engine: Option<LiveExecutionEngineConfig>,
1169 controller: Option<ImportableControllerConfig>,
1170 plugins: Option<Vec<PluginConfig>>,
1171 streaming: Option<StreamingConfig>,
1172 catalogs: Option<Vec<DataCatalogConfig>>,
1173 data_clients: Option<Bound<'_, PyDict>>,
1174 exec_clients: Option<Bound<'_, PyDict>>,
1175 ) -> PyResult<Self> {
1176 let _ = (data_clients, exec_clients);
1177 let default = Self::default();
1178
1179 let to_duration = |value: f64, name: &str| -> PyResult<Duration> {
1180 duration_from_secs_f64(name, value).map_err(config_error_to_pyvalue_err)
1181 };
1182
1183 Ok(Self {
1184 environment: environment.unwrap_or(default.environment),
1185 trader_id: trader_id.unwrap_or(default.trader_id),
1186 load_state: load_state.unwrap_or(default.load_state),
1187 save_state: save_state.unwrap_or(default.save_state),
1188 shutdown_on_error: shutdown_on_error.unwrap_or(default.shutdown_on_error),
1189 logging: logging.unwrap_or(default.logging),
1190 instance_id,
1191 timeout_connection: to_duration(
1192 timeout_connection_secs.unwrap_or(default.timeout_connection.as_secs_f64()),
1193 "timeout_connection_secs",
1194 )?,
1195 timeout_reconciliation: to_duration(
1196 timeout_reconciliation_secs.unwrap_or(default.timeout_reconciliation.as_secs_f64()),
1197 "timeout_reconciliation_secs",
1198 )?,
1199 timeout_portfolio: to_duration(
1200 timeout_portfolio_secs.unwrap_or(default.timeout_portfolio.as_secs_f64()),
1201 "timeout_portfolio_secs",
1202 )?,
1203 timeout_disconnection: to_duration(
1204 timeout_disconnection_secs.unwrap_or(default.timeout_disconnection.as_secs_f64()),
1205 "timeout_disconnection_secs",
1206 )?,
1207 delay_post_stop: to_duration(
1208 delay_post_stop_secs.unwrap_or(default.delay_post_stop.as_secs_f64()),
1209 "delay_post_stop_secs",
1210 )?,
1211 timeout_shutdown: to_duration(
1212 timeout_shutdown_secs.unwrap_or(default.timeout_shutdown.as_secs_f64()),
1213 "timeout_shutdown_secs",
1214 )?,
1215 cache,
1216 msgbus,
1217 portfolio,
1218 emulator: None,
1219 streaming,
1220 catalogs: catalogs.unwrap_or_default(),
1221 queue_monitor,
1222 event_store: None,
1223 loop_debug: loop_debug.unwrap_or(false),
1224 data_engine: data_engine.unwrap_or_default(),
1225 risk_engine: risk_engine.unwrap_or_default(),
1226 exec_engine: exec_engine.unwrap_or_default(),
1227 data_clients: HashMap::new(),
1228 exec_clients: HashMap::new(),
1229 controller,
1230 plugins: plugins.unwrap_or_default(),
1231 })
1232 }
1233
1234 #[gen_stub(skip)]
1235 #[pyo3(signature = (*_args, **kwargs))]
1236 fn __init__(
1237 slf: &Bound<'_, Self>,
1238 _args: &Bound<'_, PyTuple>,
1239 kwargs: Option<&Bound<'_, PyDict>>,
1240 ) -> PyResult<()> {
1241 for name in ["data_clients", "exec_clients"] {
1242 let values = kwargs
1243 .map(|kwargs| kwargs.get_item(name))
1244 .transpose()?
1245 .flatten();
1246
1247 let values = match values {
1248 Some(values) if !values.is_none() => values.cast::<PyDict>()?.copy()?,
1249 _ => PyDict::new(slf.py()),
1250 };
1251
1252 slf.setattr(format!("_{name}"), values)?;
1253 }
1254
1255 Ok(())
1256 }
1257
1258 #[getter]
1259 fn data_clients(slf: &Bound<'_, Self>) -> PyResult<Py<PyDict>> {
1260 let values = slf.getattr("__dict__")?;
1261 let values = values.cast::<PyDict>()?;
1262 match values.get_item("_data_clients")? {
1263 Some(values) => Ok(values.cast::<PyDict>()?.copy()?.unbind()),
1264 None => Ok(slf
1265 .borrow()
1266 .data_clients
1267 .clone()
1268 .into_pyobject(slf.py())?
1269 .unbind()),
1270 }
1271 }
1272
1273 #[getter]
1274 fn exec_clients(slf: &Bound<'_, Self>) -> PyResult<Py<PyDict>> {
1275 let values = slf.getattr("__dict__")?;
1276 let values = values.cast::<PyDict>()?;
1277 match values.get_item("_exec_clients")? {
1278 Some(values) => Ok(values.cast::<PyDict>()?.copy()?.unbind()),
1279 None => Ok(slf
1280 .borrow()
1281 .exec_clients
1282 .clone()
1283 .into_pyobject(slf.py())?
1284 .unbind()),
1285 }
1286 }
1287
1288 fn __repr__(&self) -> String {
1289 format!("{self:?}")
1290 }
1291
1292 fn __str__(&self) -> String {
1293 format!("{self:?}")
1294 }
1295
1296 #[getter]
1297 #[pyo3(name = "streaming")]
1298 fn py_streaming(&self) -> Option<StreamingConfig> {
1299 self.streaming.clone()
1300 }
1301
1302 #[getter]
1303 #[pyo3(name = "catalogs")]
1304 fn py_catalogs(&self) -> Vec<DataCatalogConfig> {
1305 self.catalogs.clone()
1306 }
1307
1308 #[getter]
1309 fn environment(&self) -> Environment {
1310 self.environment
1311 }
1312
1313 #[getter]
1314 fn trader_id(&self) -> TraderId {
1315 self.trader_id
1316 }
1317
1318 #[getter]
1319 fn load_state(&self) -> bool {
1320 self.load_state
1321 }
1322
1323 #[getter]
1324 fn save_state(&self) -> bool {
1325 self.save_state
1326 }
1327
1328 #[getter]
1329 fn shutdown_on_error(&self) -> bool {
1330 self.shutdown_on_error
1331 }
1332
1333 #[getter]
1334 fn timeout_connection_secs(&self) -> f64 {
1335 self.timeout_connection.as_secs_f64()
1336 }
1337
1338 #[getter]
1339 fn timeout_reconciliation_secs(&self) -> f64 {
1340 self.timeout_reconciliation.as_secs_f64()
1341 }
1342
1343 #[getter]
1344 fn timeout_portfolio_secs(&self) -> f64 {
1345 self.timeout_portfolio.as_secs_f64()
1346 }
1347
1348 #[getter]
1349 fn timeout_disconnection_secs(&self) -> f64 {
1350 self.timeout_disconnection.as_secs_f64()
1351 }
1352
1353 #[getter]
1354 fn delay_post_stop_secs(&self) -> f64 {
1355 self.delay_post_stop.as_secs_f64()
1356 }
1357
1358 #[getter]
1359 fn timeout_shutdown_secs(&self) -> f64 {
1360 self.timeout_shutdown.as_secs_f64()
1361 }
1362
1363 #[getter]
1364 #[pyo3(name = "logging")]
1365 fn py_logging(&self) -> LoggerConfig {
1366 self.logging.clone()
1367 }
1368
1369 #[getter]
1370 #[pyo3(name = "instance_id")]
1371 const fn py_instance_id(&self) -> Option<UUID4> {
1372 self.instance_id
1373 }
1374
1375 #[getter]
1376 #[pyo3(name = "cache")]
1377 fn py_cache(&self) -> Option<CacheConfig> {
1378 self.cache.clone()
1379 }
1380
1381 #[getter]
1382 #[pyo3(name = "msgbus")]
1383 fn py_msgbus(&self) -> Option<MessageBusConfig> {
1384 self.msgbus.clone()
1385 }
1386
1387 #[getter]
1388 #[pyo3(name = "portfolio")]
1389 fn py_portfolio(&self) -> Option<PortfolioConfig> {
1390 self.portfolio
1391 }
1392
1393 #[getter]
1394 #[pyo3(name = "queue_monitor")]
1395 fn py_queue_monitor(&self) -> Option<QueueMonitorConfig> {
1396 self.queue_monitor.clone()
1397 }
1398
1399 #[getter]
1400 #[pyo3(name = "loop_debug")]
1401 const fn py_loop_debug(&self) -> bool {
1402 self.loop_debug
1403 }
1404
1405 #[getter]
1406 #[pyo3(name = "data_engine")]
1407 fn py_data_engine(&self) -> LiveDataEngineConfig {
1408 self.data_engine.clone()
1409 }
1410
1411 #[getter]
1412 #[pyo3(name = "risk_engine")]
1413 fn py_risk_engine(&self) -> LiveRiskEngineConfig {
1414 self.risk_engine.clone()
1415 }
1416
1417 #[getter]
1418 #[pyo3(name = "exec_engine")]
1419 fn py_exec_engine(&self) -> LiveExecutionEngineConfig {
1420 self.exec_engine.clone()
1421 }
1422
1423 #[getter]
1424 fn plugins(&self) -> Vec<PluginConfig> {
1425 self.plugins.clone()
1426 }
1427
1428 #[getter]
1429 fn controller(&self) -> Option<ImportableControllerConfig> {
1430 self.controller.clone()
1431 }
1432}
1433
1434#[cfg(test)]
1435mod tests {
1436 use rstest::rstest;
1437
1438 use super::*;
1439
1440 #[rstest]
1441 fn json_value_to_py_preserves_unsigned_integer() {
1442 Python::initialize();
1443 Python::attach(|py| {
1444 let expected = u64::MAX;
1445 let value = serde_json::Value::from(expected);
1446 let result = json_value_to_py(py, &value).expect("JSON value must convert to Python");
1447
1448 assert_eq!(
1449 result
1450 .extract::<u64>(py)
1451 .expect("Python value must remain an unsigned integer"),
1452 expected
1453 );
1454 });
1455 }
1456}