Search in sources :

Example 1 with PoloniexCurrencyInfo

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

Example 2 with PoloniexCurrencyInfo

use of org.knowm.xchange.poloniex.dto.marketdata.PoloniexCurrencyInfo in project XChange by knowm.

the class PoloniexExchange method remoteInit.

@Override
public void remoteInit() throws IOException {
    PoloniexMarketDataServiceRaw poloniexMarketDataServiceRaw = (PoloniexMarketDataServiceRaw) marketDataService;
    Map<String, PoloniexCurrencyInfo> poloniexCurrencyInfoMap = poloniexMarketDataServiceRaw.getPoloniexCurrencyInfo();
    Map<String, PoloniexMarketData> poloniexMarketDataMap = poloniexMarketDataServiceRaw.getAllPoloniexTickers();
    exchangeMetaData = PoloniexAdapters.adaptToExchangeMetaData(poloniexCurrencyInfoMap, poloniexMarketDataMap, exchangeMetaData);
}
Also used : PoloniexCurrencyInfo(org.knowm.xchange.poloniex.dto.marketdata.PoloniexCurrencyInfo) PoloniexMarketData(org.knowm.xchange.poloniex.dto.marketdata.PoloniexMarketData) PoloniexMarketDataServiceRaw(org.knowm.xchange.poloniex.service.PoloniexMarketDataServiceRaw)

Aggregations

PoloniexCurrencyInfo (org.knowm.xchange.poloniex.dto.marketdata.PoloniexCurrencyInfo)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Currency (org.knowm.xchange.currency.Currency)1 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)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 PoloniexMarketData (org.knowm.xchange.poloniex.dto.marketdata.PoloniexMarketData)1 PoloniexMarketDataServiceRaw (org.knowm.xchange.poloniex.service.PoloniexMarketDataServiceRaw)1