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

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

本文整理了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

  1. /**
  2. * Constructs a {@link Wallet}.
  3. *
  4. * @param id the wallet id
  5. * @param name a descriptive name for the wallet
  6. * @param balances the balances, the currencies of the balances should not be duplicated.
  7. */
  8. public Wallet(String id, String name, Collection<Balance> balances) {
  9. this.id = id;
  10. if (name == null) {
  11. this.name = id;
  12. } else {
  13. this.name = name;
  14. }
  15. if (balances.size() == 0) {
  16. this.balances = Collections.emptyMap();
  17. } else if (balances.size() == 1) {
  18. Balance balance = balances.iterator().next();
  19. this.balances = Collections.singletonMap(balance.getCurrency(), balance);
  20. } else {
  21. this.balances = new HashMap<>();
  22. for (Balance balance : balances) {
  23. if (this.balances.containsKey(balance.getCurrency()))
  24. // this class could merge balances, but probably better to catch mistakes and let the
  25. // exchange merge them
  26. throw new IllegalArgumentException("duplicate balances in wallet");
  27. this.balances.put(balance.getCurrency(), balance);
  28. }
  29. }
  30. }

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

  1. public static Wallet adaptWallet(GateioFunds bterAccountInfo) {
  2. List<Balance> balances = new ArrayList<>();
  3. for (Entry<String, BigDecimal> funds : bterAccountInfo.getAvailableFunds().entrySet()) {
  4. Currency currency = Currency.getInstance(funds.getKey().toUpperCase());
  5. BigDecimal amount = funds.getValue();
  6. BigDecimal locked = bterAccountInfo.getLockedFunds().get(currency.toString());
  7. balances.add(new Balance(currency, null, amount, locked == null ? BigDecimal.ZERO : locked));
  8. }
  9. for (Entry<String, BigDecimal> funds : bterAccountInfo.getLockedFunds().entrySet()) {
  10. Currency currency = Currency.getInstance(funds.getKey().toUpperCase());
  11. if (balances.stream().noneMatch(balance -> balance.getCurrency().equals(currency))) {
  12. BigDecimal amount = funds.getValue();
  13. balances.add(new Balance(currency, null, BigDecimal.ZERO, amount));
  14. }
  15. }
  16. return new Wallet(balances);
  17. }

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

  1. public static Builder from(Balance balance) {
  2. return new Builder()
  3. .currency(balance.getCurrency())
  4. .total(balance.getTotal())
  5. .available(balance.getAvailable())
  6. .frozen(balance.getFrozen())
  7. .borrowed(balance.getBorrowed())
  8. .loaned(balance.getLoaned())
  9. .withdrawing(balance.getWithdrawing())
  10. .depositing(balance.getDepositing());
  11. }

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

  1. /**
  2. * Constructs a {@link Wallet}.
  3. *
  4. * @param id the wallet id
  5. * @param name a descriptive name for the wallet
  6. * @param balances the balances, the currencies of the balances should not be duplicated.
  7. */
  8. public Wallet(String id, String name, Collection<Balance> balances) {
  9. this.id = id;
  10. if (name == null) {
  11. this.name = id;
  12. } else {
  13. this.name = name;
  14. }
  15. if (balances.size() == 0) {
  16. this.balances = Collections.emptyMap();
  17. } else if (balances.size() == 1) {
  18. Balance balance = balances.iterator().next();
  19. this.balances = Collections.singletonMap(balance.getCurrency(), balance);
  20. } else {
  21. this.balances = new HashMap<>();
  22. for (Balance balance : balances) {
  23. if (this.balances.containsKey(balance.getCurrency()))
  24. // this class could merge balances, but probably better to catch mistakes and let the
  25. // exchange merge them
  26. throw new IllegalArgumentException("duplicate balances in wallet");
  27. this.balances.put(balance.getCurrency(), balance);
  28. }
  29. }
  30. }

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

  1. public static Builder from(Balance balance) {
  2. return new Builder()
  3. .currency(balance.getCurrency())
  4. .total(balance.getTotal())
  5. .available(balance.getAvailable())
  6. .frozen(balance.getFrozen())
  7. .borrowed(balance.getBorrowed())
  8. .loaned(balance.getLoaned())
  9. .withdrawing(balance.getWithdrawing())
  10. .depositing(balance.getDepositing());
  11. }

相关文章