Search in sources :

Example 6 with StreamingExchange

use of info.bitrich.xchangestream.core.StreamingExchange in project XChange by knowm.

the class OkExManualExample method main.

public static void main(String[] args) {
    StreamingExchange exchange = StreamingExchangeFactory.INSTANCE.createExchange(OkExStreamingExchange.class);
    exchange.connect().blockingAwait();
    CurrencyPair btcUsdt = new CurrencyPair(new Currency("BTC"), new Currency("USDT"));
    exchange.getStreamingMarketDataService().getOrderBook(btcUsdt).subscribe(orderBook -> {
        LOG.info("First ask: {}", orderBook.getAsks().get(0));
        LOG.info("First bid: {}", orderBook.getBids().get(0));
    }, throwable -> LOG.error("ERROR in getting order book: ", throwable));
    exchange.getStreamingMarketDataService().getTicker(btcUsdt).subscribe(ticker -> {
        LOG.info("TICKER: {}", ticker);
    }, throwable -> LOG.error("ERROR in getting ticker: ", throwable));
    exchange.getStreamingMarketDataService().getTrades(btcUsdt).subscribe(trade -> {
        LOG.info("TRADE: {}", trade);
    }, throwable -> LOG.error("ERROR in getting trades: ", throwable));
    try {
        Thread.sleep(10000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}
Also used : StreamingExchange(info.bitrich.xchangestream.core.StreamingExchange) Currency(org.knowm.xchange.currency.Currency) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 7 with StreamingExchange

use of info.bitrich.xchangestream.core.StreamingExchange in project XChange by knowm.

the class BankeraManualExample method main.

public static void main(String[] args) {
    StreamingExchange exchange = StreamingExchangeFactory.INSTANCE.createExchange(BankeraStreamingExchange.class);
    exchange.connect().blockingAwait();
    exchange.getStreamingMarketDataService().getOrderBook(CurrencyPair.ETH_BTC).subscribe(orderBook -> LOGGER.debug("ORDERBOOK: {}", orderBook.toString()), throwable -> LOGGER.error("ERROR in getting order book: ", throwable));
    exchange.getStreamingMarketDataService().getTrades(CurrencyPair.ETH_BTC).subscribe(trade -> LOGGER.debug("TRADES: {}", trade.toString()), throwable -> LOGGER.error("ERROR in getting trade ", throwable));
    try {
        Thread.sleep(10000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    exchange.disconnect().subscribe(() -> LOGGER.info("Disconnected"));
}
Also used : StreamingExchange(info.bitrich.xchangestream.core.StreamingExchange)

Example 8 with StreamingExchange

use of info.bitrich.xchangestream.core.StreamingExchange in project XChange by knowm.

the class BinanceOrderbookHighVolumeExample method main.

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

Example 9 with StreamingExchange

use of info.bitrich.xchangestream.core.StreamingExchange in project XChange by knowm.

the class KrakenManualPrivateTest method main.

public static void main(String[] args) throws InterruptedException {
    ExchangeSpecification exchangeSpecification = new ExchangeSpecification(KrakenStreamingExchange.class);
    exchangeSpecification.setApiKey(args[0]);
    exchangeSpecification.setSecretKey(args[1]);
    exchangeSpecification.setUserName(args[2]);
    StreamingExchange krakenExchange = StreamingExchangeFactory.INSTANCE.createExchange(exchangeSpecification);
    krakenExchange.connect().blockingAwait();
    krakenExchange.getStreamingTradeService().getUserTrades(null).subscribe(b -> {
        LOG.info("Received userTrade {}", b);
    }, throwable -> {
        LOG.error("UserTrades FAILED {}", throwable.getMessage(), throwable);
    });
    krakenExchange.getStreamingTradeService().getOrderChanges(null).subscribe(b -> {
        LOG.info("Received orderChange {}", b);
    }, throwable -> {
        LOG.error("OrderChange FAILED {}", throwable.getMessage(), throwable);
    });
    TimeUnit.SECONDS.sleep(120);
    krakenExchange.disconnect().subscribe(() -> LOG.info("Disconnected"));
}
Also used : StreamingExchange(info.bitrich.xchangestream.core.StreamingExchange) ExchangeSpecification(org.knowm.xchange.ExchangeSpecification)

Example 10 with StreamingExchange

use of info.bitrich.xchangestream.core.StreamingExchange in project XChange by knowm.

the class KrakenOrderbookExample method main.

public static void main(String[] args) throws InterruptedException {
    ExchangeSpecification exchangeSpecification = new ExchangeSpecification(KrakenStreamingExchange.class);
    StreamingExchange krakenExchange = StreamingExchangeFactory.INSTANCE.createExchange(exchangeSpecification);
    krakenExchange.connect().blockingAwait();
    subscribe(krakenExchange, BTC_USD);
    TimeUnit.SECONDS.sleep(Integer.MAX_VALUE);
    krakenExchange.disconnect().subscribe(() -> LOG.info("Disconnected"));
}
Also used : StreamingExchange(info.bitrich.xchangestream.core.StreamingExchange) ExchangeSpecification(org.knowm.xchange.ExchangeSpecification)

Aggregations

StreamingExchange (info.bitrich.xchangestream.core.StreamingExchange)28 ExchangeSpecification (org.knowm.xchange.ExchangeSpecification)16 Disposable (io.reactivex.disposables.Disposable)14 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)7 Test (org.junit.Test)6 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)3 ProductSubscription (info.bitrich.xchangestream.core.ProductSubscription)2 StreamingExchangeFactory (info.bitrich.xchangestream.core.StreamingExchangeFactory)2 StreamingMarketDataService (info.bitrich.xchangestream.core.StreamingMarketDataService)2 StreamingTradeService (info.bitrich.xchangestream.core.StreamingTradeService)2 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)2 BigDecimal (java.math.BigDecimal)2 Currency (org.knowm.xchange.currency.Currency)2 USE_REALTIME_BOOK_TICKER (info.bitrich.xchangestream.binance.BinanceStreamingExchange.USE_REALTIME_BOOK_TICKER)1 BitstampStreamingExchange (info.bitrich.xchangestream.bitstamp.v2.BitstampStreamingExchange)1 CexioStreamingExchange (info.bitrich.xchangestream.cexio.CexioStreamingExchange)1 CoinbaseProStreamingExchange (info.bitrich.xchangestream.coinbasepro.CoinbaseProStreamingExchange)1 ArrayList (java.util.ArrayList)1 Ignore (org.junit.Ignore)1 OrderBook (org.knowm.xchange.dto.marketdata.OrderBook)1