nautilus_tardis/python/
config.rs1use nautilus_model::{data::BarSpecification, identifiers::InstrumentId};
17use pyo3::prelude::*;
18use ustr::Ustr;
19
20use crate::{
21 enums::Exchange, machine::types::InstrumentMiniInfo, parse::bar_spec_to_tardis_trade_bar_string,
22};
23
24#[pymethods]
25impl InstrumentMiniInfo {
26 #[new]
27 fn py_new(
28 instrument_id: InstrumentId,
29 raw_symbol: String,
30 exchange: String,
31 price_precision: u8,
32 size_precision: u8,
33 ) -> PyResult<Self> {
34 let exchange: Exchange = exchange
35 .parse()
36 .expect("`exchange` should be Tardis convention");
37 Ok(Self::new(
38 instrument_id,
39 Some(Ustr::from(&raw_symbol)),
40 exchange,
41 price_precision,
42 size_precision,
43 ))
44 }
45
46 #[getter]
47 #[pyo3(name = "instrument_id")]
48 const fn py_instrument_id(&self) -> InstrumentId {
49 self.instrument_id
50 }
51
52 #[getter]
53 #[pyo3(name = "raw_symbol")]
54 fn py_raw_symbol(&self) -> String {
55 self.raw_symbol.to_string()
56 }
57
58 #[getter]
59 #[pyo3(name = "exchange")]
60 fn py_exchange(&self) -> String {
61 self.exchange.to_string()
62 }
63
64 #[getter]
65 #[pyo3(name = "price_precision")]
66 const fn py_price_precision(&self) -> u8 {
67 self.price_precision
68 }
69
70 #[getter]
71 #[pyo3(name = "size_precision")]
72 const fn py_size_precision(&self) -> u8 {
73 self.size_precision
74 }
75}
76
77#[must_use]
78#[pyfunction(name = "bar_spec_to_tardis_trade_bar_string")]
79pub fn py_bar_spec_to_tardis_trade_bar_string(bar_spec: &BarSpecification) -> String {
80 bar_spec_to_tardis_trade_bar_string(bar_spec)
81}