From ef5e23b5dcc63edc29c83e434d998bfb7ad0ae65 Mon Sep 17 00:00:00 2001 From: Carter Green Date: Mon, 18 Mar 2024 11:52:20 -0500 Subject: [PATCH] ADD: Add volatility and delta stat types --- CHANGELOG.md | 4 ++++ python/python/databento_dbn/_lib.pyi | 14 +++++++++++++- rust/dbn/src/enums.rs | 14 +++++++++++++- rust/dbn/src/record/impl_default.rs | 4 ++-- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 053b364..c7f3b17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ ### Enhancements - Added new record type `CbboMsg`, new rtypes and schema types for `Cbbo`, `Cbbo1s`, `Cbbo1m`, `Tcbbo`, `Bbo1s`, and `Bbo1m` +- Added `Volatility` and `Delta` `StatType` variants +- Added `Undefined` and `TimeProRata` `MatchAlgorithm` variants - Exported more enums to Python: - `Action` - `InstrumentClass` @@ -22,6 +24,8 @@ ### Breaking changes - Removed `Default` trait implementation for `Mbp1Msg` due to it now having multiple permissible `rtype` values. Users should use `default_for_schema` instead +- Changed the default `match_algorithm` for `InstrumentDefMsg` and `InstrumentDefMsgV1` + from `Fifo` to `Undefined` ### Bug fixes - Fixed an issue where the Python `MappingIntervalDict` was not exported diff --git a/python/python/databento_dbn/_lib.pyi b/python/python/databento_dbn/_lib.pyi index 7a20777..4f3a922 100644 --- a/python/python/databento_dbn/_lib.pyi +++ b/python/python/databento_dbn/_lib.pyi @@ -141,6 +141,8 @@ class MatchAlgorithm(Enum): The type of matching algorithm used for the instrument at the exchange. + UNDEFINED + No matching algorithm was specified. FIFO First-in-first-out matching. CONFIGURABLE @@ -157,9 +159,12 @@ class MatchAlgorithm(Enum): Like `THRESHOLD_PRO_RATA` but includes a special priority to LMMs. EURODOLLAR_FUTURES Special variant used only for Eurodollar futures on CME. - + TIME_PRO_RATA + Trade quantity is shared between all orders at the best price. Orders with the + highest time priority receive a higher matched quantity. """ + UNDEFINED: str FIFO: str CONFIGURABLE: str PRO_RATA: str @@ -168,6 +173,7 @@ class MatchAlgorithm(Enum): FIFO_TOP_LMM: str THRESHOLD_PRO_RATA_LMM: str EURODOLLAR_FUTURES: str + TIME_PRO_RATA: str @classmethod def from_str(cls, value: str) -> MatchAlgorithm: ... @@ -470,6 +476,10 @@ class StatType(Enum): VWAP The volume-weighted average price (VWAP) during the trading session. `price` will be set to the VWAP while `quantity` will be the traded volume. + VOLATILITY + The implied volatility associated with the settlement price. + DELTA + The option delta associated with the settlement price. """ @@ -486,6 +496,8 @@ class StatType(Enum): CLOSE_PRICE: int NET_CHANGE: int VWAP: int + VOLATILITY: int + DELTA: int @classmethod def variants(cls) -> Iterable[StatType]: ... diff --git a/rust/dbn/src/enums.rs b/rust/dbn/src/enums.rs index 5625561..0e20ea1 100644 --- a/rust/dbn/src/enums.rs +++ b/rust/dbn/src/enums.rs @@ -101,7 +101,7 @@ impl From for char { } /// The type of matching algorithm used for the instrument at the exchange. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, TryFromPrimitive, IntoPrimitive)] +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, TryFromPrimitive, IntoPrimitive)] #[cfg_attr( feature = "python", derive(strum::EnumIter), @@ -110,6 +110,9 @@ impl From for char { #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[repr(u8)] pub enum MatchAlgorithm { + /// No matching algorithm was specified. + #[default] + Undefined = b' ', /// First-in-first-out matching. Fifo = b'F', /// A configurable match algorithm. @@ -130,6 +133,9 @@ pub enum MatchAlgorithm { /// Special variant used only for Eurodollar futures on CME. See /// [CME documentation](https://www.cmegroup.com/confluence/display/EPICSANDBOX/Supported+Matching+Algorithms#SupportedMatchingAlgorithms-Pro-RataAllocationforEurodollarFutures). EurodollarFutures = b'Y', + /// Trade quantity is shared between all orders at the best price. Orders with the + /// highest time priority receive a higher matched quantity. + TimeProRata = b'P', } impl From for char { @@ -833,6 +839,12 @@ pub enum StatType { /// `price` will be set to the VWAP while `quantity` will be the traded /// volume. Vwap = 13, + /// The implied volatility associated with the settlement price. `price` will be set + /// with the standard precision. + Volatility = 14, + /// The option delta associated with the settlement price. `price` will be set with + /// the standard precision. + Delta = 15, } /// The type of [`StatMsg`](crate::record::StatMsg) update. diff --git a/rust/dbn/src/record/impl_default.rs b/rust/dbn/src/record/impl_default.rs index 639d832..e4291d5 100644 --- a/rust/dbn/src/record/impl_default.rs +++ b/rust/dbn/src/record/impl_default.rs @@ -214,7 +214,7 @@ impl Default for InstrumentDefMsg { strike_price_currency: Default::default(), instrument_class: 0, strike_price: UNDEF_PRICE, - match_algorithm: MatchAlgorithm::Fifo as c_char, + match_algorithm: MatchAlgorithm::Undefined as c_char, md_security_trading_status: u8::MAX, main_fraction: u8::MAX, price_display_format: u8::MAX, @@ -283,7 +283,7 @@ impl Default for InstrumentDefMsgV1 { strike_price_currency: Default::default(), instrument_class: 0, strike_price: UNDEF_PRICE, - match_algorithm: MatchAlgorithm::Fifo as c_char, + match_algorithm: MatchAlgorithm::Undefined as c_char, md_security_trading_status: u8::MAX, main_fraction: u8::MAX, price_display_format: u8::MAX,