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

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

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

Balance.getCurrency介绍

暂无

代码示例

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

/**
 * Constructs a {@link Wallet}.
 *
 * @param id the wallet id
 * @param name a descriptive name for the wallet
 * @param balances the balances, the currencies of the balances should not be duplicated.
 */
public Wallet(String id, String name, Collection<Balance> balances) {
 this.id = id;
 if (name == null) {
  this.name = id;
 } else {
  this.name = name;
 }
 if (balances.size() == 0) {
  this.balances = Collections.emptyMap();
 } else if (balances.size() == 1) {
  Balance balance = balances.iterator().next();
  this.balances = Collections.singletonMap(balance.getCurrency(), balance);
 } else {
  this.balances = new HashMap<>();
  for (Balance balance : balances) {
   if (this.balances.containsKey(balance.getCurrency()))
    // this class could merge balances, but probably better to catch mistakes and let the
    // exchange merge them
    throw new IllegalArgumentException("duplicate balances in wallet");
   this.balances.put(balance.getCurrency(), balance);
  }
 }
}

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

public static Wallet adaptWallet(GateioFunds bterAccountInfo) {
 List<Balance> balances = new ArrayList<>();
 for (Entry<String, BigDecimal> funds : bterAccountInfo.getAvailableFunds().entrySet()) {
  Currency currency = Currency.getInstance(funds.getKey().toUpperCase());
  BigDecimal amount = funds.getValue();
  BigDecimal locked = bterAccountInfo.getLockedFunds().get(currency.toString());
  balances.add(new Balance(currency, null, amount, locked == null ? BigDecimal.ZERO : locked));
 }
 for (Entry<String, BigDecimal> funds : bterAccountInfo.getLockedFunds().entrySet()) {
  Currency currency = Currency.getInstance(funds.getKey().toUpperCase());
  if (balances.stream().noneMatch(balance -> balance.getCurrency().equals(currency))) {
   BigDecimal amount = funds.getValue();
   balances.add(new Balance(currency, null, BigDecimal.ZERO, amount));
  }
 }
 return new Wallet(balances);
}

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

public static Builder from(Balance balance) {
 return new Builder()
   .currency(balance.getCurrency())
   .total(balance.getTotal())
   .available(balance.getAvailable())
   .frozen(balance.getFrozen())
   .borrowed(balance.getBorrowed())
   .loaned(balance.getLoaned())
   .withdrawing(balance.getWithdrawing())
   .depositing(balance.getDepositing());
}

代码示例来源:origin: org.knowm.xchange/xchange-core

/**
 * Constructs a {@link Wallet}.
 *
 * @param id the wallet id
 * @param name a descriptive name for the wallet
 * @param balances the balances, the currencies of the balances should not be duplicated.
 */
public Wallet(String id, String name, Collection<Balance> balances) {
 this.id = id;
 if (name == null) {
  this.name = id;
 } else {
  this.name = name;
 }
 if (balances.size() == 0) {
  this.balances = Collections.emptyMap();
 } else if (balances.size() == 1) {
  Balance balance = balances.iterator().next();
  this.balances = Collections.singletonMap(balance.getCurrency(), balance);
 } else {
  this.balances = new HashMap<>();
  for (Balance balance : balances) {
   if (this.balances.containsKey(balance.getCurrency()))
    // this class could merge balances, but probably better to catch mistakes and let the
    // exchange merge them
    throw new IllegalArgumentException("duplicate balances in wallet");
   this.balances.put(balance.getCurrency(), balance);
  }
 }
}

代码示例来源:origin: org.knowm.xchange/xchange-core

public static Builder from(Balance balance) {
 return new Builder()
   .currency(balance.getCurrency())
   .total(balance.getTotal())
   .available(balance.getAvailable())
   .frozen(balance.getFrozen())
   .borrowed(balance.getBorrowed())
   .loaned(balance.getLoaned())
   .withdrawing(balance.getWithdrawing())
   .depositing(balance.getDepositing());
}

相关文章