use super::{Binance, ExchangeServer};
use crate::{
exchange::{
StreamSelector,
binance::{
BinanceWsStream,
spot::l2::{
BinanceSpotOrderBooksL2SnapshotFetcher, BinanceSpotOrderBooksL2Transformer,
},
},
},
instrument::InstrumentData,
subscription::book::OrderBooksL2,
};
use barter_instrument::exchange::ExchangeId;
use std::fmt::{Display, Formatter};
pub mod l2;
pub const WEBSOCKET_BASE_URL_BINANCE_SPOT: &str = "wss://stream.binance.com:9443/ws";
pub type BinanceSpot = Binance<BinanceServerSpot>;
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
pub struct BinanceServerSpot;
impl ExchangeServer for BinanceServerSpot {
const ID: ExchangeId = ExchangeId::BinanceSpot;
fn websocket_url() -> &'static str {
WEBSOCKET_BASE_URL_BINANCE_SPOT
}
}
impl<Instrument> StreamSelector<Instrument, OrderBooksL2> for BinanceSpot
where
Instrument: InstrumentData,
{
type SnapFetcher = BinanceSpotOrderBooksL2SnapshotFetcher;
type Stream = BinanceWsStream<BinanceSpotOrderBooksL2Transformer<Instrument::Key>>;
}
impl Display for BinanceSpot {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "BinanceSpot")
}
}