xapi-binance 0.0.1

Binance API client
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::{clients::spot::BnSpot, data::book_ticker::BnBookTickerStream};
use tokio::sync::mpsc;
use xapi_shared::{data::crypto_symbol::CryptoSymbol, ws::error::SharedWsError};

impl BnSpot {
    /// Pushes any update to the best bid or ask's price or quantity in real-time for a specified symbol. Multiple <symbol>@bookTicker streams can be subscribed to over one connection.
    ///
    /// <https://developers.binance.com/docs/binance-spot-api-docs/web-socket-streams#individual-symbol-book-ticker-streams>
    pub async fn subscribe_book_ticker(
        &self,
        symbol: &CryptoSymbol,
    ) -> Result<mpsc::Receiver<Result<BnBookTickerStream, SharedWsError>>, SharedWsError> {
        self.executor
            .subscribe_stream(format!("{}@bookTicker", symbol.as_str().to_lowercase()))
            .await
    }
}