@@ -177,9 +177,7 @@ static_assert(alignof(TradeMsg) == 8, "Must have 8-byte alignment");
177177struct Mbp1Msg {
178178 static bool HasRType (RType rtype) {
179179 switch (rtype) {
180- case RType::Mbp1: // fallthrough
181- case RType::Bbo1M: // fallthrough
182- case RType::Bbo1S:
180+ case RType::Mbp1:
183181 return true ;
184182 default :
185183 return false ;
@@ -202,8 +200,9 @@ struct Mbp1Msg {
202200 std::array<BidAskPair, 1 > levels;
203201};
204202using TbboMsg = Mbp1Msg;
205- using Bbo1SMsg = Mbp1Msg;
206- using Bbo1MMsg = Mbp1Msg;
203+ static_assert (alignof (Mbp1Msg) == 8 , " Must have 8-byte alignment" );
204+ static_assert (sizeof (Mbp1Msg) == sizeof (TradeMsg) + sizeof (BidAskPair),
205+ " Mbp1Msg size must match Rust" );
207206
208207struct Mbp10Msg {
209208 static bool HasRType (RType rtype) { return rtype == rtype::Mbp10; }
@@ -223,14 +222,40 @@ struct Mbp10Msg {
223222 std::uint32_t sequence;
224223 std::array<BidAskPair, 10 > levels;
225224};
226-
227- static_assert (alignof (Mbp1Msg) == 8 , " Must have 8-byte alignment" );
228225static_assert (alignof (Mbp10Msg) == 8 , " Must have 8-byte alignment" );
229- static_assert (sizeof (Mbp1Msg) == sizeof (TradeMsg) + sizeof (BidAskPair),
230- " Mbp1Msg size must match Rust" );
231226static_assert (sizeof (Mbp10Msg) == sizeof (TradeMsg) + sizeof (BidAskPair) * 10 ,
232227 " Mbp10Msg size must match Rust" );
233228
229+ struct BboMsg {
230+ static bool HasRType (RType rtype) {
231+ switch (rtype) {
232+ case RType::Bbo1S: // fallthrough
233+ case RType::Bbo1M:
234+ return true ;
235+ default :
236+ return false ;
237+ };
238+ }
239+
240+ UnixNanos IndexTs () const { return ts_recv; }
241+
242+ RecordHeader hd;
243+ std::int64_t price;
244+ std::uint32_t size;
245+ char reserved1;
246+ Side side;
247+ FlagSet flags;
248+ char reserved2;
249+ UnixNanos ts_recv;
250+ std::array<char , 4 > reserved3;
251+ std::uint32_t sequence;
252+ std::array<BidAskPair, 1 > levels;
253+ };
254+ using Bbo1SMsg = BboMsg;
255+ using Bbo1MMsg = BboMsg;
256+ static_assert (alignof (BboMsg) == 8 , " Must have 8-byte alignment" );
257+ static_assert (sizeof (BboMsg) == sizeof (Mbp1Msg), " BboMsg size must match Rust" );
258+
234259struct CbboMsg {
235260 static bool HasRType (RType rtype) {
236261 switch (rtype) {
@@ -252,7 +277,7 @@ struct CbboMsg {
252277 Action action;
253278 Side side;
254279 FlagSet flags;
255- std::array< char , 1 > reserved;
280+ char reserved;
256281 UnixNanos ts_recv;
257282 TimeDeltaNanos ts_in_delta;
258283 std::uint32_t sequence;
@@ -571,6 +596,16 @@ inline bool operator!=(const Mbp10Msg& lhs, const Mbp10Msg& rhs) {
571596 return !(lhs == rhs);
572597}
573598
599+ inline bool operator ==(const BboMsg& lhs, const BboMsg& rhs) {
600+ return std::tie (lhs.hd , lhs.price , lhs.size , lhs.side , lhs.flags , lhs.ts_recv ,
601+ lhs.sequence , lhs.levels ) ==
602+ std::tie (rhs.hd , rhs.price , rhs.size , rhs.side , rhs.flags , rhs.ts_recv ,
603+ rhs.sequence , rhs.levels );
604+ }
605+ inline bool operator !=(const BboMsg& lhs, const BboMsg& rhs) {
606+ return !(lhs == rhs);
607+ }
608+
574609inline bool operator ==(const CbboMsg& lhs, const CbboMsg& rhs) {
575610 return lhs.hd == rhs.hd && lhs.price == rhs.price && lhs.size == rhs.size &&
576611 lhs.action == rhs.action && lhs.side == rhs.side &&
@@ -680,8 +715,10 @@ std::string ToString(const Mbp1Msg& mbp_msg);
680715std::ostream& operator <<(std::ostream& stream, const Mbp1Msg& mbp_msg);
681716std::string ToString (const Mbp10Msg& mbp_msg);
682717std::ostream& operator <<(std::ostream& stream, const Mbp10Msg& mbp_msg);
683- std::string ToString (const CbboMsg& mbp_msg);
684- std::ostream& operator <<(std::ostream& stream, const CbboMsg& mbp_msg);
718+ std::string ToString (const BboMsg& bbo_msg);
719+ std::ostream& operator <<(std::ostream& stream, const BboMsg& bbo_msg);
720+ std::string ToString (const CbboMsg& cbbo_msg);
721+ std::ostream& operator <<(std::ostream& stream, const CbboMsg& cbbo_msg);
685722std::string ToString (const TradeMsg& trade_msg);
686723std::ostream& operator <<(std::ostream& stream, const TradeMsg& trade_msg);
687724std::string ToString (const OhlcvMsg& ohlcv_msg);
0 commit comments