GeminiAdapters { public static Wallet adaptWallet(GeminiBalancesResponse[] response) { Map<String, BigDecimal[]> balancesByCurrency = new HashMap<>(); for (GeminiBalancesResponse balance : response) { String currencyName = balance.getCurrency().toUpperCase(); BigDecimal[] balanceDetail = balancesByCurrency.get(currencyName); if (balanceDetail == null) { balanceDetail = new BigDecimal[] {balance.getAmount(), balance.getAvailable()}; } else { balanceDetail[0] = balanceDetail[0].add(balance.getAmount()); balanceDetail[1] = balanceDetail[1].add(balance.getAvailable()); } balancesByCurrency.put(currencyName, balanceDetail); } List<Balance> balances = new ArrayList<>(balancesByCurrency.size()); for (Entry<String, BigDecimal[]> entry : balancesByCurrency.entrySet()) { String currencyName = entry.getKey(); BigDecimal[] balanceDetail = entry.getValue(); BigDecimal balanceTotal = balanceDetail[0]; BigDecimal balanceAvailable = balanceDetail[1]; balances.add(new Balance(Currency.getInstance(currencyName), balanceTotal, balanceAvailable)); } return Wallet.Builder.from(balances).build(); } private  GeminiAdapters(); static List<CurrencyPair> adaptCurrencyPairs(Collection<String> GeminiSymbol); static CurrencyPair adaptCurrencyPair(String symbol); static String adaptCurrencyPair(CurrencyPair pair); static OrderBook adaptOrderBook(GeminiDepth btceDepth, CurrencyPair currencyPair); static OrdersContainer adaptOrders(
      GeminiLevel[] GeminiLevels, CurrencyPair currencyPair, OrderType orderType); static Order adaptOrder(GeminiOrderStatusResponse geminiOrderStatusResponse); static LimitOrder adaptOrder(
      BigDecimal amount,
      BigDecimal price,
      CurrencyPair currencyPair,
      OrderType orderType,
      Date timestamp); static List<FixedRateLoanOrder> adaptFixedRateLoanOrders(
      GeminiLendLevel[] orders, String currency, String orderType, String id); static FixedRateLoanOrder adaptFixedRateLoanOrder(
      String currency,
      BigDecimal amount,
      int dayPeriod,
      String direction,
      String id,
      BigDecimal rate); static List<FloatingRateLoanOrder> adaptFloatingRateLoanOrders(
      GeminiLendLevel[] orders, String currency, String orderType, String id); static FloatingRateLoanOrder adaptFloatingRateLoanOrder(
      String currency,
      BigDecimal amount,
      int dayPeriod,
      String direction,
      String id,
      BigDecimal rate); static Trade adaptTrade(GeminiTrade trade, CurrencyPair currencyPair); static Trades adaptTrades(GeminiTrade[] trades, CurrencyPair currencyPair); static Ticker adaptTicker(GeminiTicker GeminiTicker, CurrencyPair currencyPair); static Wallet adaptWallet(GeminiBalancesResponse[] response); static OpenOrders adaptOrders(GeminiOrderStatusResponse[] activeOrders); static UserTrades adaptTradeHistory(GeminiTradeResponse[] trades, String symbol); static ExchangeMetaData adaptMetaData(
      List<CurrencyPair> currencyPairs, ExchangeMetaData metaData); static Map<CurrencyPair, Fee> AdaptDynamicTradingFees(
      GeminiTrailingVolumeResponse volumeResponse, List<CurrencyPair> currencyPairs); static FundingRecord adapt(GeminiTransfer transfer); static final Logger log; }
@Test public void shouldAdaptBalances() throws IOException { InputStream is = GeminiWalletJSONTest.class.getResourceAsStream( "/org/knowm/xchange/gemini/v1/account/example-account-info-balance.json"); ObjectMapper mapper = new ObjectMapper(); GeminiBalancesResponse[] response = mapper.readValue(is, GeminiBalancesResponse[].class); Wallet wallet = GeminiAdapters.adaptWallet(response); assertEquals(2, wallet.getBalances().size()); assertEquals(new BigDecimal("105.5"), wallet.getBalance(Currency.USD).getTotal()); assertEquals(new BigDecimal("55.5"), wallet.getBalance(Currency.USD).getAvailable()); assertEquals(new BigDecimal("50"), wallet.getBalance(Currency.BTC).getTotal()); assertEquals(new BigDecimal("30"), wallet.getBalance(Currency.BTC).getAvailable()); }