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 ticker data showing BTC to USD Ticker ticker = marketDataService.getTicker(CurrencyPair.BTC_USD); System.out.println("Pair: " + ticker.getCurrencyPair()); System.out.println("Last: " + ticker.getLast()); System.out.println("Volume: " + ticker.getVolume()); System.out.println("High: " + ticker.getHigh()); System.out.println("Low: " + ticker.getLow()); System.out.println("Bid: " + ticker.getBid()); System.out.println("Ask: " + ticker.getAsk()); System.out.println("Timestamp: " + ticker.getTimestamp()); } }
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 ticker data showing BTC to USD Ticker ticker = marketDataService.getTicker(new CurrencyPair(Currency.BTC, Currency.USD)); System.out.println("Pair: " + ticker.getCurrencyPair()); System.out.println("Last: " + ticker.getLast()); System.out.println("Volume: " + ticker.getVolume()); System.out.println("High: " + ticker.getHigh()); System.out.println("Low: " + ticker.getLow()); System.out.println("Bid: " + ticker.getBid()); System.out.println("Ask: " + ticker.getAsk()); System.out.println("Timestamp: " + ticker.getTimestamp()); } }
private ExchangeRateChange buildExchangeRateChange(CurrencyUnitPair pair, Ticker ticker) { Date date = ticker.getTimestamp(); // Not all exchanges provide a timestamp, default to 0 if it is null long milliseconds = (date != null) ? date.getTime() : 0; return new ExchangeRateChange(buildExchangeRate(pair, ticker), milliseconds); }
public static Ticker adaptUpdate(Ticker ticker, MarketDataIncrementalRefresh message) throws FieldNotFound { Ticker.Builder tickerBuilder = new Ticker.Builder().currencyPair(ticker.getCurrencyPair()).timestamp(ticker.getTimestamp()).bid(ticker.getBid()) .ask(ticker.getAsk()).last(ticker.getLast()).high(ticker.getHigh()).low(ticker.getLow()).volume(ticker.getVolume()); int noMDEntries = message.getNoMDEntries().getValue(); for (int i = 1; i <= noMDEntries; i++) { Group group = message.getGroup(i, NoMDEntries.FIELD); adapt(tickerBuilder, group); } return tickerBuilder.build(); }