Search in sources :

Example 1 with WalletHealth

use of org.knowm.xchange.dto.meta.WalletHealth in project XChange by knowm.

the class BinanceAdapters method adaptCurrencyMetaData.

static CurrencyMetaData adaptCurrencyMetaData(Map<Currency, CurrencyMetaData> currencies, Currency currency, Map<String, AssetDetail> assetDetailMap, int precision) {
    if (assetDetailMap != null) {
        AssetDetail asset = assetDetailMap.get(currency.getCurrencyCode());
        if (asset != null) {
            BigDecimal withdrawalFee = asset.getWithdrawFee().stripTrailingZeros();
            BigDecimal minWithdrawalAmount = new BigDecimal(asset.getMinWithdrawAmount()).stripTrailingZeros();
            WalletHealth walletHealth = getWalletHealth(asset.isDepositStatus(), asset.isWithdrawStatus());
            return new CurrencyMetaData(precision, withdrawalFee, minWithdrawalAmount, walletHealth);
        }
    }
    BigDecimal withdrawalFee = null;
    BigDecimal minWithdrawalAmount = null;
    if (currencies.containsKey(currency)) {
        CurrencyMetaData currencyMetaData = currencies.get(currency);
        withdrawalFee = currencyMetaData.getWithdrawalFee();
        minWithdrawalAmount = currencyMetaData.getMinWithdrawalAmount();
    }
    return new CurrencyMetaData(precision, withdrawalFee, minWithdrawalAmount);
}
Also used : WalletHealth(org.knowm.xchange.dto.meta.WalletHealth) AssetDetail(org.knowm.xchange.binance.dto.account.AssetDetail) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) BigDecimal(java.math.BigDecimal)

Example 2 with WalletHealth

use of org.knowm.xchange.dto.meta.WalletHealth in project XChange by knowm.

the class BitfinexAdapters method adaptMetaData.

public static ExchangeMetaData adaptMetaData(BitfinexAccountFeesResponse accountFeesResponse, int platformStatus, boolean platformStatusPresent, ExchangeMetaData metaData) {
    final WalletHealth health;
    if (platformStatusPresent) {
        if (platformStatus == PLATFORM_STATUS_ONLINE) {
            health = WalletHealth.ONLINE;
        } else if (platformStatus == PLATFORM_STATUS_OFFLINE) {
            health = WalletHealth.OFFLINE;
        } else {
            health = WalletHealth.UNKNOWN;
        }
    } else {
        health = WalletHealth.UNKNOWN;
    }
    Map<Currency, CurrencyMetaData> currencies = metaData.getCurrencies();
    final Map<Currency, BigDecimal> withdrawFees = accountFeesResponse.getWithdraw();
    withdrawFees.forEach((currency, withdrawalFee) -> {
        CurrencyMetaData newMetaData = new CurrencyMetaData(// Currency should have at least the scale of the withdrawalFee
        currencies.get(currency) == null ? withdrawalFee.scale() : Math.max(withdrawalFee.scale(), currencies.get(currency).getScale()), withdrawalFee, null, health);
        currencies.put(currency, newMetaData);
    });
    return metaData;
}
Also used : WalletHealth(org.knowm.xchange.dto.meta.WalletHealth) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) Currency(org.knowm.xchange.currency.Currency) BitfinexTickerFundingCurrency(org.knowm.xchange.bitfinex.v2.dto.marketdata.BitfinexTickerFundingCurrency) BigDecimal(java.math.BigDecimal)

Example 3 with WalletHealth

use of org.knowm.xchange.dto.meta.WalletHealth in project XChange by knowm.

the class BittrexAdapters method adaptMetaData.

public static void adaptMetaData(List<BittrexSymbol> rawSymbols, List<BittrexCurrency> bittrexCurrencies, Map<CurrencyPair, Fee> dynamicTradingFees, ExchangeMetaData metaData) {
    List<CurrencyPair> currencyPairs = BittrexAdapters.adaptCurrencyPairs(rawSymbols);
    for (CurrencyPair currencyPair : currencyPairs) {
        CurrencyPairMetaData defaultCurrencyPairMetaData = metaData.getCurrencyPairs().get(currencyPair);
        BigDecimal resultingFee = null;
        // Prioritize dynamic fee
        if (dynamicTradingFees != null) {
            Fee fee = dynamicTradingFees.get(currencyPair);
            if (fee != null) {
                resultingFee = fee.getMakerFee();
            }
        } else {
            if (defaultCurrencyPairMetaData != null) {
                resultingFee = defaultCurrencyPairMetaData.getTradingFee();
            }
        }
        CurrencyPairMetaData newCurrencyPairMetaData;
        if (defaultCurrencyPairMetaData != null) {
            newCurrencyPairMetaData = new CurrencyPairMetaData(resultingFee, defaultCurrencyPairMetaData.getMinimumAmount(), defaultCurrencyPairMetaData.getMaximumAmount(), defaultCurrencyPairMetaData.getPriceScale(), defaultCurrencyPairMetaData.getVolumeScale(), defaultCurrencyPairMetaData.getFeeTiers(), defaultCurrencyPairMetaData.getTradingFeeCurrency());
        } else {
            newCurrencyPairMetaData = new CurrencyPairMetaData(resultingFee, null, null, null, null, null, null);
        }
        metaData.getCurrencyPairs().put(currencyPair, newCurrencyPairMetaData);
    }
    for (BittrexCurrency bittrexCurrency : bittrexCurrencies) {
        WalletHealth walletHealth = WalletHealth.UNKNOWN;
        if (ONLINE.equals(bittrexCurrency.getStatus())) {
            walletHealth = WalletHealth.ONLINE;
        } else if (OFFLINE.equals(bittrexCurrency.getStatus())) {
            walletHealth = WalletHealth.OFFLINE;
        }
        metaData.getCurrencies().put(bittrexCurrency.getSymbol(), new CurrencyMetaData(1, BigDecimal.valueOf(bittrexCurrency.getTxFee()), null, walletHealth));
    }
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) WalletHealth(org.knowm.xchange.dto.meta.WalletHealth) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) Fee(org.knowm.xchange.dto.account.Fee) BittrexCurrency(org.knowm.xchange.bittrex.dto.marketdata.BittrexCurrency) BigDecimal(java.math.BigDecimal) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 4 with WalletHealth

