org.knowm.xchange.currency.Currency.getInstance()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(165)

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

Currency.getInstance介绍

[英]Returns a Currency instance for the given currency code.
[中]返回给定货币代码的货币实例。

代码示例

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

public static Currency fromLunoCurrency(String c) {
 String in;
 switch (c) {
  case "XBT":
   in = "BTC";
   break;
  default:
   in = c;
 }
 return Currency.getInstance(in);
}

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

@JsonCreator
public CoinbasePrice(
  @JsonProperty("amount") BigDecimal amount, @JsonProperty("currency") String currency) {
 this(amount, Currency.getInstance(currency));
}

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

public static CurrencyPair adaptMarket(String market) {
  String[] parts = market.split("_");
  return new CurrencyPair(Currency.getInstance(parts[0]), Currency.getInstance(parts[1]));
 }
}

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

public BinanceBalance(
  @JsonProperty("asset") String asset,
  @JsonProperty("free") BigDecimal free,
  @JsonProperty("locked") BigDecimal locked) {
 this.currency = Currency.getInstance(asset);
 this.locked = locked;
 this.free = free;
}

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

@JsonCreator
public LiquiAccountFunds(final Map<String, String> funds) {
 funds
   .entrySet()
   .forEach(
     entry ->
       this.funds.put(
         Currency.getInstance(entry.getKey()), new BigDecimal(entry.getValue())));
}

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

public static CurrencyPair bitMarketCurrencyPairToCurrencyPair(String currencyPair) {
 if (currencyPair.equals("LiteMineXBTC")) {
  return new CurrencyPair("LiteMineX", "BTC");
 } else if (currencyPair.length() == 6) {
  String ccyA = currencyPair.substring(0, 3);
  String ccyB = currencyPair.substring(3);
  return new CurrencyPair(Currency.getInstance(ccyA), Currency.getInstance(ccyB));
 } else {
  throw new IllegalStateException("Cannot convert '" + currencyPair + "' into a CurrencyPair");
 }
}

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

private static Map<Currency, CurrencyMetaData> adaptCurrencyMap(List<KucoinCoin> coins) {
 return coins
   .stream()
   .collect(
     Collectors.toMap(
       c -> Currency.getInstance(c.getCoin()), c -> adaptCurrencyMetadata(c)));
}

代码示例来源: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 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

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(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 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 void setBitmexAssetPairs(List<BitmexTicker> tickers) {
 for (BitmexTicker ticker : tickers) {
  String quote = ticker.getQuoteCurrency();
  String base = ticker.getRootSymbol();
  Currency baseCurrencyCode = Currency.getInstance(base);
  Currency quoteCurrencyCode = Currency.getInstance(quote);
  CurrencyPair pair = new CurrencyPair(base, quote);
  assetPairMap.put(ticker.getSymbol(), pair);
  assetsMap.put(quote, quoteCurrencyCode);
  assetsMap.put(base, baseCurrencyCode);
 }
}

代码示例来源: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 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

@Override
public String requestDepositAddress(Currency currency, String... args) throws IOException {
 BitcoinAccount[] quoineCryptoAccountInfo = getQuoineCryptoAccountInfo();
 for (BitcoinAccount bitcoinAccount : quoineCryptoAccountInfo) {
  Currency ccy = Currency.getInstance(bitcoinAccount.getCurrency());
  if (ccy.equals(currency)) return bitcoinAccount.getAddress();
 }
 return null;
}

代码示例来源: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;
}

相关文章