Skip to content

Commit

Permalink
ADD: Add volatility and delta stat types
Browse files Browse the repository at this point in the history
  • Loading branch information
threecgreen committed Mar 18, 2024
1 parent 0ae7932 commit ef5e23b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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
Expand Down
14 changes: 13 additions & 1 deletion python/python/databento_dbn/_lib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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: ...
Expand Down Expand Up @@ -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.
"""

Expand All @@ -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]: ...
Expand Down
14 changes: 13 additions & 1 deletion rust/dbn/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl From<InstrumentClass> 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),
Expand All @@ -110,6 +110,9 @@ impl From<InstrumentClass> 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.
Expand All @@ -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<MatchAlgorithm> for char {
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions rust/dbn/src/record/impl_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit ef5e23b

Please sign in to comment.