use of org.knowm.xchange.dto.meta.WalletHealth in project XChange by knowm.

the class HuobiAdapters method getCurrencyMetaData.

private static CurrencyMetaData getCurrencyMetaData(HuobiCurrency huobiCurrency, boolean isDelisted) {
    int withdrawPrecision = huobiCurrency.getWithdrawPrecision();
    BigDecimal transactFeeWithdraw = new BigDecimal(huobiCurrency.getTransactFeeWithdraw());
    BigDecimal minWithdrawAmt = new BigDecimal(huobiCurrency.getMinWithdrawAmt());
    WalletHealth walletHealthStatus = isDelisted ? WalletHealth.OFFLINE : getWalletHealthStatus(huobiCurrency);
    return new CurrencyMetaData(withdrawPrecision, transactFeeWithdraw, minWithdrawAmt, walletHealthStatus);
}
Also used : WalletHealth(org.knowm.xchange.dto.meta.WalletHealth) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) BigDecimal(java.math.BigDecimal)

Example 5 with WalletHealth

use of org.knowm.xchange.dto.meta.WalletHealth in project XChange by knowm.

the class KucoinAdapters method adaptCurrencyMetaData.

static HashMap<String, CurrencyMetaData> adaptCurrencyMetaData(List<CurrenciesResponse> list) {
    HashMap<String, CurrencyMetaData> stringCurrencyMetaDataMap = new HashMap<>();
    for (CurrenciesResponse currenciesResponse : list) {
        BigDecimal precision = currenciesResponse.getPrecision();
        BigDecimal withdrawalMinFee = null;
        BigDecimal withdrawalMinSize = null;
        if (currenciesResponse.getWithdrawalMinFee() != null) {
            withdrawalMinFee = new BigDecimal(currenciesResponse.getWithdrawalMinFee());
        }
        if (currenciesResponse.getWithdrawalMinSize() != null) {
            withdrawalMinSize = new BigDecimal(currenciesResponse.getWithdrawalMinSize());
        }
        WalletHealth walletHealth = getWalletHealth(currenciesResponse);
        CurrencyMetaData currencyMetaData = new CurrencyMetaData(precision.intValue(), withdrawalMinFee, withdrawalMinSize, walletHealth);
        stringCurrencyMetaDataMap.put(currenciesResponse.getCurrency(), currencyMetaData);
    }
    return stringCurrencyMetaDataMap;
}
Also used : CurrenciesResponse(org.knowm.xchange.kucoin.dto.response.CurrenciesResponse) WalletHealth(org.knowm.xchange.dto.meta.WalletHealth) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) HashMap(java.util.HashMap) BigDecimal(java.math.BigDecimal)

Aggregations

CurrencyMetaData (org.knowm.xchange.dto.meta.CurrencyMetaData)6 WalletHealth (org.knowm.xchange.dto.meta.WalletHealth)6 BigDecimal (java.math.BigDecimal)5 HashMap (java.util.HashMap)2 Currency (org.knowm.xchange.currency.Currency)2 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)2 CurrencyPairMetaData (org.knowm.xchange.dto.meta.CurrencyPairMetaData)2 Map (java.util.Map)1 AssetDetail (org.knowm.xchange.binance.dto.account.AssetDetail)1 BitfinexTickerFundingCurrency (org.knowm.xchange.bitfinex.v2.dto.marketdata.BitfinexTickerFundingCurrency)1 BittrexCurrency (org.knowm.xchange.bittrex.dto.marketdata.BittrexCurrency)1 Fee (org.knowm.xchange.dto.account.Fee)1 CurrenciesResponse (org.knowm.xchange.kucoin.dto.response.CurrenciesResponse)1 PoloniexCurrencyInfo (org.knowm.xchange.poloniex.dto.marketdata.PoloniexCurrencyInfo)1