Skip to content

Commit

Permalink
FIX: Fix enums and macros for BboMsg
Browse files Browse the repository at this point in the history
  • Loading branch information
threecgreen committed Jul 9, 2024
1 parent e741d48 commit 81215f0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.19.1 - TBD

### Bug fixes
- Update `rtype_dispatch` and `schema_dispatch` macros for `BboMsg`
- Update `RecordEnum` and `RecordRefEnum` for `BboMsg`

## 0.19.0 - 2024-07-09

### Enhancements
Expand Down
3 changes: 2 additions & 1 deletion rust/dbn/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ macro_rules! schema_dispatch_base {
use $crate::record::*;
match $schema {
Schema::Mbo => $handler!(MboMsg),
Schema::Mbp1 | Schema::Tbbo | Schema::Bbo1S | Schema::Bbo1M => $handler!(Mbp1Msg),
Schema::Mbp1 | Schema::Tbbo => $handler!(Mbp1Msg),
Schema::Bbo1S | Schema::Bbo1M => $handler!(BboMsg),
Schema::Mbp10 => $handler!(Mbp10Msg),
Schema::Trades => $handler!(TradeMsg),
Schema::Ohlcv1D
Expand Down
17 changes: 14 additions & 3 deletions rust/dbn/src/record_enum.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
record::CbboMsg, Error, ErrorMsg, ImbalanceMsg, InstrumentDefMsg, MboMsg, Mbp10Msg, Mbp1Msg,
OhlcvMsg, RType, Record, RecordMut, RecordRef, StatMsg, StatusMsg, SymbolMappingMsg, SystemMsg,
TradeMsg,
record::CbboMsg, BboMsg, Error, ErrorMsg, ImbalanceMsg, InstrumentDefMsg, MboMsg, Mbp10Msg,
Mbp1Msg, OhlcvMsg, RType, Record, RecordMut, RecordRef, StatMsg, StatusMsg, SymbolMappingMsg,
SystemMsg, TradeMsg,
};

/// An owned DBN record type of flexible type. Unlike [`RecordRef`], this type allows
Expand Down Expand Up @@ -36,6 +36,8 @@ pub enum RecordEnum {
System(SystemMsg),
/// A consolidated best bid and offer message.
Cbbo(CbboMsg),
/// A subsampled market-by-price message with a book depth of 1.
Bbo(BboMsg),
}

/// An immutable reference to a DBN record of flexible type. Unlike [`RecordRef`], this
Expand Down Expand Up @@ -72,6 +74,8 @@ pub enum RecordRefEnum<'a> {
System(&'a SystemMsg),
/// A reference to a consolidated best bid and offer message.
Cbbo(&'a CbboMsg),
/// A subsampled market-by-price message with a book depth of 1.
Bbo(&'a BboMsg),
}

impl<'a> From<&'a RecordEnum> for RecordRefEnum<'a> {
Expand All @@ -90,6 +94,7 @@ impl<'a> From<&'a RecordEnum> for RecordRefEnum<'a> {
RecordEnum::SymbolMapping(rec) => Self::SymbolMapping(rec),
RecordEnum::System(rec) => Self::System(rec),
RecordEnum::Cbbo(rec) => Self::Cbbo(rec),
RecordEnum::Bbo(rec) => Self::Bbo(rec),
}
}
}
Expand All @@ -112,6 +117,7 @@ impl<'a> RecordRefEnum<'a> {
Self::SymbolMapping(rec) => RecordEnum::from((*rec).clone()),
Self::System(rec) => RecordEnum::from((*rec).clone()),
Self::Cbbo(rec) => RecordEnum::from((*rec).clone()),
Self::Bbo(rec) => RecordEnum::Bbo((*rec).clone()),
}
}
}
Expand Down Expand Up @@ -313,6 +319,7 @@ impl Record for RecordEnum {
RecordEnum::SymbolMapping(rec) => rec.header(),
RecordEnum::System(rec) => rec.header(),
RecordEnum::Cbbo(rec) => rec.header(),
RecordEnum::Bbo(rec) => rec.header(),
}
}

Expand All @@ -331,6 +338,7 @@ impl Record for RecordEnum {
RecordEnum::SymbolMapping(rec) => rec.raw_index_ts(),
RecordEnum::System(rec) => rec.raw_index_ts(),
RecordEnum::Cbbo(rec) => rec.raw_index_ts(),
RecordEnum::Bbo(rec) => rec.raw_index_ts(),
}
}
}
Expand All @@ -351,6 +359,7 @@ impl RecordMut for RecordEnum {
RecordEnum::SymbolMapping(rec) => rec.header_mut(),
RecordEnum::System(rec) => rec.header_mut(),
RecordEnum::Cbbo(rec) => rec.header_mut(),
RecordEnum::Bbo(rec) => rec.header_mut(),
}
}
}
Expand All @@ -371,6 +380,7 @@ impl<'a> Record for RecordRefEnum<'a> {
RecordRefEnum::SymbolMapping(rec) => rec.header(),
RecordRefEnum::System(rec) => rec.header(),
RecordRefEnum::Cbbo(rec) => rec.header(),
RecordRefEnum::Bbo(rec) => rec.header(),
}
}

Expand All @@ -389,6 +399,7 @@ impl<'a> Record for RecordRefEnum<'a> {
RecordRefEnum::SymbolMapping(rec) => rec.raw_index_ts(),
RecordRefEnum::System(rec) => rec.raw_index_ts(),
RecordRefEnum::Cbbo(rec) => rec.raw_index_ts(),
RecordRefEnum::Bbo(rec) => rec.raw_index_ts(),
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions rust/dbn/src/record_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ impl<'a> From<&'a RecordEnum> for RecordRef<'a> {
RecordEnum::SymbolMapping(rec) => Self::from(rec),
RecordEnum::System(rec) => Self::from(rec),
RecordEnum::Cbbo(rec) => Self::from(rec),
RecordEnum::Bbo(rec) => Self::from(rec),
}
}
}
Expand All @@ -187,6 +188,7 @@ impl<'a> From<RecordRefEnum<'a>> for RecordRef<'a> {
RecordRefEnum::SymbolMapping(rec) => Self::from(rec),
RecordRefEnum::System(rec) => Self::from(rec),
RecordRefEnum::Cbbo(rec) => Self::from(rec),
RecordRefEnum::Bbo(rec) => Self::from(rec),
}
}
}
Expand Down

0 comments on commit 81215f0

Please sign in to comment.