private boolean isIn(Currency currency, Currency[] currencies) { for (Currency cur : currencies) if (cur.equals(currency)) return true; return false; } }
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; } }
@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); }
@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); }
/** * @param currency * @return */ public static String toSymbol(Currency currency) { if (Currency.IOT.equals(currency)) { return "IOTA"; } return currency.getSymbol(); }
public static String toSymbol(Currency currency) { if (Currency.IOT.equals(currency)) { return "IOTA"; } return currency.getSymbol(); }
/** * @param currency * @return */ public static String toSymbol(Currency currency) { if (Currency.IOT.equals(currency)) { return "IOTA"; } return currency.getSymbol(); }
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); } }
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(); }
/** * 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); }
@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); }
/** * 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); }
/** * 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); } }
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); }
@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; }
@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(); }
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(); }