Skip to main content

nautilus_databento/
enums.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2026 Nautech Systems Pty Ltd. All rights reserved.
3//  https://nautechsystems.io
4//
5//  Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6//  You may not use this file except in compliance with the License.
7//  You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9//  Unless required by applicable law or agreed to in writing, software
10//  distributed under the License is distributed on an "AS IS" BASIS,
11//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//  See the License for the specific language governing permissions and
13//  limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16//! Enumerations for the Databento integration.
17
18use nautilus_model::{enum_strum_serde, enums::FromU8};
19use strum::{AsRefStr, Display, EnumIter, EnumString, FromRepr};
20
21/// Represents a Databento statistic type.
22#[repr(C)]
23#[derive(
24    Copy,
25    Clone,
26    Debug,
27    Display,
28    Hash,
29    PartialEq,
30    Eq,
31    PartialOrd,
32    Ord,
33    AsRefStr,
34    FromRepr,
35    EnumIter,
36    EnumString,
37)]
38#[strum(ascii_case_insensitive)]
39#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
40#[cfg_attr(
41    feature = "python",
42    pyo3::pyclass(
43        eq,
44        eq_int,
45        rename_all = "SCREAMING_SNAKE_CASE",
46        module = "nautilus_trader.adapters.databento",
47        from_py_object
48    )
49)]
50#[cfg_attr(
51    feature = "python",
52    pyo3_stub_gen::derive::gen_stub_pyclass_enum(module = "nautilus_trader.adapters.databento")
53)]
54pub enum DatabentoStatisticType {
55    OpeningPrice = 1,
56    IndicativeOpeningPrice = 2,
57    SettlementPrice = 3,
58    TradingSessionLowPrice = 4,
59    TradingSessionHighPrice = 5,
60    ClearedVolume = 6,
61    LowestOffer = 7,
62    HighestBid = 8,
63    OpenInterest = 9,
64    FixingPrice = 10,
65    ClosePrice = 11,
66    NetChange = 12,
67    Vwap = 13,
68    Volatility = 14,
69    Delta = 15,
70    UncrossingPrice = 16,
71    UpperPriceLimit = 17,
72    LowerPriceLimit = 18,
73    BlockVolume = 19,
74    IndicativeClosePrice = 20,
75}
76
77impl FromU8 for DatabentoStatisticType {
78    fn from_u8(value: u8) -> Option<Self> {
79        match value {
80            1 => Some(Self::OpeningPrice),
81            2 => Some(Self::IndicativeOpeningPrice),
82            3 => Some(Self::SettlementPrice),
83            4 => Some(Self::TradingSessionLowPrice),
84            5 => Some(Self::TradingSessionHighPrice),
85            6 => Some(Self::ClearedVolume),
86            7 => Some(Self::LowestOffer),
87            8 => Some(Self::HighestBid),
88            9 => Some(Self::OpenInterest),
89            10 => Some(Self::FixingPrice),
90            11 => Some(Self::ClosePrice),
91            12 => Some(Self::NetChange),
92            13 => Some(Self::Vwap),
93            14 => Some(Self::Volatility),
94            15 => Some(Self::Delta),
95            16 => Some(Self::UncrossingPrice),
96            17 => Some(Self::UpperPriceLimit),
97            18 => Some(Self::LowerPriceLimit),
98            19 => Some(Self::BlockVolume),
99            20 => Some(Self::IndicativeClosePrice),
100            _ => None,
101        }
102    }
103}
104
105/// Represents a Databento statistic update action.
106#[repr(C)]
107#[derive(
108    Copy,
109    Clone,
110    Debug,
111    Display,
112    Hash,
113    PartialEq,
114    Eq,
115    PartialOrd,
116    Ord,
117    AsRefStr,
118    FromRepr,
119    EnumIter,
120    EnumString,
121)]
122#[strum(ascii_case_insensitive)]
123#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
124#[cfg_attr(
125    feature = "python",
126    pyo3::pyclass(
127        eq,
128        eq_int,
129        rename_all = "SCREAMING_SNAKE_CASE",
130        module = "nautilus_trader.adapters.databento",
131        from_py_object
132    )
133)]
134#[cfg_attr(
135    feature = "python",
136    pyo3_stub_gen::derive::gen_stub_pyclass_enum(module = "nautilus_trader.adapters.databento")
137)]
138pub enum DatabentoStatisticUpdateAction {
139    Added = 1,
140    Deleted = 2,
141}
142
143impl FromU8 for DatabentoStatisticUpdateAction {
144    fn from_u8(value: u8) -> Option<Self> {
145        match value {
146            1 => Some(Self::Added),
147            2 => Some(Self::Deleted),
148            _ => None,
149        }
150    }
151}
152
153enum_strum_serde!(DatabentoStatisticType);
154enum_strum_serde!(DatabentoStatisticUpdateAction);