info.bitrich.xchangestream.huobi.HuobiStreamingExchange Maven / Gradle / Ivy
package info.bitrich.xchangestream.huobi;
import info.bitrich.xchangestream.core.ProductSubscription;
import info.bitrich.xchangestream.core.StreamingExchange;
import info.bitrich.xchangestream.core.StreamingMarketDataService;
import info.bitrich.xchangestream.service.netty.ConnectionStateModel.State;
import io.reactivex.rxjava3.core.Completable;
import io.reactivex.rxjava3.core.Observable;
import org.knowm.xchange.huobi.HuobiExchange;
public class HuobiStreamingExchange extends HuobiExchange implements StreamingExchange {
private static final String API_BASE_URI = "wss://api.huobi.pro/ws";
private static final String API_URI_AWS = "wss://api-aws.huobi.pro/ws";
private HuobiStreamingService streamingService;
private HuobiStreamingMarketDataService streamingMarketDataService;
@Override
protected void initServices() {
super.initServices();
Boolean aws =
(Boolean)
getExchangeSpecification()
.getExchangeSpecificParameters()
.getOrDefault("AWS", Boolean.FALSE);
this.streamingService = new HuobiStreamingService(aws ? API_URI_AWS : API_BASE_URI);
this.streamingService.useCompressedMessages(true);
applyStreamingSpecification(getExchangeSpecification(), streamingService);
streamingMarketDataService = new HuobiStreamingMarketDataService(streamingService);
}
@Override
public Completable connect(ProductSubscription... args) {
return streamingService.connect();
}
@Override
public Completable disconnect() {
return streamingService.disconnect();
}
@Override
public boolean isAlive() {
return streamingService.isSocketOpen();
}
@Override
public Observable reconnectFailure() {
return streamingService.subscribeReconnectFailure();
}
@Override
public Observable
© 2015 - 2024 Weber Informatics LLC | Privacy Policy