nautilus_databento/
enums.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2025 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 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/// Represents a Databento statistic type.
25#[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(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.databento")
46)]
47pub enum DatabentoStatisticType {
48    OpeningPrice = 1,
49    IndicativeOpeningPrice = 2,
50    SettlementPrice = 3,
51    TradingSessionLowPrice = 4,
52    TradingSessionHighPrice = 5,
53    ClearedVolume = 6,
54    LowestOffer = 7,
55    HighestBid = 8,
56    OpenInterest = 9,
57    FixingPrice = 10,
58    ClosePrice = 11,
59    NetChange = 12,
60    Vwap = 13,
61}
62
63impl FromU8 for DatabentoStatisticType {
64    fn from_u8(value: u8) -> Option<Self> {
65        match value {
66            1 => Some(Self::OpeningPrice),
67            2 => Some(Self::IndicativeOpeningPrice),
68            3 => Some(Self::SettlementPrice),
69            4 => Some(Self::TradingSessionLowPrice),
70            5 => Some(Self::TradingSessionHighPrice),
71            6 => Some(Self::ClearedVolume),
72            7 => Some(Self::LowestOffer),
73            8 => Some(Self::HighestBid),
74            9 => Some(Self::OpenInterest),
75            10 => Some(Self::FixingPrice),
76            11 => Some(Self::ClosePrice),
77            12 => Some(Self::NetChange),
78            13 => Some(Self::Vwap),
79            _ => None,
80        }
81    }
82}
83
84/// Represents a Databento statistic update action.
85#[repr(C)]
86#[derive(
87    Copy,
88    Clone,
89    Debug,
90    Display,
91    Hash,
92    PartialEq,
93    Eq,
94    PartialOrd,
95    Ord,
96    AsRefStr,
97    FromRepr,
98    EnumIter,
99    EnumString,
100)]
101#[strum(ascii_case_insensitive)]
102#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
103#[cfg_attr(
104    feature = "python",
105    pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.databento")
106)]
107pub enum DatabentoStatisticUpdateAction {
108    Added = 1,
109    Deleted = 2,
110}
111
112impl FromU8 for DatabentoStatisticUpdateAction {
113    fn from_u8(value: u8) -> Option<Self> {
114        match value {
115            1 => Some(Self::Added),
116            2 => Some(Self::Deleted),
117            _ => None,
118        }
119    }
120}
121
122enum_strum_serde!(DatabentoStatisticType);
123enum_strum_serde!(DatabentoStatisticUpdateAction);