nautilus_tardis/machine/
types.rs1use chrono::NaiveDate;
17use nautilus_model::identifiers::InstrumentId;
18use serde::{Deserialize, Serialize};
19use ustr::Ustr;
20
21use crate::common::enums::TardisExchange;
22pub use crate::machine::client::TardisMachineClient;
23
24#[derive(Clone, Debug, Serialize, Deserialize)]
26#[cfg_attr(
27 feature = "python",
28 pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.tardis", from_py_object)
29)]
30#[cfg_attr(
31 feature = "python",
32 pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.tardis")
33)]
34pub struct TardisInstrumentMiniInfo {
35 pub instrument_id: InstrumentId,
37 pub raw_symbol: Ustr,
39 pub exchange: TardisExchange,
41 pub price_precision: u8,
43 pub size_precision: u8,
45}
46
47impl TardisInstrumentMiniInfo {
48 #[must_use]
52 pub fn new(
53 instrument_id: InstrumentId,
54 raw_symbol: Option<Ustr>,
55 exchange: TardisExchange,
56 price_precision: u8,
57 size_precision: u8,
58 ) -> Self {
59 Self {
60 instrument_id,
61 raw_symbol: raw_symbol.unwrap_or(instrument_id.symbol.inner()),
62 exchange,
63 price_precision,
64 size_precision,
65 }
66 }
67
68 #[must_use]
69 pub const fn as_tardis_instrument_key(&self) -> TardisInstrumentKey {
70 TardisInstrumentKey::new(self.raw_symbol, self.exchange)
71 }
72}
73
74#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
76#[cfg_attr(
77 feature = "python",
78 pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.tardis", from_py_object)
79)]
80#[cfg_attr(
81 feature = "python",
82 pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.tardis")
83)]
84pub struct TardisInstrumentKey {
85 pub raw_symbol: Ustr,
87 pub exchange: TardisExchange,
89}
90
91impl TardisInstrumentKey {
92 #[must_use]
94 pub const fn new(raw_symbol: Ustr, exchange: TardisExchange) -> Self {
95 Self {
96 raw_symbol,
97 exchange,
98 }
99 }
100}
101
102#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(rename_all = "camelCase")]
105#[cfg_attr(
106 feature = "python",
107 pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.tardis", from_py_object)
108)]
109#[cfg_attr(
110 feature = "python",
111 pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.tardis")
112)]
113pub struct ReplayNormalizedRequestOptions {
114 pub exchange: TardisExchange,
116 #[serde(skip_serializing_if = "Option::is_none")]
119 #[serde(default)]
120 pub symbols: Option<Vec<String>>,
121 pub from: NaiveDate,
123 pub to: NaiveDate,
125 #[serde(alias = "data_types")]
128 pub data_types: Vec<String>,
129 #[serde(skip_serializing_if = "Option::is_none")]
132 #[serde(default)]
133 #[serde(alias = "with_disconnect_messages")]
134 pub with_disconnect_messages: Option<bool>,
135}
136
137#[derive(Debug, Clone, Serialize, Deserialize)]
139#[serde(rename_all = "camelCase")]
140#[cfg_attr(
141 feature = "python",
142 pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.tardis", from_py_object)
143)]
144#[cfg_attr(
145 feature = "python",
146 pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.tardis")
147)]
148pub struct StreamNormalizedRequestOptions {
149 pub exchange: TardisExchange,
151 #[serde(skip_serializing_if = "Option::is_none")]
153 #[serde(default)]
154 pub symbols: Option<Vec<String>>,
155 #[serde(alias = "data_types")]
158 pub data_types: Vec<String>,
159 #[serde(skip_serializing_if = "Option::is_none")]
162 #[serde(default)]
163 pub with_disconnect_messages: Option<bool>,
164 #[serde(skip_serializing_if = "Option::is_none")]
167 #[serde(default, rename = "timeoutIntervalMS")]
168 pub timeout_interval_ms: Option<u64>,
169}