1use 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.adapters.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 Volatility = 14,
72 Delta = 15,
73 UncrossingPrice = 16,
74 UpperPriceLimit = 17,
75 LowerPriceLimit = 18,
76 BlockVolume = 19,
77 IndicativeClosePrice = 20,
78}
79
80impl FromU8 for DatabentoStatisticType {
81 fn from_u8(value: u8) -> Option<Self> {
82 match value {
83 1 => Some(Self::OpeningPrice),
84 2 => Some(Self::IndicativeOpeningPrice),
85 3 => Some(Self::SettlementPrice),
86 4 => Some(Self::TradingSessionLowPrice),
87 5 => Some(Self::TradingSessionHighPrice),
88 6 => Some(Self::ClearedVolume),
89 7 => Some(Self::LowestOffer),
90 8 => Some(Self::HighestBid),
91 9 => Some(Self::OpenInterest),
92 10 => Some(Self::FixingPrice),
93 11 => Some(Self::ClosePrice),
94 12 => Some(Self::NetChange),
95 13 => Some(Self::Vwap),
96 14 => Some(Self::Volatility),
97 15 => Some(Self::Delta),
98 16 => Some(Self::UncrossingPrice),
99 17 => Some(Self::UpperPriceLimit),
100 18 => Some(Self::LowerPriceLimit),
101 19 => Some(Self::BlockVolume),
102 20 => Some(Self::IndicativeClosePrice),
103 _ => None,
104 }
105 }
106}
107
108#[repr(C)]
110#[derive(
111 Copy,
112 Clone,
113 Debug,
114 Display,
115 Hash,
116 PartialEq,
117 Eq,
118 PartialOrd,
119 Ord,
120 AsRefStr,
121 FromRepr,
122 EnumIter,
123 EnumString,
124)]
125#[strum(ascii_case_insensitive)]
126#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
127#[cfg_attr(
128 feature = "python",
129 pyo3::pyclass(
130 eq,
131 eq_int,
132 rename_all = "SCREAMING_SNAKE_CASE",
133 module = "nautilus_trader.core.nautilus_pyo3.databento",
134 from_py_object
135 )
136)]
137#[cfg_attr(
138 feature = "python",
139 pyo3_stub_gen::derive::gen_stub_pyclass_enum(module = "nautilus_trader.adapters.databento")
140)]
141pub enum DatabentoStatisticUpdateAction {
142 Added = 1,
143 Deleted = 2,
144}
145
146impl FromU8 for DatabentoStatisticUpdateAction {
147 fn from_u8(value: u8) -> Option<Self> {
148 match value {
149 1 => Some(Self::Added),
150 2 => Some(Self::Deleted),
151 _ => None,
152 }
153 }
154}
155
156enum_strum_serde!(DatabentoStatisticType);
157enum_strum_serde!(DatabentoStatisticUpdateAction);