Class BinanceStreamingMarketDataService
java.lang.Object
info.bitrich.xchangestream.binance.BinanceStreamingMarketDataService
- All Implemented Interfaces:
StreamingMarketDataService
public class BinanceStreamingMarketDataService extends Object implements StreamingMarketDataService
-
Constructor Summary
Constructors Constructor Description BinanceStreamingMarketDataService(BinanceStreamingService service, BinanceMarketDataService marketDataService, Runnable onApiCall, String orderBookUpdateFrequencyParameter, boolean realtimeOrderBookTicker, int oderBookFetchLimitParameter)
-
Method Summary
Modifier and Type Method Description io.reactivex.Observable<OrderBook>
getOrderBook(CurrencyPair currencyPair, Object... args)
Get an order book representing the current offered exchange rates (market depth).io.reactivex.Observable<OrderBookUpdate>
getOrderBookUpdates(CurrencyPair currencyPair, Object... args)
Api to get binance incremental order book updates.io.reactivex.Observable<BinanceBookTicker>
getRawBookTicker(CurrencyPair currencyPair, Object... args)
io.reactivex.Observable<BinanceTicker24h>
getRawTicker(CurrencyPair currencyPair, Object... args)
io.reactivex.Observable<BinanceRawTrade>
getRawTrades(CurrencyPair currencyPair, Object... args)
io.reactivex.Observable<Ticker>
getTicker(CurrencyPair currencyPair, Object... args)
Get a ticker representing the current exchange rate.io.reactivex.Observable<Trade>
getTrades(CurrencyPair currencyPair, Object... args)
Get the trades performed by the exchange.void
openSubscriptions(ProductSubscription productSubscription)
Registers subsriptions with the streaming service for the given products.void
unsubscribe(CurrencyPair currencyPair, BinanceSubscriptionType subscriptionType)
Live Unsubscription that should be called in the Observable.doOnDispose().Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface info.bitrich.xchangestream.core.StreamingMarketDataService
getOrderBook, getTicker, getTrades
-
Constructor Details
-
BinanceStreamingMarketDataService
public BinanceStreamingMarketDataService(BinanceStreamingService service, BinanceMarketDataService marketDataService, Runnable onApiCall, String orderBookUpdateFrequencyParameter, boolean realtimeOrderBookTicker, int oderBookFetchLimitParameter)
-
-
Method Details
-
getOrderBook
Description copied from interface:StreamingMarketDataService
Get 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
NotConnectedException
when not connected to the WebSocket API.- Specified by:
getOrderBook
in interfaceStreamingMarketDataService
- Parameters:
currencyPair
- Currency pair of the order book- Returns:
Observable
that emitsOrderBook
when exchange sends the update.
-
getRawTicker
public io.reactivex.Observable<BinanceTicker24h> getRawTicker(CurrencyPair currencyPair, Object... args) -
getRawBookTicker
public io.reactivex.Observable<BinanceBookTicker> getRawBookTicker(CurrencyPair currencyPair, Object... args) -
getRawTrades
public io.reactivex.Observable<BinanceRawTrade> getRawTrades(CurrencyPair currencyPair, Object... args) -
getOrderBookUpdates
public io.reactivex.Observable<OrderBookUpdate> getOrderBookUpdates(CurrencyPair currencyPair, Object... args)Api to get binance incremental order book updates. As binance websocket provides only api to get incremental updatesgetOrderBook(CurrencyPair, 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(CurrencyPair, Object...)
at the same time. -
getTicker
Description copied from interface:StreamingMarketDataService
Get a ticker representing the current exchange rate. EmitsNotConnectedException
When 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:
getTicker
in interfaceStreamingMarketDataService
- Parameters:
currencyPair
- Currency pair of the ticker- Returns:
Observable
that emitsTicker
when exchange sends the update.
-
getTrades
Description copied from interface:StreamingMarketDataService
Get the trades performed by the exchange. EmitsNotConnectedException
When not connected to the WebSocket API.Warning: There are currently no guarantees that messages will not be skipped.
- Specified by:
getTrades
in interfaceStreamingMarketDataService
- Parameters:
currencyPair
- Currency pair of the trades- Returns:
Observable
that emitsTrade
when exchange sends the update.
-
openSubscriptions
Registers subsriptions 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.
-