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())); }
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 + "'"); }
/** * 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; }
/** * 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); }
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); }
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); }
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); }
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; }
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; }
@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()); } }
.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(
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); }
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(),
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());
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()); } }
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(); }
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(); }
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 + "'"); }