DeribitAdapters { public static OrderBook adaptOrderBook(DeribitOrderBook deribitOrderBook) { CurrencyPair pair = adaptCurrencyPair(deribitOrderBook.getInstrumentName()); List<LimitOrder> bids = adaptOrdersList(deribitOrderBook.getBids(), Order.OrderType.BID, pair); List<LimitOrder> asks = adaptOrdersList(deribitOrderBook.getAsks(), Order.OrderType.ASK, pair); return new OrderBook(deribitOrderBook.getTimestamp(), asks, bids); }  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 adaptOrderBook() throws IOException { InputStream is = DeribitTrade.class.getResourceAsStream( "/org/knowm/xchange/deribit/v2/dto/marketdata/example-orderbook.json"); ObjectMapper mapper = new ObjectMapper(); DeribitOrderBook deribitOrderbook = mapper.readValue(is, DeribitOrderBook.class); OrderBook orderBook = DeribitAdapters.adaptOrderBook(deribitOrderbook); assertThat(orderBook).isNotNull(); assertThat(orderBook.getTimeStamp().getTime()).isEqualTo(1550757626706L); assertThat(orderBook.getBids()).isNotEmpty(); assertThat(orderBook.getBids().get(0).getType()).isEqualTo(Order.OrderType.BID); assertThat(orderBook.getBids().get(0).getLimitPrice()).isEqualTo(new BigDecimal("3955.75")); assertThat(orderBook.getBids().get(0).getOriginalAmount()).isEqualTo(new BigDecimal("30.0")); assertThat(orderBook.getBids().get(0).getCurrencyPair()) .isEqualTo(new CurrencyPair("BTC", "PERPETUAL")); assertThat(orderBook.getBids().get(1).getType()).isEqualTo(Order.OrderType.BID); assertThat(orderBook.getBids().get(1).getLimitPrice()).isEqualTo(new BigDecimal("3940.75")); assertThat(orderBook.getBids().get(1).getOriginalAmount()) .isEqualTo(new BigDecimal("102020.0")); assertThat(orderBook.getBids().get(1).getCurrencyPair()) .isEqualTo(new CurrencyPair("BTC", "PERPETUAL")); assertThat(orderBook.getBids().get(2).getType()).isEqualTo(Order.OrderType.BID); assertThat(orderBook.getBids().get(2).getLimitPrice()).isEqualTo(new BigDecimal("3423.0")); assertThat(orderBook.getBids().get(2).getOriginalAmount()).isEqualTo(new BigDecimal("42840.0")); assertThat(orderBook.getBids().get(2).getCurrencyPair()) .isEqualTo(new CurrencyPair("BTC", "PERPETUAL")); assertThat(orderBook.getAsks()).isEmpty(); }