diff --git a/xchange-stream-binance/src/main/java/info/bitrich/xchangestream/binance/BinanceStreamingMarketDataService.java b/xchange-stream-binance/src/main/java/info/bitrich/xchangestream/binance/BinanceStreamingMarketDataService.java index ac3d1c8a759..9daa381f9bf 100644 --- a/xchange-stream-binance/src/main/java/info/bitrich/xchangestream/binance/BinanceStreamingMarketDataService.java +++ b/xchange-stream-binance/src/main/java/info/bitrich/xchangestream/binance/BinanceStreamingMarketDataService.java @@ -253,7 +253,9 @@ private Observable klinesStream(Instrument instrument, KlineInterv * This api provides the ability to start receiving updates immediately. It is allowed to * subscribe to this api and {@link #getOrderBook(Instrument, Object...)} at the same time. */ - public Observable> getOrderBookUpdates(Instrument instrument) { + @Override + public Observable> getOrderBookUpdates(Instrument instrument, + Object... args) { if (!service.isLiveSubscriptionEnabled() && !service.getProductSubscription().getOrderBook().contains(instrument)) { throw new UpFrontSubscriptionRequiredException(); diff --git a/xchange-stream-binance/src/test/java/info/bitrich/xchangestream/binance/BinanceManualExample.java b/xchange-stream-binance/src/test/java/info/bitrich/xchangestream/binance/BinanceManualExample.java index 79b590b2475..f0f42ec126e 100644 --- a/xchange-stream-binance/src/test/java/info/bitrich/xchangestream/binance/BinanceManualExample.java +++ b/xchange-stream-binance/src/test/java/info/bitrich/xchangestream/binance/BinanceManualExample.java @@ -143,7 +143,7 @@ private static Disposable orderbooks(StreamingExchange exchange, String identifi } private static Disposable orderbooksIncremental( - BinanceStreamingExchange exchange, String identifier) { + StreamingExchange exchange, String identifier) { return exchange .getStreamingMarketDataService() .getOrderBookUpdates(CurrencyPair.LTC_BTC) diff --git a/xchange-stream-core/src/main/java/info/bitrich/xchangestream/core/StreamingMarketDataService.java b/xchange-stream-core/src/main/java/info/bitrich/xchangestream/core/StreamingMarketDataService.java index c801d102f70..18eab988eb2 100644 --- a/xchange-stream-core/src/main/java/info/bitrich/xchangestream/core/StreamingMarketDataService.java +++ b/xchange-stream-core/src/main/java/info/bitrich/xchangestream/core/StreamingMarketDataService.java @@ -1,6 +1,7 @@ package info.bitrich.xchangestream.core; import io.reactivex.Observable; +import java.util.List; import org.knowm.xchange.currency.CurrencyPair; import org.knowm.xchange.dto.marketdata.*; import org.knowm.xchange.exceptions.NotYetImplementedForExchangeException; @@ -92,4 +93,16 @@ default Observable getFundingRate(Instrument instrument, Object... default Observable getFundingRates() { throw new NotYetImplementedForExchangeException("getFundingRates"); } + + /** + * Get snapshots of orderBook update separately. + * Work only with {@link #getOrderBook(Instrument, Object...)} subscription. + * + * @return {@link Observable} that emits {@link OrderBookUpdate} when exchange sends the orderBook + * snapshot. + */ + default Observable> getOrderBookUpdates(Instrument instrument, + Object... args) { + throw new NotYetImplementedForExchangeException("getOrderBookUpdates"); + } } diff --git a/xchange-stream-okex/src/main/java/info/bitrich/xchangestream/okex/OkexStreamingMarketDataService.java b/xchange-stream-okex/src/main/java/info/bitrich/xchangestream/okex/OkexStreamingMarketDataService.java index 089d019aa61..580cb96c982 100644 --- a/xchange-stream-okex/src/main/java/info/bitrich/xchangestream/okex/OkexStreamingMarketDataService.java +++ b/xchange-stream-okex/src/main/java/info/bitrich/xchangestream/okex/OkexStreamingMarketDataService.java @@ -162,7 +162,9 @@ public Observable getOrderBook(Instrument instrument, Object... args) }); } - public Observable> getOrderBookUpdates(Instrument instrument) { + @Override + public Observable> getOrderBookUpdates(Instrument instrument, + Object... args) { return orderBookUpdatesSubscriptions.computeIfAbsent(instrument, v -> PublishSubject.create()); }