rustrade_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 rustrade_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>;
40
41#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
43pub struct BinanceServerSpot;
44
45impl ExchangeServer for BinanceServerSpot {
46 const ID: ExchangeId = ExchangeId::BinanceSpot;
47
48 fn websocket_url() -> &'static str {
49 WEBSOCKET_BASE_URL_BINANCE_SPOT
50 }
51}
52
53impl<Instrument> StreamSelector<Instrument, OrderBooksL2> for BinanceSpot
54where
55 Instrument: InstrumentData,
56{
57 type SnapFetcher = BinanceSpotOrderBooksL2SnapshotFetcher;
58 type Stream = BinanceWsStream<BinanceSpotOrderBooksL2Transformer<Instrument::Key>>;
59}
60
61impl Display for BinanceSpot {
62 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
63 write!(f, "BinanceSpot")
64 }
65}