use of org.knowm.xchange.dto.account.Balance in project XChange by knowm.
the class CexIOAdapters method adaptBalance.
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);
}
use of org.knowm.xchange.dto.account.Balance in project XChange by knowm.
the class BTCTurkAdapters method adaptWallet.
public static Wallet adaptWallet(String name, BTCTurkAccountBalance btcTurkBalance) {
List<Balance> balances = new ArrayList<>(7);
balances.add(new Balance(Currency.TRY, null, btcTurkBalance.getTry_available(), btcTurkBalance.getTry_reserved()));
balances.add(new Balance(Currency.BTC, null, btcTurkBalance.getBtc_available(), btcTurkBalance.getBtc_reserved()));
balances.add(new Balance(Currency.ETH, null, btcTurkBalance.getEth_available(), btcTurkBalance.getEth_reserved()));
balances.add(new Balance(Currency.XRP, null, btcTurkBalance.getXrp_available(), btcTurkBalance.getXrp_reserved()));
balances.add(new Balance(Currency.LTC, null, btcTurkBalance.getLtc_available(), btcTurkBalance.getLtc_reserved()));
balances.add(new Balance(Currency.USDT, null, btcTurkBalance.getUsdt_available(), btcTurkBalance.getUsdt_reserved()));
balances.add(new Balance(Currency.XLM, null, btcTurkBalance.getXlm_available(), btcTurkBalance.getXlm_reserved()));
return Wallet.Builder.from(balances).id(name).name(name).build();
}
use of org.knowm.xchange.dto.account.Balance in project XChange by knowm.
the class CexIOAdapters method adaptWallet.
/**
* Adapts CexIOBalanceInfo to Wallet
*
* @param cexIOBalanceInfo CexIOBalanceInfo balance
* @return The account info
*/
public static Wallet adaptWallet(CexIOBalanceInfo cexIOBalanceInfo) {
List<Balance> balances = new ArrayList<>();
for (String ccyName : cexIOBalanceInfo.getBalances().keySet()) {
CexIOBalance cexIOBalance = cexIOBalanceInfo.getBalances().get(ccyName);
balances.add(adaptBalance(Currency.getInstance(ccyName), cexIOBalance));
}
return Wallet.Builder.from(balances).build();
}
use of org.knowm.xchange.dto.account.Balance in project XChange by knowm.
the class CryptopiaAccountServiceRaw method getBalances.
public List<Balance> getBalances() throws IOException {
CryptopiaBaseResponse<List<Map>> response = cryptopia.getBalance(signatureCreator, new HashMap<>());
List<Balance> balances = new ArrayList<>();
for (Map datum : response.getData()) {
Currency symbol = Currency.getInstance(datum.get("Symbol").toString());
BigDecimal total = new BigDecimal(datum.get("Total").toString());
BigDecimal available = new BigDecimal(datum.get("Available").toString());
BigDecimal heldForTrades = new BigDecimal(datum.get("HeldForTrades").toString());
BigDecimal pendingWithdraw = new BigDecimal(datum.get("PendingWithdraw").toString());
BigDecimal unconfirmed = new BigDecimal(datum.get("Unconfirmed").toString());
Balance balance = new Balance(symbol, total, available, heldForTrades, BigDecimal.ZERO, BigDecimal.ZERO, pendingWithdraw, unconfirmed);
balances.add(balance);
}
return balances;
}
use of org.knowm.xchange.dto.account.Balance in project XChange by knowm.
the class CryptoFacilitiesAdapters method adaptAccounts.
public static AccountInfo adaptAccounts(CryptoFacilitiesAccounts cryptoFacilitiesAccounts, String username) {
Map<String, CryptoFacilitiesAccountInfo> accounts = cryptoFacilitiesAccounts.getAccounts();
List<Wallet> wallets = new ArrayList<>();
for (String accountName : accounts.keySet()) {
List<Balance> balances = new ArrayList<>(accounts.get(accountName).getBalances().size());
Balance balance;
for (Entry<String, BigDecimal> balancePair : accounts.get(accountName).getBalances().entrySet()) {
if (!accountName.equalsIgnoreCase("cash") && balancePair.getKey().equalsIgnoreCase("xbt")) {
// For xbt balance we construct both total=deposited xbt and available=total - margin
// balances
balance = new Balance(Currency.BTC, balancePair.getValue(), accounts.get(accountName).getAuxiliary().get("af"));
} else {
Currency currency = adaptCurrency(balancePair.getKey());
balance = new Balance(currency, balancePair.getValue());
}
balances.add(balance);
}
wallets.add(Wallet.Builder.from(balances).id(accountName).name(accountName).build());
}
return new AccountInfo(username, wallets);
}
Aggregations