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

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

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

Currency.<init>介绍

[英]Public constructor. Links to an existing currency.
[中]公共构造函数。指向现有货币的链接。

代码示例

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

public BitfinexAccountFeesResponse(
  @JsonProperty("withdraw") final Map<String, BigDecimal> withdraw) {
 this.withdraw =
   withdraw
     .entrySet()
     .stream() // Sting needs to be adapted (i.e., DSH -> DASH)
     .collect(
       Collectors.toMap(
         entry -> new Currency(BitfinexAdapters.adaptBitfinexCurrency(entry.getKey())),
         entry -> entry.getValue()));
}

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

public static CurrencyPair convert(String symbol) {
 // Iterate by base currency priority at binance.
 for (Currency base : Arrays.asList(Currency.BTC, Currency.ETH, Currency.BNB, Currency.USDT)) {
  if (symbol.contains(base.toString())) {
   String counter = symbol.replace(base.toString(), "");
   return new CurrencyPair(base, new Currency(counter));
  }
 }
 throw new IllegalArgumentException("Could not parse currency pair from '" + symbol + "'");
}

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

/**
 * Factory
 *
 * @param commonCode commonly used code for this currency: "BTC"
 * @param name Name of the currency: "Bitcoin"
 * @param unicode Unicode symbol for the currency: "\u20BF" or "฿"
 * @param alternativeCodes Alternative codes for the currency: "XBT"
 */
private static Currency createCurrency(
  String commonCode, String name, String unicode, String... alternativeCodes) {
 CurrencyAttributes attributes =
   new CurrencyAttributes(commonCode, name, unicode, alternativeCodes);
 Currency currency = new Currency(commonCode, attributes);
 for (String code : attributes.codes) {
  if (commonCode.equals(code)) {
   // common code will always be part of the currencies map
   currencies.put(code, currency);
  } else if (!currencies.containsKey(code)) {
   // alternative codes will never overwrite common codes
   currencies.put(code, new Currency(code, attributes));
  }
 }
 return currency;
}

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

/**
 * Gets the equivalent object with the passed code.
 *
 * <p>This is useful in case some currencies share codes, such that {@link #getInstance(String)}
 * may return the wrong currency.
 *
 * @param code The code the returned object will evaluate to
 * @return A Currency representing the same currency but having the passed currency code
 * @throws IllegalArgumentException if the passed code is not listed for this currency
 */
public Currency getCodeCurrency(String code) {
 if (code.equals(this.code)) return this;
 Currency currency = getInstance(code);
 if (currency.equals(this)) return currency;
 if (!attributes.codes.contains(code))
  throw new IllegalArgumentException("Code not listed for this currency");
 return new Currency(code, attributes);
}

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

public static Wallet adaptBalances(
  Map<String, Bl3pAccountInfo.Bl3pAccountInfoWallet> bl3pBalances) {
 List<Balance> balances = new ArrayList<>(bl3pBalances.size());
 for (Bl3pAccountInfo.Bl3pAccountInfoWallet bl3pWallet : bl3pBalances.values()) {
  balances.add(
    new Balance(
      new Currency(bl3pWallet.getAvailable().currency),
      bl3pWallet.getBalance().value,
      bl3pWallet.getAvailable().value));
 }
 return new Wallet(balances);
}

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

public static AccountInfo adaptAccountInfo(CobinhoodCoinBalances balances) {
 Wallet wallet =
   new Wallet(
     null,
     balances
       .getBalances()
       .stream()
       .map(
         balance ->
           new Balance(new Currency(balance.getCurrency()), balance.getTotalAmount()))
       .collect(Collectors.toList()));
 return new AccountInfo(wallet);
}

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

public static AccountInfo adaptAccountInfo(CoinbeneCoinBalances balances) {
 Wallet wallet =
   new Wallet(
     null,
     balances
       .getBalances()
       .stream()
       .map(
         balance ->
           new Balance(
             new Currency(balance.getAsset()),
             balance.getTotal(),
             balance.getAvailable(),
             balance.getReserved()))
       .collect(Collectors.toList()));
 return new AccountInfo(wallet);
}

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

public AccountInfo getAccountInfo() {
 AccountInfo ret = null;
 try {
  String s = apiKey.substring(0, 6) + "…";
  ReturnCompleteBalancesResponse returnBalancesPost;
  ret = null;
  returnBalancesPost =
    returnCompleteBalancesApi.completeBalances(new CompleteBalancesReq().address(apiKey));
  ret =
    new AccountInfo(
      new Wallet(
        s,
        returnBalancesPost
          .entrySet()
          .stream()
          .map(
            entry ->
              new Balance(
                new Currency(entry.getKey()),
                null,
                entry.getValue().getAvailable(),
                entry.getValue().getOnOrders()))
          .collect(Collectors.toList())));
 } catch (Exception ignored) {
  ignored.printStackTrace();
 }
 return ret;
}

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

public static List<UserTrade> adaptUserTrades(BankeraUserTrades userTrades) {
 List<UserTrade> tradeList = new ArrayList<>();
 userTrades
   .getTrades()
   .forEach(
     trade -> {
      String[] currencies = trade.getMarket().split("-");
      CurrencyPair pair = new CurrencyPair(currencies[0], currencies[1]);
      Currency feeCurrency = new Currency(currencies[1]);
      tradeList.add(
        new UserTrade(
          trade.getSide().equalsIgnoreCase("buy") ? OrderType.BID : OrderType.ASK,
          new BigDecimal(trade.getAmount()),
          pair,
          new BigDecimal(trade.getPrice()),
          new Date(Long.valueOf(trade.getCompletedAt())),
          String.valueOf(trade.getId()),
          String.valueOf(trade.getOrderId()),
          new BigDecimal(trade.getFeeAmount()),
          feeCurrency));
     });
 return tradeList;
}

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

