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
use async_trait::async_trait;
use super::utils::{GateCommandTranslator, GateMessageHandler, EXCHANGE_NAME};
use crate::{
clients::common_traits::{
Candlestick, Level3OrderBook, OrderBook, OrderBookTopK, Ticker, Trade, BBO,
},
common::{command_translator::CommandTranslator, ws_client_internal::WSClientInternal},
WSClient,
};
const INVERSE_SWAP_WEBSOCKET_URL: &str = "wss://fx-ws.gateio.ws/v4/ws/btc";
const LINEAR_SWAP_WEBSOCKET_URL: &str = "wss://fx-ws.gateio.ws/v4/ws/usdt";
pub struct GateInverseSwapWSClient {
client: WSClientInternal<GateMessageHandler<'F'>>,
translator: GateCommandTranslator<'F'>,
}
pub struct GateLinearSwapWSClient {
client: WSClientInternal<GateMessageHandler<'F'>>,
translator: GateCommandTranslator<'F'>,
}
impl_new_constructor!(
GateInverseSwapWSClient,
EXCHANGE_NAME,
INVERSE_SWAP_WEBSOCKET_URL,
GateMessageHandler::<'F'> {},
GateCommandTranslator::<'F'> {}
);
impl_new_constructor!(
GateLinearSwapWSClient,
EXCHANGE_NAME,
LINEAR_SWAP_WEBSOCKET_URL,
GateMessageHandler::<'F'> {},
GateCommandTranslator::<'F'> {}
);
impl_trait!(Trade, GateInverseSwapWSClient, subscribe_trade, "trades");
#[rustfmt::skip]
impl_trait!(OrderBook, GateInverseSwapWSClient, subscribe_orderbook, "order_book_update");
#[rustfmt::skip]
impl_trait!(OrderBookTopK, GateInverseSwapWSClient, subscribe_orderbook_topk, "order_book");
impl_trait!(BBO, GateInverseSwapWSClient, subscribe_bbo, "book_ticker");
impl_trait!(Ticker, GateInverseSwapWSClient, subscribe_ticker, "tickers");
impl_trait!(Trade, GateLinearSwapWSClient, subscribe_trade, "trades");
#[rustfmt::skip]
impl_trait!(OrderBook, GateLinearSwapWSClient, subscribe_orderbook, "order_book_update");
#[rustfmt::skip]
impl_trait!(OrderBookTopK, GateLinearSwapWSClient, subscribe_orderbook_topk, "order_book");
impl_trait!(BBO, GateLinearSwapWSClient, subscribe_bbo, "book_ticker");
impl_trait!(Ticker, GateLinearSwapWSClient, subscribe_ticker, "tickers");
impl_candlestick!(GateInverseSwapWSClient);
impl_candlestick!(GateLinearSwapWSClient);
panic_l3_orderbook!(GateInverseSwapWSClient);
panic_l3_orderbook!(GateLinearSwapWSClient);
impl_ws_client_trait!(GateInverseSwapWSClient);
impl_ws_client_trait!(GateLinearSwapWSClient);