org.knowm.xchange.dto.account.Balance.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(200)

本文整理了Java中org.knowm.xchange.dto.account.Balance.<init>()方法的一些代码示例,展示了Balance.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Balance.<init>()方法的具体详情如下:
包路径:org.knowm.xchange.dto.account.Balance
类名称:Balance
方法名:<init>

Balance.<init>介绍

[英]Constructs a balance, the #available will be the same as the total, and the #frozen is zero. The borrowed and loaned will be zero.
[中]构建余额时,可用的#将与total相同,#冻结的为零。borrowedloaned将为零。

代码示例

代码示例来源:origin: knowm/XChange

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);
 }
}

代码示例来源:origin: knowm/XChange

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);
}

代码示例来源:origin: knowm/XChange

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);
}

代码示例来源:origin: knowm/XChange

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);
}

代码示例来源:origin: knowm/XChange

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;
}

代码示例来源:origin: knowm/XChange

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);
}

代码示例来源:origin: knowm/XChange

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));
}

代码示例来源:origin: knowm/XChange

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);
}

代码示例来源:origin: knowm/XChange

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);
}

代码示例来源:origin: knowm/XChange

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;
}

代码示例来源:origin: knowm/XChange

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);
}

代码示例来源:origin: knowm/XChange

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;
}

代码示例来源:origin: knowm/XChange

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);
}

代码示例来源:origin: knowm/XChange

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);
}

代码示例来源:origin: knowm/XChange

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));
}

代码示例来源:origin: knowm/XChange

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));
}

代码示例来源:origin: knowm/XChange

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);
}

代码示例来源:origin: knowm/XChange

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);
 }
}

代码示例来源:origin: knowm/XChange

/**
 * 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());
}

代码示例来源:origin: knowm/XChange

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;
}

相关文章