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
use crate::WSClient;
use std::sync::{Arc, Mutex};
use super::super::ws_client_internal::WSClientInternal;
use super::super::{Candlestick, OrderBook, OrderBookSnapshot, Ticker, Trade, BBO};
use super::utils::{
channels_to_commands, on_misc_msg, to_candlestick_raw_channel, to_raw_channel, EXCHANGE_NAME,
PING_INTERVAL_AND_MSG,
};
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<'a> {
client: WSClientInternal<'a>,
}
pub struct GateLinearSwapWSClient<'a> {
client: WSClientInternal<'a>,
}
#[rustfmt::skip]
impl_trait!(Trade, GateInverseSwapWSClient, subscribe_trade, "trades", to_raw_channel);
#[rustfmt::skip]
impl_trait!(OrderBook, GateInverseSwapWSClient, subscribe_orderbook, "order_book", to_raw_channel);
#[rustfmt::skip]
impl_trait!(Ticker, GateInverseSwapWSClient, subscribe_ticker, "tickers", to_raw_channel);
#[rustfmt::skip]
impl_trait!(Trade, GateLinearSwapWSClient, subscribe_trade, "trades", to_raw_channel);
#[rustfmt::skip]
impl_trait!(OrderBook, GateLinearSwapWSClient, subscribe_orderbook, "order_book", to_raw_channel);
#[rustfmt::skip]
impl_trait!(Ticker, GateLinearSwapWSClient, subscribe_ticker, "tickers", to_raw_channel);
impl<'a> BBO for GateInverseSwapWSClient<'a> {
fn subscribe_bbo(&self, _pairs: &[String]) {
panic!("Gate does NOT have BBO channel");
}
}
impl<'a> BBO for GateLinearSwapWSClient<'a> {
fn subscribe_bbo(&self, _pairs: &[String]) {
panic!("Gate does NOT have BBO channel");
}
}
impl<'a> OrderBookSnapshot for GateInverseSwapWSClient<'a> {
fn subscribe_orderbook_snapshot(&self, _pairs: &[String]) {
panic!("Gate does NOT have orderbook snapshot channel");
}
}
impl<'a> OrderBookSnapshot for GateLinearSwapWSClient<'a> {
fn subscribe_orderbook_snapshot(&self, _pairs: &[String]) {
panic!("Gate does NOT have orderbook snapshot channel");
}
}
impl_candlestick!(GateInverseSwapWSClient);
impl_candlestick!(GateLinearSwapWSClient);
define_client!(
GateInverseSwapWSClient,
EXCHANGE_NAME,
INVERSE_SWAP_WEBSOCKET_URL,
channels_to_commands,
on_misc_msg,
Some(PING_INTERVAL_AND_MSG)
);
define_client!(
GateLinearSwapWSClient,
EXCHANGE_NAME,
LINEAR_SWAP_WEBSOCKET_URL,
channels_to_commands,
on_misc_msg,
Some(PING_INTERVAL_AND_MSG)
);