Search in sources :

Example 1 with BittrexCurrency

use of org.knowm.xchange.bittrex.dto.marketdata.BittrexCurrency 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)

Aggregations

BigDecimal (java.math.BigDecimal)1 BittrexCurrency (org.knowm.xchange.bittrex.dto.marketdata.BittrexCurrency)1 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)1 Fee (org.knowm.xchange.dto.account.Fee)1 CurrencyMetaData (org.knowm.xchange.dto.meta.CurrencyMetaData)1 CurrencyPairMetaData (org.knowm.xchange.dto.meta.CurrencyPairMetaData)1 WalletHealth (org.knowm.xchange.dto.meta.WalletHealth)1