barter_data/exchange/binance/spot/
mod.rs1use super::{Binance, ExchangeServer};
2use crate::{
3 exchange::{
4 StreamSelector,
5 binance::{
6 BinanceWsStream,
7 spot::l2::{
8 BinanceSpotOrderBooksL2SnapshotFetcher, BinanceSpotOrderBooksL2Transformer,
9 },
10 },
11 },
12 instrument::InstrumentData,
13 subscription::book::OrderBooksL2,
14};
15use barter_instrument::exchange::ExchangeId;
16use std::fmt::{Display, Formatter};
17
18pub mod l2;
20
21pub const WEBSOCKET_BASE_URL_BINANCE_SPOT: &str = "wss://stream.binance.com:9443/ws";
25
26pub type BinanceSpot = Binance<BinanceServerSpot>;
28
29#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
31pub struct BinanceServerSpot;
32
33impl ExchangeServer for BinanceServerSpot {
34 const ID: ExchangeId = ExchangeId::BinanceSpot;
35
36 fn websocket_url() -> &'static str {
37 WEBSOCKET_BASE_URL_BINANCE_SPOT
38 }
39}
40
41impl<Instrument> StreamSelector<Instrument, OrderBooksL2> for BinanceSpot
42where
43 Instrument: InstrumentData,
44{
45 type SnapFetcher = BinanceSpotOrderBooksL2SnapshotFetcher;
46 type Stream = BinanceWsStream<BinanceSpotOrderBooksL2Transformer<Instrument::Key>>;
47}
48
49impl Display for BinanceSpot {
50 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
51 write!(f, "BinanceSpot")
52 }
53}