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
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_FUTURE_WEBSOCKET_URL: &str = "wss://fx-ws.gateio.ws/v4/ws/delivery/btc";
const LINEAR_FUTURE_WEBSOCKET_URL: &str = "wss://fx-ws.gateio.ws/v4/ws/delivery/usdt";
pub struct GateInverseFutureWSClient {
client: WSClientInternal<GateMessageHandler<'F'>>,
translator: GateCommandTranslator<'F'>,
}
pub struct GateLinearFutureWSClient {
client: WSClientInternal<GateMessageHandler<'F'>>,
translator: GateCommandTranslator<'F'>,
}
impl_new_constructor!(
GateInverseFutureWSClient,
EXCHANGE_NAME,
INVERSE_FUTURE_WEBSOCKET_URL,
GateMessageHandler::<'F'> {},
GateCommandTranslator::<'F'> {}
);
impl_new_constructor!(
GateLinearFutureWSClient,
EXCHANGE_NAME,
LINEAR_FUTURE_WEBSOCKET_URL,
GateMessageHandler::<'F'> {},
GateCommandTranslator::<'F'> {}
);
impl_trait!(Trade, GateInverseFutureWSClient, subscribe_trade, "trades");
#[rustfmt::skip]
impl_trait!(OrderBook, GateInverseFutureWSClient, subscribe_orderbook, "order_book");
#[rustfmt::skip]
impl_trait!(Ticker, GateInverseFutureWSClient, subscribe_ticker, "tickers");
#[rustfmt::skip]
impl_trait!(Trade, GateLinearFutureWSClient, subscribe_trade, "trades");
#[rustfmt::skip]
impl_trait!(OrderBook, GateLinearFutureWSClient, subscribe_orderbook, "order_book");
#[rustfmt::skip]
impl_trait!(Ticker, GateLinearFutureWSClient, subscribe_ticker, "tickers");
impl_candlestick!(GateInverseFutureWSClient);
impl_candlestick!(GateLinearFutureWSClient);
panic_bbo!(GateInverseFutureWSClient);
panic_bbo!(GateLinearFutureWSClient);
panic_l2_topk!(GateInverseFutureWSClient);
panic_l2_topk!(GateLinearFutureWSClient);
panic_l3_orderbook!(GateInverseFutureWSClient);
panic_l3_orderbook!(GateLinearFutureWSClient);
impl_ws_client_trait!(GateInverseFutureWSClient);
impl_ws_client_trait!(GateLinearFutureWSClient);