Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CORE] Give ability to get separate snapshots of orderbook updates. #4810

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -162,7 +162,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
Loading