DeribitAdapters { public static Trade adaptTrade(DeribitTrade deribitTrade) { Order.OrderType type = null; switch (deribitTrade.getDirection()) { case buy: type = Order.OrderType.BID; break; case sell: type = Order.OrderType.ASK; break; default: break; } return new Trade.Builder() .type(type) .originalAmount(deribitTrade.getAmount()) .currencyPair(adaptCurrencyPair(deribitTrade.getInstrumentName())) .price(deribitTrade.getPrice()) .timestamp(deribitTrade.getTimestamp()) .id(deribitTrade.getTradeId()) .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 adaptTrade() throws IOException { InputStream is = DeribitTrade.class.getResourceAsStream( "/org/knowm/xchange/deribit/v2/dto/marketdata/example-trade.json"); ObjectMapper mapper = new ObjectMapper(); DeribitTrade deribitTrade = mapper.readValue(is, DeribitTrade.class); Trade trade = DeribitAdapters.adaptTrade(deribitTrade); assertThat(trade).isNotNull(); assertThat(trade.getType()).isEqualTo(Order.OrderType.ASK); assertThat(trade.getOriginalAmount()).isEqualTo(new BigDecimal("10")); assertThat(trade.getPrice()).isEqualTo(new BigDecimal("3610")); assertThat(trade.getTimestamp().getTime()).isEqualTo(1550050591859L); assertThat(trade.getId()).isEqualTo("48470"); }