public Balance build() { if (frozen == null) { if (total == null || available == null) { frozen = BigDecimal.ZERO; } } return new Balance( currency, total, available, frozen, borrowed, loaned, withdrawing, depositing); } }
public static Balance adaptBalance( Map<String, String> balances, Map<String, String> reserved, String ccy) { Currency currency = Currency.getInstance(ccy); BigDecimal available = new BigDecimal(balances.get(ccy)); BigDecimal frozen = new BigDecimal(reserved.get(ccy)); return new Balance(currency, available.add(frozen), available, frozen); }
public static Wallet adaptWallet(Map<String, BigDecimal> krakenWallet) { List<Balance> balances = new ArrayList<>(krakenWallet.size()); for (Entry<String, BigDecimal> balancePair : krakenWallet.entrySet()) { Currency currency = adaptCurrency(balancePair.getKey()); Balance balance = new Balance(currency, balancePair.getValue()); balances.add(balance); } return new Wallet(balances); }
public static Wallet adaptWallet(Map<String, BigDecimal> bitmexWallet) { List<Balance> balances = new ArrayList<>(bitmexWallet.size()); for (Entry<String, BigDecimal> balancePair : bitmexWallet.entrySet()) { Currency currency = adaptCurrency(balancePair.getKey()); Balance balance = new Balance(currency, balancePair.getValue()); balances.add(balance); } return new Wallet(balances); }
public static List<Balance> adaptPoloniexBalances( HashMap<String, PoloniexBalance> poloniexBalances) { List<Balance> balances = new ArrayList<>(); for (Map.Entry<String, PoloniexBalance> item : poloniexBalances.entrySet()) { Currency currency = Currency.getInstance(item.getKey()); balances.add( new Balance( currency, null, item.getValue().getAvailable(), item.getValue().getOnOrders())); } return balances; }
public static Wallet adaptWallet(WexAccountInfo wexAccountInfo) { List<Balance> balances = new ArrayList<>(); Map<String, BigDecimal> funds = wexAccountInfo.getFunds(); for (String lcCurrency : funds.keySet()) { /* BTC-E signals DASH as DSH. This is a different coin. Translate in correct DASH name */ BigDecimal fund = funds.get(lcCurrency); Currency currency = adaptCurrencyIn(lcCurrency); balances.add(new Balance(currency, fund)); } return new Wallet(balances); }
public static AccountInfo adaptAccountInfo(VircurexAccountInfoReturn vircurexAccountInfo) { List<Balance> balances = new ArrayList<>(); Map<String, Map<String, BigDecimal>> funds = vircurexAccountInfo.getAvailableFunds(); for (String lcCurrency : funds.keySet()) { Currency currency = Currency.getInstance(lcCurrency.toUpperCase()); // TODO does vircurex offer total balance as well? the api page lists two output keys balances.add(new Balance(currency, null, funds.get(lcCurrency).get("availablebalance"))); } return new AccountInfo(new Wallet(balances)); }
public static Balance adaptBalance(Currency currency, CexIOBalance balance) { BigDecimal inOrders = balance.getOrders(); BigDecimal frozen = inOrders == null ? BigDecimal.ZERO : inOrders; return new Balance(currency, null, balance.getAvailable(), frozen); }
private static Balance adaptBalance(KucoinCoinBalance balance) { BigDecimal avail = balance.getBalance(); BigDecimal freezeBalance = balance.getFreezeBalance(); BigDecimal total = BigDecimal.ZERO.add(avail).add(freezeBalance); return new Balance(Currency.getInstance(balance.getCoinType()), total, avail, freezeBalance); }
public static List<Wallet> adapt(FiatAccount[] balances) { List<Wallet> res = new ArrayList<>(); for (FiatAccount nativeBalance : balances) { Balance balance = new Balance( Currency.getInstance(nativeBalance.getCurrency()), nativeBalance.getBalance()); res.add(new Wallet(String.valueOf(nativeBalance.getId()), balance)); } return res; }
public static Wallet adaptWallet(String name, List<HitbtcBalance> hitbtcBalances) { List<Balance> balances = new ArrayList<>(hitbtcBalances.size()); for (HitbtcBalance balanceRaw : hitbtcBalances) { Currency currency = Currency.getInstance(balanceRaw.getCurrency()); Balance balance = new Balance(currency, null, balanceRaw.getAvailable(), balanceRaw.getReserved()); balances.add(balance); } return new Wallet(name, name, balances); }
public static List<Wallet> adapt(BitcoinAccount[] balances) { List<Wallet> res = new ArrayList<>(); for (BitcoinAccount nativeBalance : balances) { Balance balance = new Balance( Currency.getInstance(nativeBalance.getCurrency()), nativeBalance.getBalance()); res.add(new Wallet(String.valueOf(nativeBalance.getId()), balance)); } return res; }
public static Wallet adaptWallet(UpbitBalances wallets) { List<Balance> balances = new ArrayList<>(); Arrays.stream(wallets.getBalances()) .forEach( balance -> { balances.add( new Balance( Currency.getInstance(balance.getCurrency()), balance.getBalance().add(balance.getLocked()), balance.getBalance())); }); return new Wallet(balances); }
public static Wallet adaptFiatAccountWallet(FiatAccount[] fiatAccounts) { List<Balance> balances = new ArrayList<>(); for (FiatAccount fiatAccount : fiatAccounts) { Balance fiatBalance = new Balance( Currency.getInstance(fiatAccount.getCurrency()), fiatAccount.getBalance(), fiatAccount.getBalance()); balances.add(fiatBalance); } return new Wallet(balances); }
public static AccountInfo adaptAccountInfoFutures(OkCoinFuturesUserInfoCross futureUserInfo) { OkcoinFuturesFundsCross btcFunds = futureUserInfo.getFunds(Currency.BTC); OkcoinFuturesFundsCross ltcFunds = futureUserInfo.getFunds(Currency.LTC); OkcoinFuturesFundsCross bchFunds = futureUserInfo.getFunds(Currency.BCH); Balance btcBalance = new Balance(BTC, btcFunds.getAccountRights()); Balance ltcBalance = new Balance(LTC, ltcFunds.getAccountRights()); Balance bchBalance = new Balance(BCH, bchFunds.getAccountRights()); return new AccountInfo(new Wallet(zeroUsdBalance, btcBalance, ltcBalance, bchBalance)); }
public static AccountInfo adaptAccountInfo(List<TheRockBalance> trBalances, String userName) { ArrayList<Balance> balances = new ArrayList<>(trBalances.size()); for (TheRockBalance blc : trBalances) { Currency currency = Currency.getInstance(blc.getCurrency()); balances.add(new Balance(currency, blc.getBalance(), blc.getTradingBalance())); } return new AccountInfo(userName, new Wallet(balances)); }
public static Wallet adaptBleutradeBalances(List<BleutradeBalance> bleutradeBalances) { List<Balance> balances = new ArrayList<>(); for (BleutradeBalance bleutradeBalance : bleutradeBalances) { balances.add( new Balance( Currency.getInstance(bleutradeBalance.getCurrency()), bleutradeBalance.getBalance(), bleutradeBalance.getAvailable(), bleutradeBalance.getPending())); } return new Wallet(null, balances); }
public static AccountInfo adaptAccountInfo( BitcoinCoreBalanceResponse available, BitcoinCoreBalanceResponse unconfirmed) { BigDecimal total = available.getAmount().add(unconfirmed.getAmount()); Balance btc = new Balance(Currency.BTC, total, available.getAmount(), unconfirmed.getAmount()); Wallet wallet = new Wallet(btc); return new AccountInfo(wallet); } }
/** * Adapts AbucoinsAccount to a Balance * * @param account AbucoinsAccount balance * @return The account info */ public static Balance adaptBalance(AbucoinsAccount account) { Currency currency = Currency.getInstance(account.getCurrency()); return new Balance(currency, account.getBalance(), account.getAvailable(), account.getHold()); }
public static AccountInfo adaptAccountInfo(CoinbaseUser user) { final String username = user.getEmail(); final CoinbaseMoney money = user.getBalance(); final Balance balance = new Balance(Currency.getInstance(money.getCurrency()), money.getAmount()); final AccountInfo accountInfoTemporaryName = new AccountInfo(username, new Wallet(balance)); return accountInfoTemporaryName; }