本文整理了Java中org.knowm.xchange.currency.Currency.equals()
方法的一些代码示例,展示了Currency.equals()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Currency.equals()
方法的具体详情如下:
包路径:org.knowm.xchange.currency.Currency
类名称:Currency
方法名:equals
暂无
代码示例来源:origin: knowm/XChange
public static int getMaxPriceScale(CurrencyPair currencyPair) {
if (currencyPair.base.equals(Currency.BTC) || currencyPair.base.equals(Currency.LTC)) {
return 5;
} else {
return 8;
}
}
代码示例来源:origin: knowm/XChange
private boolean isIn(Currency currency, Currency[] currencies) {
for (Currency cur : currencies) if (cur.equals(currency)) return true;
return false;
}
}
代码示例来源:origin: knowm/XChange
public boolean contains(Currency currency) {
return base.equals(currency) || counter.equals(currency);
}
代码示例来源:origin: knowm/XChange
public boolean contains(Currency currency) {
return pair.base.equals(currency) || pair.counter.equals(currency);
}
代码示例来源:origin: knowm/XChange
public boolean hasCurrency(Currency currency) {
if (currency.equals(Currency.BTC)) {
return !Objects.equals(btcBalance, BigDecimal.ZERO);
} else if (currency.equals(Currency.GBP)) {
return !Objects.equals(gbpBalance, BigDecimal.ZERO);
} else if (currency.equals(Currency.EUR)) {
return !Objects.equals(eurBalance, BigDecimal.ZERO);
} else if (currency.equals(Currency.USD)) {
return !Objects.equals(usdBalance, BigDecimal.ZERO);
} else if (currency.equals(Currency.BCH)) {
return !Objects.equals(bchBalance, BigDecimal.ZERO);
} else if (currency.equals(Currency.XRP)) {
return !Objects.equals(xrpBalance, BigDecimal.ZERO);
} else if (currency.equals(Currency.LTC)) {
return !Objects.equals(ltcBalance, BigDecimal.ZERO);
} else if (currency.equals(Currency.ETH)) {
return !Objects.equals(ethBalance, BigDecimal.ZERO);
} else {
return false;
}
}
代码示例来源:origin: knowm/XChange
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
CoinbasePrice other = (CoinbasePrice) obj;
return amount.compareTo(other.amount) == 0 && currency.equals(other.currency);
}
代码示例来源:origin: knowm/XChange
@Override
public String withdrawFunds(Currency currency, BigDecimal amount, String address)
throws IOException {
if (currency.equals(Currency.BTC)) return withdrawBitcoin(amount, address);
else if (currency.equals(Currency.ETH)) return withdrawEther(amount, address);
else if (currency.equals(Currency.BCH)) return withdrawBitcoinCach(amount, address);
else if (currency.equals(Currency.BTG)) return withdrawBitcoinGold(amount, address);
else if (currency.equals(Currency.LTC)) return withdrawLitecoin(amount, address);
else throw new IllegalStateException("unsupported ccy " + currency);
}
代码示例来源:origin: knowm/XChange
/**
* @param currency
* @return
*/
public static String toSymbol(Currency currency) {
if (Currency.IOT.equals(currency)) {
return "IOTA";
}
return currency.getSymbol();
}
代码示例来源:origin: knowm/XChange
public static String toSymbol(Currency currency) {
if (Currency.IOT.equals(currency)) {
return "IOTA";
}
return currency.getSymbol();
}
代码示例来源:origin: knowm/XChange
/**
* @param currency
* @return
*/
public static String toSymbol(Currency currency) {
if (Currency.IOT.equals(currency)) {
return "IOTA";
}
return currency.getSymbol();
}
代码示例来源:origin: knowm/XChange
public BitstampDepositAddress requestDepositAddressObject(Currency currency, String... arguments)
throws IOException {
if (currency.equals(Currency.BTC)) {
return getBitstampBitcoinDepositAddress();
} else if (currency.equals(Currency.LTC)) {
return getBitstampLitecoinDepositAddress();
} else if (currency.equals(Currency.XRP)) {
return getRippleDepositAddress();
} else if (currency.equals(Currency.BCH)) {
return getBitstampBitcoinCashDepositAddress();
} else if (currency.equals(Currency.ETH)) {
return getBitstampEthereumDepositAddress();
} else {
throw new IllegalStateException("Unsupported currency " + currency);
}
}
代码示例来源:origin: knowm/XChange
private static BigDecimal getBaseCurrencyAmountFromBitstampTransaction(
BitstampOrderTransaction bitstampTransaction) {
CurrencyPair currencyPair = adaptCurrencyPair(bitstampTransaction);
if (currencyPair.base.equals(Currency.LTC)) return bitstampTransaction.getLtc();
if (currencyPair.base.equals(Currency.BTC)) return bitstampTransaction.getBtc();
if (currencyPair.base.equals(Currency.BCH)) return bitstampTransaction.getBch();
if (currencyPair.base.equals(Currency.ETH)) return bitstampTransaction.getEth();
if (currencyPair.base.equals(Currency.XRP)) return bitstampTransaction.getXrp();
throw new NotYetImplementedForExchangeException();
}
代码示例来源: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
@Override
public String requestDepositAddress(Currency currency, String... args) throws IOException {
KrakenDepositAddress[] depositAddresses;
if (Currency.BTC.equals(currency)) {
depositAddresses = getDepositAddresses(currency.toString(), "Bitcoin", false);
} else if (Currency.LTC.equals(currency)) {
depositAddresses = getDepositAddresses(currency.toString(), "Litecoin", false);
} else {
throw new RuntimeException("Not implemented yet, Kraken works only for BTC and LTC");
}
return KrakenAdapters.adaptKrakenDepositAddress(depositAddresses);
}
代码示例来源:origin: knowm/XChange
/**
* This returns the currently set deposit address. It will not generate a new address (ie.
* repeated calls will return the same address).
*/
@Override
public String requestDepositAddress(Currency currency, String... arguments) throws IOException {
if (currency.equals(Currency.BTC))
return getQuadrigaCxBitcoinDepositAddress().getDepositAddress();
else if (currency.equals(Currency.ETH))
return getQuadrigaCxEtherDepositAddress().getDepositAddress();
else if (currency.equals(Currency.BCH))
return getQuadrigaCxBitcoinCachDepositAddress().getDepositAddress();
else if (currency.equals(Currency.BTG))
return getQuadrigaCxBitcoinGoldDepositAddress().getDepositAddress();
else if (currency.equals(Currency.LTC))
return getQuadrigaCxLitecoinDepositAddress().getDepositAddress();
else throw new IllegalStateException("unsupported ccy " + currency);
}
代码示例来源:origin: knowm/XChange
/**
* This returns the currently set deposit address. It will not generate a new address (ie.
* repeated calls will return the same address).
*/
@Override
public String requestDepositAddress(Currency currency, String... arguments) throws IOException {
if (currency.equals(Currency.BTC)) {
return getBitstampBitcoinDepositAddress().getDepositAddress();
} else if (currency.equals(Currency.LTC)) {
return getBitstampLitecoinDepositAddress().getDepositAddress();
} else if (currency.equals(Currency.XRP)) {
return getRippleDepositAddress().getAddressAndDt();
} else if (currency.equals(Currency.BCH)) {
return getBitstampBitcoinCashDepositAddress().getDepositAddress();
} else if (currency.equals(Currency.ETH)) {
return getBitstampEthereumDepositAddress().getDepositAddress();
} else {
throw new IllegalStateException("Unsupported currency " + currency);
}
}
代码示例来源: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
@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
@Override
public String requestDepositAddress(Currency currency, String... args) throws IOException {
CoinbaseProAccount[] coinbaseAccounts = getCoinbaseAccounts();
CoinbaseProAccount depositAccount = null;
for (CoinbaseProAccount account : coinbaseAccounts) {
Currency accountCurrency = Currency.getInstance(account.getCurrency());
if (account.isActive()
&& account.getType().equals("wallet")
&& accountCurrency.equals(currency)) {
depositAccount = account;
break;
}
}
CoinbaseProAccountAddress depositAddress = getCoinbaseAccountAddress(depositAccount.getId());
return depositAddress.getAddress();
}
代码示例来源:origin: knowm/XChange
public static UserTrade adoptUserTrade(BitmexPrivateExecution exec) {
CurrencyPair pair = BitmexUtils.translateBitmexCurrencyPair(exec.symbol);
// the "lastQty" parameter is in the USD currency for ???/USD pairs
OrderType orderType = convertType(exec.side);
return orderType == null
? null
: new UserTrade.Builder()
.id(exec.execID)
.orderId(exec.orderID)
.currencyPair(pair)
.originalAmount(exec.lastQty)
.price(exec.lastPx)
.feeAmount(exec.commission.multiply(exec.lastQty))
.feeCurrency(pair.counter.equals(Currency.USD) ? pair.counter : pair.base)
.timestamp(exec.timestamp)
.type(orderType)
.build();
}
内容来源于网络,如有侵权,请联系作者删除!