Search in sources :

Example 6 with WalletHealth

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

the class PoloniexAdapters method adaptToExchangeMetaData.

public static ExchangeMetaData adaptToExchangeMetaData(Map<String, PoloniexCurrencyInfo> poloniexCurrencyInfo, Map<String, PoloniexMarketData> poloniexMarketData, ExchangeMetaData exchangeMetaData) {
    Map<Currency, CurrencyMetaData> currencyMetaDataMap = exchangeMetaData.getCurrencies();
    CurrencyMetaData currencyArchetype = currencyMetaDataMap.values().iterator().next();
    for (Map.Entry<String, PoloniexCurrencyInfo> entry : poloniexCurrencyInfo.entrySet()) {
        Currency ccy = Currency.getInstance(entry.getKey());
        if (!currencyMetaDataMap.containsKey(ccy)) {
            currencyMetaDataMap.put(ccy, currencyArchetype);
        }
        CurrencyMetaData currencyMetaData = currencyMetaDataMap.get(ccy);
        WalletHealth walletHealth = WalletHealth.ONLINE;
        if (entry.getValue().isDelisted() || entry.getValue().isDisabled()) {
            walletHealth = WalletHealth.OFFLINE;
        }
        CurrencyMetaData currencyMetaDataUpdated = new CurrencyMetaData(currencyMetaData.getScale(), entry.getValue().getTxFee(), currencyMetaData.getMinWithdrawalAmount(), walletHealth);
        currencyMetaDataMap.put(ccy, currencyMetaDataUpdated);
    }
    Map<CurrencyPair, CurrencyPairMetaData> marketMetaDataMap = exchangeMetaData.getCurrencyPairs();
    CurrencyPairMetaData marketArchetype = marketMetaDataMap.values().iterator().next();
    for (String market : poloniexMarketData.keySet()) {
        CurrencyPair currencyPair = PoloniexUtils.toCurrencyPair(market);
        if (!marketMetaDataMap.containsKey(currencyPair))
            marketMetaDataMap.put(currencyPair, marketArchetype);
    }
    return exchangeMetaData;
}
Also used : PoloniexCurrencyInfo(org.knowm.xchange.poloniex.dto.marketdata.PoloniexCurrencyInfo) CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) WalletHealth(org.knowm.xchange.dto.meta.WalletHealth) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) Currency(org.knowm.xchange.currency.Currency) HashMap(java.util.HashMap) Map(java.util.Map) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

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