1mod exchanges;
2
3use std::collections::HashMap;
4
5use serde::{Deserialize, Serialize};
6use strum_macros::{Display, EnumString};
7
8#[repr(C)]
13#[derive(Copy, Clone, Eq, PartialEq, Serialize, Deserialize, Display, Debug, EnumString, Hash)]
14#[serde(rename_all = "snake_case")]
15#[strum(serialize_all = "snake_case")]
16pub enum MessageType {
17 Other,
19 Trade,
21 L2Event,
23 L2Snapshot,
25 #[serde(rename = "l2_topk")]
27 #[strum(serialize = "l2_topk")]
28 L2TopK,
29 L3Event,
31 L3Snapshot,
33 #[serde(rename = "bbo")]
35 #[allow(clippy::upper_case_acronyms)]
36 BBO,
37 Ticker,
39 Candlestick,
41 FundingRate,
43 OpenInterest,
45 LongShortRatio,
47 TakerVolume,
49}
50
51pub fn get_ws_commands(
56 exchange: &str,
57 msg_types: &[MessageType],
58 symbols: &[String],
59 subscribe: bool,
60 configs: Option<&HashMap<String, String>>,
61) -> Vec<String> {
62 if msg_types.is_empty() || symbols.is_empty() {
63 return Vec::new();
64 }
65 match exchange {
66 "binance" => exchanges::binance::get_ws_commands(msg_types, symbols, subscribe, configs),
67 "bitfinex" => exchanges::bitfinex::get_ws_commands(msg_types, symbols, subscribe, configs),
68 "bitmex" => exchanges::bitmex::get_ws_commands(msg_types, symbols, subscribe, configs),
69 "bybit" => exchanges::bybit::get_ws_commands(msg_types, symbols, subscribe, configs),
70 "deribit" => exchanges::deribit::get_ws_commands(msg_types, symbols, subscribe, configs),
71 "ftx" => exchanges::ftx::get_ws_commands(msg_types, symbols, subscribe, configs),
72 "huobi" => exchanges::huobi::get_ws_commands(msg_types, symbols, subscribe, configs),
73 "okex" => exchanges::okex::get_ws_commands(msg_types, symbols, subscribe, configs),
74 "okx" => exchanges::okx::get_ws_commands(msg_types, symbols, subscribe, configs),
75 _ => Vec::new(),
76 }
77}