
info.bitrich.xchangestream.lgo.LgoStreamingMarketDataService Maven / Gradle / Ivy
The newest version!
package info.bitrich.xchangestream.lgo;
import info.bitrich.xchangestream.core.StreamingMarketDataService;
import io.reactivex.rxjava3.core.Observable;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.knowm.xchange.currency.CurrencyPair;
import org.knowm.xchange.dto.marketdata.OrderBook;
import org.knowm.xchange.dto.marketdata.Trade;
public class LgoStreamingMarketDataService implements StreamingMarketDataService {
private final LgoStreamingService service;
private final Map level2Subscriptions =
new ConcurrentHashMap<>();
private final Map tradeSubscriptions =
new ConcurrentHashMap<>();
LgoStreamingMarketDataService(LgoStreamingService lgoStreamingService) {
service = lgoStreamingService;
}
@Override
public Observable getOrderBook(CurrencyPair currencyPair, Object... args) {
return level2Subscriptions
.computeIfAbsent(currencyPair, this::createLevel2Subscription)
.getSubscription();
}
private LgoLevel2BatchSubscription createLevel2Subscription(CurrencyPair currencyPair) {
return LgoLevel2BatchSubscription.create(service, currencyPair);
}
@Override
public Observable getTrades(CurrencyPair currencyPair, Object... args) {
return tradeSubscriptions
.computeIfAbsent(currencyPair, this::createTradeSubscription)
.getSubscription();
}
private LgoTradeBatchSubscription createTradeSubscription(CurrencyPair currencyPair) {
return LgoTradeBatchSubscription.create(service, currencyPair);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy