1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
mod order;
pub mod proto;
pub use crate::order::Order;
use crypto_market_type::MarketType;
use crypto_msg_type::MessageType;
use serde::{Deserialize, Serialize};
use std::str::FromStr;
use strum_macros::{Display, EnumString};
#[derive(Eq, PartialEq)]
pub enum Message {
Trade(TradeMsg),
Bbo(BboMsg),
Level2(OrderBookMsg),
FundingRate(FundingRateMsg),
Candlestick(CandlestickMsg),
Ticker(TickerMsg),
}
macro_rules! add_common_fields {
(
$(#[$outer:meta])*
struct $name:ident {
$(
$(#[$inner:meta])*
$field:ident: $ty:ty
),* $(,)*
}
) => {
$(#[$outer])*
pub struct $name {
pub exchange: String,
pub market_type: MarketType,
pub symbol: String,
pub pair: String,
pub msg_type: MessageType,
pub timestamp: i64,
pub json: String,
$(
$(#[$inner])*
pub $field: $ty
),*
}
};
}
#[derive(Copy, Clone, Eq, PartialEq, Serialize, Deserialize, Display, Debug, EnumString)]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum TradeSide {
Buy,
Sell,
}
#[derive(Serialize, Deserialize)]
pub struct TradeMsg {
pub exchange: String,
pub market_type: MarketType,
pub msg_type: MessageType,
pub pair: String,
pub symbol: String,
pub timestamp: i64,
pub side: TradeSide,
pub price: f64,
pub quantity_base: f64,
pub quantity_quote: f64,
#[serde(skip_serializing_if = "Option::is_none")]
pub quantity_contract: Option<f64>,
pub trade_id: String,
pub json: String,
}
#[derive(Serialize, Deserialize)]
pub struct OrderBookMsg {
pub exchange: String,
pub market_type: MarketType,
pub symbol: String,
pub pair: String,
pub msg_type: MessageType,
pub timestamp: i64,
pub snapshot: bool,
pub asks: Vec<Order>,
pub bids: Vec<Order>,
#[serde(skip_serializing_if = "Option::is_none")]
pub seq_id: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub prev_seq_id: Option<u64>,
pub json: String,
}
#[derive(Serialize, Deserialize)]
pub struct FundingRateMsg {
pub exchange: String,
pub market_type: MarketType,
pub symbol: String,
pub pair: String,
pub msg_type: MessageType,
pub timestamp: i64,
pub funding_rate: f64,
pub funding_time: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub estimated_rate: Option<f64>,
pub json: String,
}
add_common_fields!(
#[derive(Serialize, Deserialize)]
struct TickerMsg {
open: f64,
high: f64,
low: f64,
close: f64,
volume: f64,
quote_volume: f64,
last_quantity: Option<f64>,
best_bid_price: Option<f64>,
best_bid_quantity: Option<f64>,
best_ask_price: Option<f64>,
best_ask_quantity: Option<f64>,
open_interest: Option<f64>,
open_interest_quote: Option<f64>,
}
);
add_common_fields!(
#[derive(Serialize, Deserialize)]
struct BboMsg {
bid_price: f64,
bid_quantity_base: f64,
bid_quantity_quote: f64,
bid_quantity_contract: Option<f64>,
ask_price: f64,
ask_quantity_base: f64,
ask_quantity_quote: f64,
ask_quantity_contract: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
id: Option<u64>,
}
);
add_common_fields!(
#[derive(Serialize, Deserialize)]
struct CandlestickMsg {
open: f64,
high: f64,
low: f64,
close: f64,
volume: f64,
period: String,
quote_volume: Option<f64>,
}
);
const PRECISION: f64 = 1000000000.0;
fn round(f: f64) -> f64 {
(f * PRECISION).round() / PRECISION
}
impl TradeMsg {
pub fn to_csv_string(&self) -> String {
format!(
"{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}",
self.timestamp,
self.side,
self.price,
round(self.quantity_base),
round(self.quantity_quote),
if let Some(x) = self.quantity_contract {
round(x).to_string()
} else {
"".to_string()
},
self.trade_id,
self.json
)
}
pub fn from_csv_string(
exchange: &str,
market_type: &str,
msg_type: &str,
pair: &str,
symbol: &str,
s: &str,
) -> Self {
let v: Vec<&str> = s.split('\t').collect();
assert_eq!(8, v.len());
let market_type = MarketType::from_str(market_type).unwrap();
let msg_type = MessageType::from_str(msg_type).unwrap();
let side = TradeSide::from_str(v[1]).unwrap();
let price = v[2].parse::<f64>().unwrap();
let quantity_base = v[3].parse::<f64>().unwrap();
let quantity_quote = v[4].parse::<f64>().unwrap();
let quantity_contract = if v[5].is_empty() {
None
} else {
Some(v[5].parse::<f64>().unwrap())
};
TradeMsg {
exchange: exchange.to_string(),
market_type,
msg_type,
pair: pair.to_string(),
symbol: symbol.to_string(),
timestamp: v[0].parse::<i64>().unwrap(),
price,
quantity_base,
quantity_quote,
quantity_contract,
side,
trade_id: v[6].to_string(),
json: v[7].to_string(),
}
}
pub fn to_proto(&self) -> crate::proto::Trade {
let mut proto_msg = crate::proto::Trade::new();
let mut timestamp = protobuf::well_known_types::timestamp::Timestamp::new();
timestamp.seconds = self.timestamp / 1000_i64;
timestamp.nanos = (self.timestamp % 1000 * 1000000) as i32;
proto_msg.timestamp = protobuf::MessageField::some(timestamp);
proto_msg.side = self.side == TradeSide::Sell;
proto_msg.price = self.price as f32;
proto_msg.quantity_base = self.quantity_base as f32;
proto_msg.quantity_quote = self.quantity_quote as f32;
proto_msg.quantity_contract = self.quantity_contract.map(|x| x as f32);
proto_msg
}
pub fn from_proto(
exchange: &str,
market_type: &str,
msg_type: &str,
pair: &str,
symbol: &str,
proto_msg: &crate::proto::Trade,
) -> Self {
let market_type = MarketType::from_str(market_type).unwrap();
let msg_type = MessageType::from_str(msg_type).unwrap();
let side = if proto_msg.side {
TradeSide::Sell
} else {
TradeSide::Buy
};
let timestamp =
proto_msg.timestamp.seconds * 1000 + (proto_msg.timestamp.nanos / 1000000) as i64;
TradeMsg {
exchange: exchange.to_string(),
market_type,
msg_type,
pair: pair.to_string(),
symbol: symbol.to_string(),
timestamp,
price: proto_msg.price as f64,
quantity_base: proto_msg.quantity_base as f64,
quantity_quote: proto_msg.quantity_quote as f64,
quantity_contract: proto_msg.quantity_contract.map(|x| x as f64),
side,
trade_id: "".to_string(),
json: "".to_string(),
}
}
}
impl OrderBookMsg {
pub fn to_csv_string(&self) -> String {
format!(
"{}\t{}\t{}\t{}\t{}\t{}",
self.timestamp,
self.snapshot,
serde_json::to_string(&self.asks).unwrap(),
serde_json::to_string(&self.bids).unwrap(),
self.seq_id.map(|x| x.to_string()).unwrap_or_default(),
self.prev_seq_id.map(|x| x.to_string()).unwrap_or_default()
)
}
pub fn from_csv_string(
exchange: &str,
market_type: &str,
msg_type: &str,
pair: &str,
symbol: &str,
s: &str,
) -> Self {
let v: Vec<&str> = s.split('\t').collect();
assert_eq!(6, v.len());
let market_type = MarketType::from_str(market_type).unwrap();
let msg_type = MessageType::from_str(msg_type).unwrap();
let asks = serde_json::from_str::<Vec<Order>>(v[2]).unwrap();
let bids = serde_json::from_str::<Vec<Order>>(v[3]).unwrap();
let seq_id = if v[4].is_empty() {
None
} else {
Some(v[4].parse::<u64>().unwrap())
};
let prev_seq_id = if v[5].is_empty() {
None
} else {
Some(v[5].parse::<u64>().unwrap())
};
OrderBookMsg {
exchange: exchange.to_string(),
market_type,
msg_type,
pair: pair.to_string(),
symbol: symbol.to_string(),
timestamp: v[0].parse::<i64>().unwrap(),
snapshot: v[1].parse::<bool>().unwrap(),
asks,
bids,
seq_id,
prev_seq_id,
json: "".to_string(),
}
}
pub fn to_proto(&self) -> crate::proto::Orderbook {
let mut proto_msg = crate::proto::Orderbook::new();
let mut timestamp = protobuf::well_known_types::timestamp::Timestamp::new();
timestamp.seconds = self.timestamp / 1000_i64;
timestamp.nanos = (self.timestamp % 1000 * 1000000) as i32;
proto_msg.timestamp = protobuf::MessageField::some(timestamp);
proto_msg.snapshot = self.snapshot;
proto_msg.asks = proto_msg
.asks
.iter()
.map(|order| {
let mut o = crate::proto::Order::new();
o.price = order.price as f32;
o.quantity_base = order.quantity_base as f32;
o.quantity_quote = order.quantity_quote as f32;
o.quantity_contract = order.quantity_contract.map(|x| x as f32);
o
})
.collect();
proto_msg.bids = proto_msg
.bids
.iter()
.map(|order| {
let mut o = crate::proto::Order::new();
o.price = order.price as f32;
o.quantity_base = order.quantity_base as f32;
o.quantity_quote = order.quantity_quote as f32;
o.quantity_contract = order.quantity_contract.map(|x| x as f32);
o
})
.collect();
proto_msg
}
pub fn from_proto(
exchange: &str,
market_type: &str,
msg_type: &str,
pair: &str,
symbol: &str,
proto_msg: &crate::proto::Orderbook,
) -> Self {
let market_type = MarketType::from_str(market_type).unwrap();
let msg_type = MessageType::from_str(msg_type).unwrap();
let timestamp =
proto_msg.timestamp.seconds * 1000 + (proto_msg.timestamp.nanos / 1000000) as i64;
let asks = proto_msg
.asks
.iter()
.map(|order| Order {
price: order.price as f64,
quantity_base: order.quantity_base as f64,
quantity_quote: order.quantity_quote as f64,
quantity_contract: order.quantity_contract.map(|x| x as f64),
})
.collect();
let bids = proto_msg
.bids
.iter()
.map(|order| Order {
price: order.price as f64,
quantity_base: order.quantity_base as f64,
quantity_quote: order.quantity_quote as f64,
quantity_contract: order.quantity_contract.map(|x| x as f64),
})
.collect();
OrderBookMsg {
exchange: exchange.to_string(),
market_type,
msg_type,
pair: pair.to_string(),
symbol: symbol.to_string(),
timestamp,
snapshot: proto_msg.snapshot,
asks,
bids,
seq_id: None,
prev_seq_id: None,
json: "".to_string(),
}
}
}
#[cfg(test)]
mod tests {
use super::{Order, OrderBookMsg, TradeMsg, TradeSide};
use crypto_market_type::MarketType;
use crypto_msg_type::MessageType;
#[test]
fn test_trade() {
let trade_msg = TradeMsg {
exchange: "binance".to_string(),
market_type: MarketType::LinearSwap,
symbol: "BTCUSDT".to_string(),
pair: "BTC/USDT".to_string(),
msg_type: MessageType::Trade,
timestamp: 1646092800027,
side: TradeSide::Sell,
price: 43150.8,
quantity_base: 0.001,
quantity_quote: 43.1508,
quantity_contract: Some(0.001),
trade_id: "1108933367".to_string(),
json: r#"{"stream":"btcusdt@aggTrade","data":{"e":"aggTrade","E":1646092800098,"a":1108933367,"s":"BTCUSDT","p":"43150.80","q":"0.001","f":1987119093,"l":1987119093,"T":1646092800027,"m":true}}"#.to_string(),
};
let csv_string = trade_msg.to_csv_string();
let csv_string_expected = r#"1646092800027 sell 43150.8 0.001 43.1508 0.001 1108933367 {"stream":"btcusdt@aggTrade","data":{"e":"aggTrade","E":1646092800098,"a":1108933367,"s":"BTCUSDT","p":"43150.80","q":"0.001","f":1987119093,"l":1987119093,"T":1646092800027,"m":true}}"#;
assert_eq!(csv_string_expected, csv_string);
let trade_msg_restored = TradeMsg::from_csv_string(
"binance",
"linear_swap",
"trade",
"BTC/USDT",
"BTCUSDT",
&csv_string,
);
assert_eq!(
serde_json::to_string(&trade_msg).unwrap(),
serde_json::to_string(&trade_msg_restored).unwrap()
);
}
#[test]
fn test_l2_event() {
let orderbook_msg = OrderBookMsg {
exchange: "binance".to_string(),
market_type: MarketType::LinearSwap,
symbol: "BTCUSDT".to_string(),
pair: "BTC/USDT".to_string(),
msg_type: MessageType::L2Event,
timestamp: 1648785270714,
snapshot: false,
asks: vec![
Order {
price: 44405.4,
quantity_base: 0.0,
quantity_quote: 0.0,
quantity_contract: Some(0.0),
},
Order {
price: 44427.2,
quantity_base: 0.0,
quantity_quote: 0.0,
quantity_contract: Some(0.0),
},
],
bids: vec![
Order {
price: 43633.4,
quantity_base: 4.515,
quantity_quote: 197004.801,
quantity_contract: Some(4.515),
},
Order {
price: 43855.6,
quantity_base: 6.058,
quantity_quote: 265677.2248,
quantity_contract: Some(6.058),
},
],
seq_id: Some(1343268964711_u64),
prev_seq_id: Some(1343268961876_u64),
json: "".to_string(),
};
let csv_string = orderbook_msg.to_csv_string();
let csv_string_expected = r#"1648785270714 false [[44405.4,0.0,0.0,0.0],[44427.2,0.0,0.0,0.0]] [[43633.4,4.515,197004.801,4.515],[43855.6,6.058,265677.2248,6.058]] 1343268964711 1343268961876"#;
assert_eq!(csv_string_expected, csv_string);
let orderbook_msg_restored = OrderBookMsg::from_csv_string(
"binance",
"linear_swap",
"l2_event",
"BTC/USDT",
"BTCUSDT",
&csv_string,
);
assert_eq!(
serde_json::to_string(&orderbook_msg).unwrap(),
serde_json::to_string(&orderbook_msg_restored).unwrap()
);
}
}
macro_rules! impl_partial_ord {
($struct_name:ident) => {
impl PartialOrd for $struct_name {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.timestamp.cmp(&other.timestamp))
}
}
};
}
impl PartialEq for TradeMsg {
fn eq(&self, other: &Self) -> bool {
self.exchange == other.exchange
&& self.market_type == other.market_type
&& self.symbol == other.symbol
&& self.timestamp == other.timestamp
&& self.trade_id == other.trade_id
&& self.price == other.price
&& self.quantity_base == other.quantity_base
&& self.quantity_quote == other.quantity_quote
&& self.quantity_contract == other.quantity_contract
}
}
impl Eq for TradeMsg {}
impl_partial_ord!(TradeMsg);
impl Ord for TradeMsg {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
let ret = self.timestamp.cmp(&other.timestamp);
if ret == std::cmp::Ordering::Equal {
self.trade_id.cmp(&other.trade_id)
} else {
ret
}
}
}
impl PartialEq for OrderBookMsg {
fn eq(&self, other: &Self) -> bool {
self.exchange == other.exchange
&& self.market_type == other.market_type
&& self.symbol == other.symbol
&& self.timestamp == other.timestamp
&& self.asks == other.asks
&& self.bids == other.bids
}
}
impl Eq for OrderBookMsg {}
impl_partial_ord!(OrderBookMsg);
impl Ord for OrderBookMsg {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
let ret = self.timestamp.cmp(&other.timestamp);
if ret == std::cmp::Ordering::Equal {
if self.seq_id.is_some() && other.seq_id.is_some() {
self.seq_id.unwrap().cmp(&(other.seq_id.unwrap()))
} else {
ret
}
} else {
ret
}
}
}
impl PartialEq for BboMsg {
fn eq(&self, other: &Self) -> bool {
self.exchange == other.exchange
&& self.market_type == other.market_type
&& self.symbol == other.symbol
&& self.timestamp == other.timestamp
&& self.bid_price == other.bid_price
&& self.bid_quantity_base == other.bid_quantity_base
&& self.bid_quantity_quote == other.bid_quantity_quote
&& self.ask_price == other.ask_price
&& self.ask_quantity_base == other.ask_quantity_base
&& self.ask_quantity_quote == other.ask_quantity_quote
&& self.id == other.id
}
}
impl Eq for BboMsg {}
impl_partial_ord!(BboMsg);
impl Ord for BboMsg {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.timestamp.cmp(&other.timestamp)
}
}
impl PartialEq for TickerMsg {
fn eq(&self, other: &Self) -> bool {
self.exchange == other.exchange
&& self.market_type == other.market_type
&& self.symbol == other.symbol
&& self.timestamp == other.timestamp
&& self.open == other.open
&& self.high == other.high
&& self.close == other.close
&& self.volume == other.volume
&& self.quote_volume == other.quote_volume
}
}
impl Eq for TickerMsg {}
impl_partial_ord!(TickerMsg);
impl Ord for TickerMsg {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.timestamp.cmp(&other.timestamp)
}
}
impl PartialEq for CandlestickMsg {
fn eq(&self, other: &Self) -> bool {
self.exchange == other.exchange
&& self.market_type == other.market_type
&& self.symbol == other.symbol
&& self.timestamp == other.timestamp
&& self.open == other.open
&& self.high == other.high
&& self.close == other.close
&& self.volume == other.volume
&& self.period == other.period
}
}
impl Eq for CandlestickMsg {}
impl_partial_ord!(CandlestickMsg);
impl Ord for CandlestickMsg {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.timestamp.cmp(&other.timestamp)
}
}
impl PartialEq for FundingRateMsg {
fn eq(&self, other: &Self) -> bool {
self.exchange == other.exchange
&& self.market_type == other.market_type
&& self.symbol == other.symbol
&& self.timestamp == other.timestamp
&& self.funding_rate == other.funding_rate
&& self.funding_time == other.funding_time
}
}
impl Eq for FundingRateMsg {}
impl_partial_ord!(FundingRateMsg);
impl Ord for FundingRateMsg {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
let ret = self.timestamp.cmp(&other.timestamp);
if ret == std::cmp::Ordering::Equal {
self.funding_time.cmp(&other.funding_time)
} else {
ret
}
}
}
impl PartialOrd for Message {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
match self {
Message::Trade(ref a) => match other {
Message::Trade(ref b) => Some(a.cmp(b)),
_ => None,
},
Message::Level2(ref a) => match other {
Message::Level2(ref b) => Some(a.cmp(b)),
_ => None,
},
Message::Bbo(ref a) => match other {
Message::Bbo(ref b) => Some(a.cmp(b)),
_ => None,
},
Message::Ticker(ref a) => match other {
Message::Ticker(ref b) => Some(a.cmp(b)),
_ => None,
},
Message::Candlestick(ref a) => match other {
Message::Candlestick(ref b) => Some(a.cmp(b)),
_ => None,
},
Message::FundingRate(ref a) => match other {
Message::FundingRate(ref b) => Some(a.cmp(b)),
_ => None,
},
}
}
}
impl Ord for Message {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
match self {
Message::Trade(ref a) => match other {
Message::Trade(ref b) => a.cmp(b),
_ => std::cmp::Ordering::Less,
},
Message::Level2(ref a) => match other {
Message::Level2(ref b) => a.cmp(b),
_ => std::cmp::Ordering::Less,
},
Message::Bbo(ref a) => match other {
Message::Bbo(ref b) => a.cmp(b),
_ => std::cmp::Ordering::Less,
},
Message::Ticker(ref a) => match other {
Message::Ticker(ref b) => a.cmp(b),
_ => std::cmp::Ordering::Less,
},
Message::Candlestick(ref a) => match other {
Message::Candlestick(ref b) => a.cmp(b),
_ => std::cmp::Ordering::Less,
},
Message::FundingRate(ref a) => match other {
Message::FundingRate(ref b) => a.cmp(b),
_ => std::cmp::Ordering::Less,
},
}
}
}