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
mod exchanges;
use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use strum_macros::{Display, EnumString};
#[repr(C)]
#[derive(Copy, Clone, Eq, PartialEq, Serialize, Deserialize, Display, Debug, EnumString, Hash)]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum MessageType {
Other,
Trade,
L2Event,
L2Snapshot,
#[serde(rename = "l2_topk")]
#[strum(serialize = "l2_topk")]
L2TopK,
L3Event,
L3Snapshot,
#[serde(rename = "bbo")]
#[allow(clippy::upper_case_acronyms)]
BBO,
Ticker,
Candlestick,
FundingRate,
OpenInterest,
LongShortRatio,
TakerVolume,
}
pub fn get_ws_commands(
exchange: &str,
msg_types: &[MessageType],
symbols: &[String],
subscribe: bool,
configs: Option<&HashMap<String, String>>,
) -> Vec<String> {
if msg_types.is_empty() || symbols.is_empty() {
return Vec::new();
}
match exchange {
"binance" => exchanges::binance::get_ws_commands(msg_types, symbols, subscribe, configs),
"bitfinex" => exchanges::bitfinex::get_ws_commands(msg_types, symbols, subscribe, configs),
"bitmex" => exchanges::bitmex::get_ws_commands(msg_types, symbols, subscribe, configs),
"bybit" => exchanges::bybit::get_ws_commands(msg_types, symbols, subscribe, configs),
"deribit" => exchanges::deribit::get_ws_commands(msg_types, symbols, subscribe, configs),
"ftx" => exchanges::ftx::get_ws_commands(msg_types, symbols, subscribe, configs),
"huobi" => exchanges::huobi::get_ws_commands(msg_types, symbols, subscribe, configs),
"okex" => exchanges::okex::get_ws_commands(msg_types, symbols, subscribe, configs),
"okx" => exchanges::okx::get_ws_commands(msg_types, symbols, subscribe, configs),
_ => Vec::new(),
}
}