DeribitAdapters { public static Ticker adaptTicker(DeribitTicker deribitTicker) { return new Ticker.Builder() .currencyPair(adaptCurrencyPair(deribitTicker.getInstrumentName())) .open(deribitTicker.getOpenInterest()) .last(deribitTicker.getLastPrice()) .bid(deribitTicker.getBestBidPrice()) .ask(deribitTicker.getBestAskPrice()) .high(deribitTicker.getMaxPrice()) .low(deribitTicker.getMinPrice()) .volume(deribitTicker.getStats().getVolume()) .bidSize(deribitTicker.getBestBidAmount()) .askSize(deribitTicker.getBestAskAmount()) .timestamp(deribitTicker.getTimestamp()) .build(); }  static CurrencyPair adaptCurrencyPair(String instrumentName); static String adaptInstrumentName(CurrencyPair pair, Object[] args); static Ticker adaptTicker(DeribitTicker deribitTicker); static OrderBook adaptOrderBook(DeribitOrderBook deribitOrderBook); static Trade adaptTrade(DeribitTrade deribitTrade); static Trades adaptTrades(DeribitTrades deribitTrades); static ExchangeException adapt(DeribitException ex); static Balance adapt(AccountSummary as);  }
@Test public void adaptTicker() throws IOException { InputStream is = DeribitTrade.class.getResourceAsStream( "/org/knowm/xchange/deribit/v2/dto/marketdata/example-ticker.json"); ObjectMapper mapper = new ObjectMapper(); DeribitTicker deribitTicker = mapper.readValue(is, DeribitTicker.class); Ticker ticker = DeribitAdapters.adaptTicker(deribitTicker); assertThat(ticker).isNotNull(); assertThat(ticker.getCurrencyPair()).isEqualTo(new CurrencyPair("BTC", "3MAY19-5000-P")); assertThat(ticker.getOpen()).isEqualTo(new BigDecimal("0.5")); assertThat(ticker.getLast()).isEqualTo(new BigDecimal("0.0075")); assertThat(ticker.getBid()).isEqualTo(new BigDecimal("0.01")); assertThat(ticker.getAsk()).isEqualTo(new BigDecimal("0.0135")); assertThat(ticker.getHigh()).isEqualTo(new BigDecimal("0.0625")); assertThat(ticker.getLow()).isEqualTo(new BigDecimal("0.0005")); assertThat(ticker.getVolume()).isEqualTo(new BigDecimal("0.5")); assertThat(ticker.getBidSize()).isEqualTo(new BigDecimal("5")); assertThat(ticker.getAskSize()).isEqualTo(new BigDecimal("5")); assertThat(ticker.getTimestamp().getTime()).isEqualTo(1556125162701L); }