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();
}
}
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"));
}
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);
}
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"));
}
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"));
}
Aggregations