nautilus_tardis/machine/
types.rs1use jiff::civil::Date;
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.adapters.tardis", from_py_object)
29)]
30#[cfg_attr(
31 feature = "python",
32 pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.adapters.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.adapters.tardis", from_py_object)
79)]
80pub struct TardisInstrumentKey {
81 pub raw_symbol: Ustr,
83 pub exchange: TardisExchange,
85}
86
87impl TardisInstrumentKey {
88 #[must_use]
90 pub const fn new(raw_symbol: Ustr, exchange: TardisExchange) -> Self {
91 Self {
92 raw_symbol,
93 exchange,
94 }
95 }
96}
97
98#[derive(Debug, Clone, Serialize, Deserialize)]
100#[serde(rename_all = "camelCase")]
101#[cfg_attr(
102 feature = "python",
103 pyo3::pyclass(module = "nautilus_trader.adapters.tardis", from_py_object)
104)]
105#[cfg_attr(
106 feature = "python",
107 pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.adapters.tardis")
108)]
109pub struct ReplayNormalizedRequestOptions {
110 pub exchange: TardisExchange,
112 #[serde(skip_serializing_if = "Option::is_none")]
115 #[serde(default)]
116 pub symbols: Option<Vec<String>>,
117 pub from: Date,
119 pub to: Date,
121 #[serde(alias = "data_types")]
124 pub data_types: Vec<String>,
125 #[serde(skip_serializing_if = "Option::is_none")]
128 #[serde(default)]
129 #[serde(alias = "with_disconnect_messages")]
130 pub with_disconnect_messages: Option<bool>,
131}
132
133#[derive(Debug, Clone, Serialize, Deserialize)]
135#[serde(rename_all = "camelCase")]
136#[cfg_attr(
137 feature = "python",
138 pyo3::pyclass(module = "nautilus_trader.adapters.tardis", from_py_object)
139)]
140#[cfg_attr(
141 feature = "python",
142 pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.adapters.tardis")
143)]
144pub struct StreamNormalizedRequestOptions {
145 pub exchange: TardisExchange,
147 #[serde(skip_serializing_if = "Option::is_none")]
149 #[serde(default)]
150 pub symbols: Option<Vec<String>>,
151 #[serde(alias = "data_types")]
154 pub data_types: Vec<String>,
155 #[serde(skip_serializing_if = "Option::is_none")]
158 #[serde(default)]
159 pub with_disconnect_messages: Option<bool>,
160 #[serde(skip_serializing_if = "Option::is_none")]
163 #[serde(default, rename = "timeoutIntervalMS")]
164 pub timeout_interval_ms: Option<u64>,
165}