BitfinexStreamingAdapters { static UserTrade adaptUserTrade(BitfinexWebSocketAuthTrade authTrade) { return new UserTrade.Builder() .currencyPair(BitfinexAdapters.adaptCurrencyPair(adaptV2SymbolToV1(authTrade.getPair()))) .feeAmount(authTrade.getFee().abs()) .feeCurrency(Currency.getInstance(authTrade.getFeeCurrency())) .id(Long.toString(authTrade.getId())) .orderId(Long.toString(authTrade.getOrderId())) .originalAmount(authTrade.getExecAmount().abs()) .price(authTrade.getExecPrice()) .timestamp(DateUtils.fromMillisUtc(authTrade.getMtsCreate())) .type(authTrade.getExecAmount().signum() == 1 ? BID : ASK) .build(); }    }
@Test public void testTradeBuy() { BitfinexWebSocketAuthTrade bitfinexWebSocketAuthTrade = new BitfinexWebSocketAuthTrade( 335015622L, "tBTCUSD", 1548674247684L, 21895093123L, new BigDecimal("0.00341448"), new BigDecimal("3495.4"), "SHOULDNT MATTER", new BigDecimal("3495.9"), 1548674247683L, new BigDecimal("-0.00000682896"), "BTC" ); UserTrade adapted = BitfinexStreamingAdapters.adaptUserTrade(bitfinexWebSocketAuthTrade); assertEquals(CurrencyPair.BTC_USD, adapted.getCurrencyPair()); assertEquals(new BigDecimal("0.00000682896"), adapted.getFeeAmount()); assertEquals(CurrencyPair.BTC_USD.base, adapted.getFeeCurrency()); assertEquals("335015622", adapted.getId()); assertEquals("21895093123", adapted.getOrderId()); assertEquals(new BigDecimal("0.00341448"), adapted.getOriginalAmount()); assertEquals(new BigDecimal("3495.4"), adapted.getPrice()); assertEquals(new Date(1548674247684L).getTime(), adapted.getTimestamp().getTime()); assertEquals(OrderType.BID, adapted.getType()); }
@Test public void testTradeSell() { BitfinexWebSocketAuthTrade bitfinexWebSocketAuthTrade = new BitfinexWebSocketAuthTrade( 335015622L, "tBTCUSD", 1548674247684L, 21895093123L, new BigDecimal("-0.00341448"), new BigDecimal("3495.4"), "SHOULDNT MATTER", new BigDecimal("3495.9"), 1548674247683L, new BigDecimal("0.00000682896"), "BTC" ); UserTrade adapted = BitfinexStreamingAdapters.adaptUserTrade(bitfinexWebSocketAuthTrade); assertEquals(CurrencyPair.BTC_USD, adapted.getCurrencyPair()); assertEquals(new BigDecimal("0.00000682896"), adapted.getFeeAmount()); assertEquals(CurrencyPair.BTC_USD.base, adapted.getFeeCurrency()); assertEquals("335015622", adapted.getId()); assertEquals("21895093123", adapted.getOrderId()); assertEquals(new BigDecimal("0.00341448"), adapted.getOriginalAmount()); assertEquals(new BigDecimal("3495.4"), adapted.getPrice()); assertEquals(new Date(1548674247684L).getTime(), adapted.getTimestamp().getTime()); assertEquals(OrderType.ASK, adapted.getType()); }