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