Skip to content

Commit

Permalink
Merge pull request knowm#4810 from rizer1980/core_getorderbookupdates…
Browse files Browse the repository at this point in the history
…_to_PR

[CORE] Give ability to get separate snapshots of orderbook updates.
  • Loading branch information
timmolter authored and duplessisc committed May 28, 2024
2 parents 08abaf5 + 9402c59 commit ca41224
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,9 @@ private Observable<BinanceKline> 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<List<OrderBookUpdate>> getOrderBookUpdates(Instrument instrument) {
@Override
public Observable<List<OrderBookUpdate>> getOrderBookUpdates(Instrument instrument,
Object... args) {
if (!service.isLiveSubscriptionEnabled()
&& !service.getProductSubscription().getOrderBook().contains(instrument)) {
throw new UpFrontSubscriptionRequiredException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -92,4 +93,16 @@ default Observable<FundingRate> getFundingRate(Instrument instrument, Object...
default Observable<FundingRates> 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<List<OrderBookUpdate>> getOrderBookUpdates(Instrument instrument,
Object... args) {
throw new NotYetImplementedForExchangeException("getOrderBookUpdates");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ public Observable<OrderBook> getOrderBook(Instrument instrument, Object... args)
});
}

public Observable<List<OrderBookUpdate>> getOrderBookUpdates(Instrument instrument) {
@Override
public Observable<List<OrderBookUpdate>> getOrderBookUpdates(Instrument instrument,
Object... args) {
return orderBookUpdatesSubscriptions.computeIfAbsent(instrument, v -> PublishSubject.create());
}

Expand Down

0 comments on commit ca41224

Please sign in to comment.