use of org.knowm.xchange.dto.marketdata.Ticker in project XChange by knowm.
the class MarketDataTest method testTickerAdapter.
@Test
public void testTickerAdapter() throws Exception {
InputStream is = MarketDataTest.class.getResourceAsStream("/org/knowm/xchange/btcc/ticker.json");
ObjectMapper mapper = new ObjectMapper();
TypeFactory t = TypeFactory.defaultInstance();
Map<String, BTCCTicker> response = mapper.readValue(is, t.constructMapType(Map.class, String.class, BTCCTicker.class));
BTCCTicker btccTicker = response.get("ticker");
Ticker ticker = BTCCAdapters.adaptTicker(btccTicker, CurrencyPair.BTC_USD);
assertThat(ticker.getHigh()).isEqualTo(new BigDecimal("1730"));
assertThat(ticker.getLow()).isEqualTo(new BigDecimal("1688"));
assertThat(ticker.getLast()).isEqualTo(new BigDecimal("1725"));
assertThat(ticker.getVolume()).isEqualTo(new BigDecimal("113.3411"));
assertThat(ticker.getAsk()).isEqualTo(new BigDecimal("1729"));
assertThat(ticker.getBid()).isEqualTo(new BigDecimal("1725"));
}
use of org.knowm.xchange.dto.marketdata.Ticker in project XChange by knowm.
the class BTCMarketsAdaptersTest method shouldAdaptTicker.
@Test
public void shouldAdaptTicker() throws IOException {
final BTCMarketsTicker response = parse(BTCMarketsTicker.class);
final Ticker ticker = BTCMarketsAdapters.adaptTicker(CurrencyPair.BTC_AUD, response);
assertThat(ticker.getBid()).isEqualTo("137.00");
assertThat(ticker.getAsk()).isEqualTo("140.00");
assertThat(ticker.getLast()).isEqualTo("140.00");
assertThat(ticker.getCurrencyPair()).isEqualTo(CurrencyPair.BTC_AUD);
assertThat(ticker.getTimestamp().getTime()).isEqualTo(1378878117000L);
}
use of org.knowm.xchange.dto.marketdata.Ticker in project XChange by knowm.
the class BTCTradeAdaptersTest method testAdaptTicker.
@Test
public void testAdaptTicker() throws IOException {
BTCTradeTicker btcTradeTicker = mapper.readValue(getClass().getResource("dto/marketdata/ticker.json"), BTCTradeTicker.class);
Ticker ticker = BTCTradeAdapters.adaptTicker(btcTradeTicker, CurrencyPair.BTC_CNY);
assertEquals(new BigDecimal("3760"), ticker.getHigh());
assertEquals(new BigDecimal("3658"), ticker.getLow());
assertEquals(new BigDecimal("3752"), ticker.getBid());
assertEquals(new BigDecimal("3758"), ticker.getAsk());
assertEquals(new BigDecimal("3757"), ticker.getLast());
assertEquals(new BigDecimal("11009.76"), ticker.getVolume());
}
use of org.knowm.xchange.dto.marketdata.Ticker in project XChange by knowm.
the class TickerDemo method generic.
private static void generic(MarketDataService marketDataService) throws IOException {
Ticker ticker = marketDataService.getTicker(CurrencyPair.BTC_USD);
System.out.println(ticker.toString());
}
use of org.knowm.xchange.dto.marketdata.Ticker in project XChange by knowm.
the class ParibuTickerDemo method generic.
private static void generic(MarketDataService marketDataService) throws IOException {
Ticker ticker = marketDataService.getTicker(CurrencyPair.BTC_TRY);
System.out.println(ticker.toString());
}
Aggregations