Search in sources :

Example 1 with USE_REALTIME_BOOK_TICKER

use of info.bitrich.xchangestream.binance.BinanceStreamingExchange.USE_REALTIME_BOOK_TICKER in project XChange by knowm.

the class BinanceBookTickerRealtimeExample method main.

public static void main(String[] args) throws InterruptedException {
    final ExchangeSpecification exchangeSpecification = new ExchangeSpecification(BinanceStreamingExchange.class);
    exchangeSpecification.setShouldLoadRemoteMetaData(true);
    exchangeSpecification.setExchangeSpecificParametersItem(USE_REALTIME_BOOK_TICKER, true);
    StreamingExchange exchange = StreamingExchangeFactory.INSTANCE.createExchange(exchangeSpecification);
    ProductSubscription subscription = exchange.getExchangeSymbols().stream().limit(50).reduce(ProductSubscription.create(), ProductSubscription.ProductSubscriptionBuilder::addTicker, (productSubscriptionBuilder, productSubscriptionBuilder2) -> {
        throw new UnsupportedOperationException();
    }).build();
    exchange.connect(subscription).blockingAwait();
    exchange.getStreamingMarketDataService().getTicker(CurrencyPair.LTC_BTC).forEach(System.out::println);
    Thread.sleep(Long.MAX_VALUE);
}
Also used : ExchangeSpecification(org.knowm.xchange.ExchangeSpecification) StreamingExchangeFactory(info.bitrich.xchangestream.core.StreamingExchangeFactory) USE_REALTIME_BOOK_TICKER(info.bitrich.xchangestream.binance.BinanceStreamingExchange.USE_REALTIME_BOOK_TICKER) StreamingExchange(info.bitrich.xchangestream.core.StreamingExchange) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) ProductSubscription(info.bitrich.xchangestream.core.ProductSubscription) StreamingExchange(info.bitrich.xchangestream.core.StreamingExchange) ProductSubscription(info.bitrich.xchangestream.core.ProductSubscription) ExchangeSpecification(org.knowm.xchange.ExchangeSpecification)

Aggregations

USE_REALTIME_BOOK_TICKER (info.bitrich.xchangestream.binance.BinanceStreamingExchange.USE_REALTIME_BOOK_TICKER)1 ProductSubscription (info.bitrich.xchangestream.core.ProductSubscription)1 StreamingExchange (info.bitrich.xchangestream.core.StreamingExchange)1 StreamingExchangeFactory (info.bitrich.xchangestream.core.StreamingExchangeFactory)1 ExchangeSpecification (org.knowm.xchange.ExchangeSpecification)1 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)1