nautilus_databento/
enums.rs1use std::str::FromStr;
19
20use nautilus_model::{enum_strum_serde, enums::FromU8};
21use serde::{Deserialize, Deserializer, Serialize, Serializer};
22use strum::{AsRefStr, Display, EnumIter, EnumString, FromRepr};
23
24#[repr(C)]
26#[derive(
27 Copy,
28 Clone,
29 Debug,
30 Display,
31 Hash,
32 PartialEq,
33 Eq,
34 PartialOrd,
35 Ord,
36 AsRefStr,
37 FromRepr,
38 EnumIter,
39 EnumString,
40)]
41#[strum(ascii_case_insensitive)]
42#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
43#[cfg_attr(
44 feature = "python",
45 pyo3::pyclass(
46 eq,
47 eq_int,
48 rename_all = "SCREAMING_SNAKE_CASE",
49 module = "nautilus_trader.core.nautilus_pyo3.databento",
50 from_py_object
51 )
52)]
53#[cfg_attr(
54 feature = "python",
55 pyo3_stub_gen::derive::gen_stub_pyclass_enum(module = "nautilus_trader.databento")
56)]
57pub enum DatabentoStatisticType {
58 OpeningPrice = 1,
59 IndicativeOpeningPrice = 2,
60 SettlementPrice = 3,
61 TradingSessionLowPrice = 4,
62 TradingSessionHighPrice = 5,
63 ClearedVolume = 6,
64 LowestOffer = 7,
65 HighestBid = 8,
66 OpenInterest = 9,
67 FixingPrice = 10,
68 ClosePrice = 11,
69 NetChange = 12,
70 Vwap = 13,
71}
72
73impl FromU8 for DatabentoStatisticType {
74 fn from_u8(value: u8) -> Option<Self> {
75 match value {
76 1 => Some(Self::OpeningPrice),
77 2 => Some(Self::IndicativeOpeningPrice),
78 3 => Some(Self::SettlementPrice),
79 4 => Some(Self::TradingSessionLowPrice),
80 5 => Some(Self::TradingSessionHighPrice),
81 6 => Some(Self::ClearedVolume),
82 7 => Some(Self::LowestOffer),
83 8 => Some(Self::HighestBid),
84 9 => Some(Self::OpenInterest),
85 10 => Some(Self::FixingPrice),
86 11 => Some(Self::ClosePrice),
87 12 => Some(Self::NetChange),
88 13 => Some(Self::Vwap),
89 _ => None,
90 }
91 }
92}
93
94#[repr(C)]
96#[derive(
97 Copy,
98 Clone,
99 Debug,
100 Display,
101 Hash,
102 PartialEq,
103 Eq,
104 PartialOrd,
105 Ord,
106 AsRefStr,
107 FromRepr,
108 EnumIter,
109 EnumString,
110)]
111#[strum(ascii_case_insensitive)]
112#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
113#[cfg_attr(
114 feature = "python",
115 pyo3::pyclass(
116 eq,
117 eq_int,
118 rename_all = "SCREAMING_SNAKE_CASE",
119 module = "nautilus_trader.core.nautilus_pyo3.databento",
120 from_py_object
121 )
122)]
123#[cfg_attr(
124 feature = "python",
125 pyo3_stub_gen::derive::gen_stub_pyclass_enum(module = "nautilus_trader.databento")
126)]
127pub enum DatabentoStatisticUpdateAction {
128 Added = 1,
129 Deleted = 2,
130}
131
132impl FromU8 for DatabentoStatisticUpdateAction {
133 fn from_u8(value: u8) -> Option<Self> {
134 match value {
135 1 => Some(Self::Added),
136 2 => Some(Self::Deleted),
137 _ => None,
138 }
139 }
140}
141
142enum_strum_serde!(DatabentoStatisticType);
143enum_strum_serde!(DatabentoStatisticUpdateAction);