@Override
 public List<FundingRecord> getFundingHistory(TradeHistoryParams params) {

  Currency currency = null;

  if (params instanceof TradeHistoryParamCurrency) {
   currency = ((TradeHistoryParamCurrency) params).getCurrency();

   if (currency.getCurrencyCode().equals("BTC") || currency.getCurrencyCode().equals("XBT")) {
    currency = new Currency("XBt");
   }
  } else {
   throw new ExchangeException("Currency must be supplied");
  }

  return getBitmexWalletHistory(currency)
    .stream()
    .filter(
      w ->
        w.getTransactStatus().equals("Completed")
          && (w.getTransactType().equals("Deposit")
            || w.getTransactType().equals("Withdrawal")))
    .map(w -> BitmexAdapters.adaptFundingRecord(w))
    .collect(Collectors.toList());
 }
}

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

.collect(
  Collectors.toMap(
    hitbtcCurrency -> new Currency(hitbtcCurrency.getId()),
    hitbtcCurrency -> new CurrencyMetaData(null, hitbtcCurrency.getPayoutFee())));
    hitbtcSymbol ->
      new CurrencyPair(
        new Currency(hitbtcSymbol.getBaseCurrency()),
        new Currency(hitbtcSymbol.getQuoteCurrency())),
    hitbtcSymbol ->
      new CurrencyPairMetaData(

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

public static Wallet adaptWallet(List<BankeraWallet> wallets) {
 List<Balance> balances =
   wallets
     .stream()
     .map(
       w ->
         new Balance.Builder()
           .total(new BigDecimal(w.getTotal()))
           .available(new BigDecimal(w.getBalance()))
           .frozen(new BigDecimal(w.getReserved()))
           .currency(new Currency(w.getCurrency()))
           .build())
     .collect(Collectors.toList());
 return new Wallet(balances);
}

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

String[] markets = upbitOrderResponse.getMarket().split("-");
CurrencyPair currencyPair =
  new CurrencyPair(new Currency(markets[1]), new Currency(markets[0]));
String orderId = upbitOrderResponse.getUuid();
BigDecimal cumulativeAmount = upbitOrderResponse.getExecutedVolume();

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

exchange.getExchangeSpecification().getApiKey(),
new Date(Long.parseLong(fundingLedger.getTimestamp()) * 1000),
new Currency(fundingLedger.getCurrency()),
safeParse(fundingLedger.getAmount()),
fundingLedger.getTransactionHash(),
exchange.getExchangeSpecification().getApiKey(),
new Date(Long.parseLong(fundingLedger1.getTimestamp()) * 1000),
new Currency(fundingLedger1.getCurrency()),
safeParse(fundingLedger1.getAmount()),
fundingLedger1.getTransactionHash(),

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

BigDecimal originalAmount = orderInfo.getQty();
CurrencyPair currencyPair =
  new CurrencyPair(new Currency(orderInfo.getCurrency().toUpperCase()), Currency.KRW);
String orderId = orderInfo.getOrderId();
BigDecimal cumulativeAmount = orderInfo.getQty().subtract(orderInfo.getRemainQty());

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

public static FundingRecord adaptTransaction(IndependentReserveTransaction transaction) {
  BigDecimal amount = null;
  if (transaction.getDebit() != null) {
   amount = transaction.getDebit();
  } else if (transaction.getCredit() != null) {
   amount = transaction.getCredit();
  }
  return new FundingRecord(
    null,
    transaction.getCreatedTimestamp(),
    new Currency(transaction.getCurrencyCode()),
    amount,
    null,
    transaction.getBitcoinTransactionId(),
    adaptTransactionTypeToFundingRecordType(transaction.getType()),
    adaptTransactionStatusToFundingRecordStatus(transaction.getStatus()),
    transaction.getBalance(),
    null,
    transaction.getComment());
 }
}

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

public static FundingRecord adaptFundingRecord(
  BitflyerDepositOrWithdrawal history, FundingRecord.Type type) {
 return new FundingRecord.Builder()
   .setDate(BitflyerUtils.parseDate(history.getEventDate()))
   .setCurrency(new Currency(history.getCurrencyCode()))
   .setAmount(history.getAmount())
   .setInternalId(history.getID())
   .setType(type)
   .setStatus(adaptStatus(history.getStatus()))
   .setBalance(history.getAmount())
   .build();
}

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

public static FundingRecord adaptFundingRecord(
  BitflyerCoinHistory history, FundingRecord.Type type) {
 return new FundingRecord.Builder()
   .setDate(BitflyerUtils.parseDate(history.getEventDate()))
   .setCurrency(new Currency(history.getCurrencyCode()))
   .setAmount(history.getAmount())
   .setAddress(history.getAddress())
   .setInternalId(history.getID())
   .setType(type)
   .setStatus(adaptStatus(history.getStatus()))
   .setBalance(history.getAmount())
   .setFee(add(history.getFee(), history.getAdditionalFee()))
   .build();
}

代码示例来源:origin: bitrich-info/xchange-stream

public CurrencyPair getCurrencyPair() {
  String base = symbol.substring(0, 3);
  String counter = symbol.substring(3, 6);
  return new CurrencyPair(new Currency(base), new Currency(counter));
}

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

public static CurrencyPair convert(String symbol) {
 // Iterate by base currency priority at binance.
 for (Currency base : Arrays.asList(Currency.BTC, Currency.ETH, Currency.BNB, Currency.USDT)) {
  if (symbol.contains(base.toString())) {
   String counter = symbol.replace(base.toString(), "");
   return new CurrencyPair(base, new Currency(counter));
  }
 }
 throw new IllegalArgumentException("Could not parse currency pair from '" + symbol + "'");
}

相关文章