barter_data_sniper/exchange/gateio/perpetual/
mod.rs

1use self::trade::GateioFuturesTrades;
2use super::Gateio;
3use crate::{
4    exchange::{ExchangeServer, StreamSelector},
5    instrument::InstrumentData,
6    subscription::trade::PublicTrades,
7    transformer::stateless::StatelessTransformer,
8    ExchangeWsStream, NoInitialSnapshots,
9};
10use barter_instrument_copy::exchange::ExchangeId;
11
12/// Public trades types.
13pub mod trade;
14
15/// [`GateioPerpetualsUsd`] WebSocket server base url.
16///
17/// See docs: <https://www.gate.io/docs/developers/futures/ws/en/>
18pub const WEBSOCKET_BASE_URL_GATEIO_PERPETUALS_USD: &str = "wss://fx-ws.gateio.ws/v4/ws/usdt";
19
20/// [`Gateio`] perpetual usd exchange.
21pub type GateioPerpetualsUsd = Gateio<GateioServerPerpetualsUsd>;
22
23/// [`Gateio`] perpetual usd [`ExchangeServer`].
24#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
25pub struct GateioServerPerpetualsUsd;
26
27impl ExchangeServer for GateioServerPerpetualsUsd {
28    const ID: ExchangeId = ExchangeId::GateioPerpetualsUsd;
29
30    fn websocket_url() -> &'static str {
31        WEBSOCKET_BASE_URL_GATEIO_PERPETUALS_USD
32    }
33}
34
35impl<Instrument> StreamSelector<Instrument, PublicTrades> for GateioPerpetualsUsd
36where
37    Instrument: InstrumentData,
38{
39    type SnapFetcher = NoInitialSnapshots;
40    type Stream = ExchangeWsStream<
41        StatelessTransformer<Self, Instrument::Key, PublicTrades, GateioFuturesTrades>,
42    >;
43}
44
45/// [`GateioPerpetualsBtc`] WebSocket server base url.
46///
47/// See docs: <https://www.gate.io/docs/developers/futures/ws/en/>
48pub const WEBSOCKET_BASE_URL_GATEIO_PERPETUALS_BTC: &str = "wss://fx-ws.gateio.ws/v4/ws/btc";
49
50/// [`Gateio`] perpetual btc exchange.
51pub type GateioPerpetualsBtc = Gateio<GateioServerPerpetualsBtc>;
52
53/// [`Gateio`] perpetual btc [`ExchangeServer`].
54#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
55pub struct GateioServerPerpetualsBtc;
56
57impl ExchangeServer for GateioServerPerpetualsBtc {
58    const ID: ExchangeId = ExchangeId::GateioPerpetualsBtc;
59
60    fn websocket_url() -> &'static str {
61        WEBSOCKET_BASE_URL_GATEIO_PERPETUALS_BTC
62    }
63}
64
65impl<Instrument> StreamSelector<Instrument, PublicTrades> for GateioPerpetualsBtc
66where
67    Instrument: InstrumentData,
68{
69    type SnapFetcher = NoInitialSnapshots;
70    type Stream = ExchangeWsStream<
71        StatelessTransformer<Self, Instrument::Key, PublicTrades, GateioFuturesTrades>,
72    >;
73}