use of org.knowm.xchange.mercadobitcoin.dto.marketdata.MercadoBitcoinTicker in project XChange by knowm.
the class TickerDemo method raw.
private static void raw(MercadoBitcoinMarketDataServiceRaw marketDataService) throws IOException {
MercadoBitcoinTicker mercadoBitcoinTicker = marketDataService.getMercadoBitcoinTicker(CurrencyPair.BTC_BRL);
System.out.println(mercadoBitcoinTicker.toString());
}
use of org.knowm.xchange.mercadobitcoin.dto.marketdata.MercadoBitcoinTicker in project XChange by knowm.
the class MercadoBitcoinAdapters method adaptTicker.
/**
* Adapts a MercadoBitcoinTicker to a Ticker Object
*
* @param mercadoBitcoinTicker The exchange specific ticker
* @param currencyPair (e.g. BTC/USD)
* @return The ticker
*/
public static Ticker adaptTicker(MercadoBitcoinTicker mercadoBitcoinTicker, CurrencyPair currencyPair) {
BigDecimal last = mercadoBitcoinTicker.getTicker().getLast();
BigDecimal bid = mercadoBitcoinTicker.getTicker().getBuy();
BigDecimal ask = mercadoBitcoinTicker.getTicker().getSell();
BigDecimal high = mercadoBitcoinTicker.getTicker().getHigh();
BigDecimal low = mercadoBitcoinTicker.getTicker().getLow();
BigDecimal volume = mercadoBitcoinTicker.getTicker().getVol();
Date timestamp = new Date(mercadoBitcoinTicker.getTicker().getDate() * 1000L);
return new Ticker.Builder().currencyPair(currencyPair).last(last).bid(bid).ask(ask).high(high).low(low).volume(volume).timestamp(timestamp).build();
}
use of org.knowm.xchange.mercadobitcoin.dto.marketdata.MercadoBitcoinTicker in project XChange by knowm.
the class MercadoBitcoinAdapterTest method testTickerAdapter.
@Test
public void testTickerAdapter() throws IOException {
// Read in the JSON from the example resources
InputStream is = MercadoBitcoinAdapterTest.class.getResourceAsStream("/org/knowm/xchange/mercadobitcoin/dto/marketdata/example-ticker-data.json");
// Use Jackson to parse it
ObjectMapper mapper = new ObjectMapper();
MercadoBitcoinTicker mercadoBitcoinTicker = mapper.readValue(is, MercadoBitcoinTicker.class);
Ticker ticker = MercadoBitcoinAdapters.adaptTicker(mercadoBitcoinTicker, CurrencyPair.BTC_BRL);
assertThat(ticker.getLast().toString()).isEqualTo("1019.99999");
assertThat(ticker.getBid().toString()).isEqualTo("1019.99999");
assertThat(ticker.getAsk().toString()).isEqualTo("1020");
assertThat(ticker.getVolume()).isEqualTo(new BigDecimal("6.90157391"));
assertThat(ticker.getTimestamp()).isEqualTo(new Date(1417226432L * 1000L));
}
use of org.knowm.xchange.mercadobitcoin.dto.marketdata.MercadoBitcoinTicker in project XChange by knowm.
the class TickerDemo method raw.
private static void raw(MercadoBitcoinMarketDataServiceRaw marketDataService) throws IOException {
MercadoBitcoinTicker mercadoBitcoinTicker = marketDataService.getMercadoBitcoinTicker(new CurrencyPair(Currency.LTC, Currency.BRL));
System.out.println(mercadoBitcoinTicker.toString());
}
Aggregations