barter_data/exchange/gateio/future/
mod.rs1use crate::{
2 ExchangeWsStream, NoInitialSnapshots,
3 exchange::{
4 ExchangeServer, StreamSelector,
5 gateio::{Gateio, perpetual::trade::GateioFuturesTrades},
6 },
7 instrument::InstrumentData,
8 subscription::trade::PublicTrades,
9 transformer::stateless::StatelessTransformer,
10};
11use barter_instrument::exchange::ExchangeId;
12use std::fmt::Display;
13
14pub const WEBSOCKET_BASE_URL_GATEIO_FUTURES_USD: &str = "wss://fx-ws.gateio.ws/v4/ws/delivery/usdt";
18
19pub type GateioFuturesUsd = Gateio<GateioServerFuturesUsd>;
21
22#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
24pub struct GateioServerFuturesUsd;
25
26impl ExchangeServer for GateioServerFuturesUsd {
27 const ID: ExchangeId = ExchangeId::GateioFuturesUsd;
28
29 fn websocket_url() -> &'static str {
30 WEBSOCKET_BASE_URL_GATEIO_FUTURES_USD
31 }
32}
33
34impl<Instrument> StreamSelector<Instrument, PublicTrades> for GateioFuturesUsd
35where
36 Instrument: InstrumentData,
37{
38 type SnapFetcher = NoInitialSnapshots;
39 type Stream = ExchangeWsStream<
40 StatelessTransformer<Self, Instrument::Key, PublicTrades, GateioFuturesTrades>,
41 >;
42}
43
44impl Display for GateioFuturesUsd {
45 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
46 write!(f, "GateioFuturesUsd")
47 }
48}
49
50pub const WEBSOCKET_BASE_URL_GATEIO_FUTURES_BTC: &str = "wss://fx-ws.gateio.ws/v4/ws/delivery/btc";
54
55pub type GateioFuturesBtc = Gateio<GateioServerFuturesBtc>;
57
58#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
60pub struct GateioServerFuturesBtc;
61
62impl ExchangeServer for GateioServerFuturesBtc {
63 const ID: ExchangeId = ExchangeId::GateioFuturesBtc;
64
65 fn websocket_url() -> &'static str {
66 WEBSOCKET_BASE_URL_GATEIO_FUTURES_BTC
67 }
68}
69
70impl<Instrument> StreamSelector<Instrument, PublicTrades> for GateioFuturesBtc
71where
72 Instrument: InstrumentData,
73{
74 type SnapFetcher = NoInitialSnapshots;
75 type Stream = ExchangeWsStream<
76 StatelessTransformer<Self, Instrument::Key, PublicTrades, GateioFuturesTrades>,
77 >;
78}
79
80impl Display for GateioFuturesBtc {
81 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
82 write!(f, "GateioFuturesBtc")
83 }
84}