Class BinanceStreamingMarketDataService
java.lang.Object
info.bitrich.xchangestream.binance.BinanceStreamingMarketDataService
- All Implemented Interfaces:
StreamingMarketDataService
-
Constructor Summary
ConstructorsConstructorDescriptionBinanceStreamingMarketDataService(BinanceStreamingService service, BinanceMarketDataService marketDataService, Runnable onApiCall, String orderBookUpdateFrequencyParameter, boolean realtimeOrderBookTicker, int oderBookFetchLimitParameter) -
Method Summary
Modifier and TypeMethodDescriptionio.reactivex.rxjava3.core.Observable<FundingRate>getFundingRate(Instrument instrument, Object... args) Get funding rate of specific instrument.io.reactivex.rxjava3.core.Observable<BinanceKline>getKlines(Instrument instrument, KlineInterval interval) io.reactivex.rxjava3.core.Observable<OrderBook>getOrderBook(CurrencyPair currencyPair, Object... args) Get an order book representing the current offered exchange rates (market depth).io.reactivex.rxjava3.core.Observable<OrderBook>getOrderBook(Instrument instrument, Object... args) io.reactivex.rxjava3.core.Observable<List<OrderBookUpdate>>getOrderBookUpdates(Instrument instrument, Object... args) Api to get binance incremental order book updates.io.reactivex.rxjava3.core.Observable<BinanceBookTicker>getRawBookTicker(Instrument instrument) io.reactivex.rxjava3.core.Observable<BinanceTicker24h>getRawTicker(Instrument instrument) io.reactivex.rxjava3.core.Observable<BinanceRawTrade>getRawTrades(Instrument instrument) io.reactivex.rxjava3.core.Observable<Ticker>getTicker(CurrencyPair currencyPair, Object... args) Get a ticker representing the current exchange rate.io.reactivex.rxjava3.core.Observable<Ticker>getTicker(Instrument instrument, Object... args) io.reactivex.rxjava3.core.Observable<Trade>getTrades(CurrencyPair currencyPair, Object... args) Get the trades performed by the exchange.io.reactivex.rxjava3.core.Observable<Trade>getTrades(Instrument instrument, Object... args) voidopenSubscriptions(ProductSubscription productSubscription, KlineSubscription klineSubscription) Registers subscriptions with the streaming service for the given products.voidunsubscribe(Instrument instrument, BinanceSubscriptionType subscriptionType) Live Unsubscription that should be called in the Observable.doOnDispose().voidunsubscribeKline(Instrument instrument, KlineInterval klineInterval) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface info.bitrich.xchangestream.core.StreamingMarketDataService
getFundingRates
-
Constructor Details
-
BinanceStreamingMarketDataService
public BinanceStreamingMarketDataService(BinanceStreamingService service, BinanceMarketDataService marketDataService, Runnable onApiCall, String orderBookUpdateFrequencyParameter, boolean realtimeOrderBookTicker, int oderBookFetchLimitParameter)
-
-
Method Details
-
getOrderBook
public io.reactivex.rxjava3.core.Observable<OrderBook> getOrderBook(CurrencyPair currencyPair, Object... args) Description copied from interface:StreamingMarketDataServiceGet an order book representing the current offered exchange rates (market depth).Warning: The library will attempt to keep the snapshots returned in sync with the exchange using the approaches published by that exchange. However, there are currently no guarantees that messages will not be skipped, or that any initial state message will be sent on connection. Emits
NotConnectedExceptionwhen not connected to the WebSocket API.- Specified by:
getOrderBookin interfaceStreamingMarketDataService- Parameters:
currencyPair- Currency pair of the order book- Returns:
Observablethat emitsOrderBookwhen exchange sends the update.
-
getTicker
public io.reactivex.rxjava3.core.Observable<Ticker> getTicker(CurrencyPair currencyPair, Object... args) Description copied from interface:StreamingMarketDataServiceGet a ticker representing the current exchange rate. EmitsNotConnectedExceptionWhen not connected to the WebSocket API.Warning: There are currently no guarantees that messages will not be skipped, or that any initial state message will be sent on connection.
- Specified by:
getTickerin interfaceStreamingMarketDataService- Parameters:
currencyPair- Currency pair of the ticker- Returns:
Observablethat emitsTickerwhen exchange sends the update.
-
getTrades
public io.reactivex.rxjava3.core.Observable<Trade> getTrades(CurrencyPair currencyPair, Object... args) Description copied from interface:StreamingMarketDataServiceGet the trades performed by the exchange. EmitsNotConnectedExceptionWhen not connected to the WebSocket API.Warning: There are currently no guarantees that messages will not be skipped.
- Specified by:
getTradesin interfaceStreamingMarketDataService- Parameters:
currencyPair- Currency pair of the trades- Returns:
Observablethat emitsTradewhen exchange sends the update.
-
getOrderBook
public io.reactivex.rxjava3.core.Observable<OrderBook> getOrderBook(Instrument instrument, Object... args) - Specified by:
getOrderBookin interfaceStreamingMarketDataService
-
getTicker
public io.reactivex.rxjava3.core.Observable<Ticker> getTicker(Instrument instrument, Object... args) - Specified by:
getTickerin interfaceStreamingMarketDataService
-
getTrades
- Specified by:
getTradesin interfaceStreamingMarketDataService
-
getFundingRate
public io.reactivex.rxjava3.core.Observable<FundingRate> getFundingRate(Instrument instrument, Object... args) Description copied from interface:StreamingMarketDataServiceGet funding rate of specific instrument.- Specified by:
getFundingRatein interfaceStreamingMarketDataService- Parameters:
instrument- Instrument to get the funding rate for- Returns:
Observablethat emitsFundingRatewhen exchange sends the update.
-
getRawTicker
-
getRawBookTicker
public io.reactivex.rxjava3.core.Observable<BinanceBookTicker> getRawBookTicker(Instrument instrument) -
getRawTrades
-
getKlines
public io.reactivex.rxjava3.core.Observable<BinanceKline> getKlines(Instrument instrument, KlineInterval interval) -
getOrderBookUpdates
public io.reactivex.rxjava3.core.Observable<List<OrderBookUpdate>> getOrderBookUpdates(Instrument instrument, Object... args) Api to get binance incremental order book updates. As binance websocket provides only api to get incremental updatesgetOrderBook(Instrument, Object...)have to build book from rest and websocket which leads to delay before the order book will be received by subscriber. This api provides the ability to start receiving updates immediately. It is allowed to subscribe to this api andgetOrderBook(Instrument, Object...)at the same time.- Specified by:
getOrderBookUpdatesin interfaceStreamingMarketDataService- Returns:
Observablethat emitsOrderBookUpdatewhen exchange sends the orderBook snapshot.
-
openSubscriptions
public void openSubscriptions(ProductSubscription productSubscription, KlineSubscription klineSubscription) Registers subscriptions with the streaming service for the given products.As we receive messages as soon as the connection is open, we need to register subscribers to handle these before the first messages arrive.
-
unsubscribe
Live Unsubscription that should be called in the Observable.doOnDispose(). This is required to stop receiving data from the stream. This method also clear the subscription from the appropriate map. -
unsubscribeKline
-