public static void main(String[] args) throws IOException { // Use the factory to get Cex.IO exchange API using default settings Exchange exchange = ExchangeFactory.INSTANCE.createExchange(AbucoinsExchange.class.getName()); // Interested in the public market data feed (no authentication) MarketDataService marketDataService = exchange.getMarketDataService(); // Get the latest order book data for GHs/BTC OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.BTC_USD); System.out.println( "Current Order Book size for BTC/USD: " + (orderBook.getAsks().size() + orderBook.getBids().size())); System.out.println("First Ask: " + orderBook.getAsks().get(0).toString()); System.out.println("First Bid: " + orderBook.getBids().get(0).toString()); System.out.println("Timestamp: " + orderBook.getTimeStamp().toString()); // System.out.println(orderBook.toString()); } }
public static void main(String[] args) throws IOException { // Use the factory to get Cex.IO exchange API using default settings Exchange exchange = ExchangeFactory.INSTANCE.createExchange(CexIOExchange.class.getName()); // Interested in the public market data feed (no authentication) MarketDataService marketDataService = exchange.getMarketDataService(); // Get the latest order book data for GHs/BTC OrderBook orderBook = marketDataService.getOrderBook(new CurrencyPair(Currency.GHs, Currency.BTC)); System.out.println( "Current Order Book size for GHS/BTC: " + (orderBook.getAsks().size() + orderBook.getBids().size())); System.out.println("First Ask: " + orderBook.getAsks().get(0).toString()); System.out.println("First Bid: " + orderBook.getBids().get(0).toString()); System.out.println("Timestamp: " + orderBook.getTimeStamp().toString()); // System.out.println(orderBook.toString()); } }
@Override public void onOrderBook(OrderBook orderBook, SessionID sessionId) { long now = System.currentTimeMillis(); log.info("order book time: {}, lagging: {} ms. bids size: {}, asks size: {}. best bid: {}@{}, best ask: {}@{}.", orderBook.getTimeStamp().toInstant(), mFmt.format(now - orderBook.getTimeStamp().getTime()), StringUtils.leftPad(String.valueOf(orderBook.getBids().size()), 3), StringUtils.leftPad(String.valueOf(orderBook.getAsks().size()), 3), StringUtils.leftPad(qFmt.format(orderBook.getBids().get(0).getTradableAmount()), 7), pFmt.format(orderBook.getBids().get(0).getLimitPrice()), StringUtils.leftPad(qFmt.format(orderBook.getAsks().get(0).getTradableAmount()), 7), pFmt.format(orderBook.getAsks().get(0).getLimitPrice()) ); }
XchangeUtil.getHelperForExchange(coinTraderExchange).handleOrderBook(orderBook); log.trace("Attempting create book from: " + orderBook); Book book = bookFactory.create(new Instant(orderBook.getTimeStamp()), market); LimitOrder limitOrder;