Search in sources :

Example 41 with CurrencyMetaData

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

the class GlobitexAdapters method adaptToExchangeMetaData.

public static ExchangeMetaData adaptToExchangeMetaData(GlobitexSymbols globitexSymbols) {
    Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = new HashMap<>();
    Map<Currency, CurrencyMetaData> currencies = new HashMap<>();
    List<FeeTier> resultFeeTiers = new ArrayList<FeeTier>();
    resultFeeTiers.add(new FeeTier(BigDecimal.ONE, new Fee(BigDecimal.valueOf(0.001), BigDecimal.valueOf(0.002))));
    globitexSymbols.getSymbols().forEach(globitexSymbol -> {
        currencyPairs.put(adaptGlobitexSymbolToCurrencyPair(globitexSymbol), new CurrencyPairMetaData(BigDecimal.valueOf(0.002), globitexSymbol.getSizeMin(), null, globitexSymbol.getPriceIncrement().scale(), resultFeeTiers.toArray(new FeeTier[resultFeeTiers.size()])));
        currencies.put(new Currency(convertXBTtoBTC(globitexSymbol.getCurrency())), new CurrencyMetaData(globitexSymbol.getPriceIncrement().scale(), null));
        currencies.put(new Currency(convertXBTtoBTC(globitexSymbol.getCommodity())), new CurrencyMetaData(globitexSymbol.getSizeIncrement().scale(), null));
    });
    return new ExchangeMetaData(currencyPairs, currencies, null, null, null);
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) HashMap(java.util.HashMap) ExchangeMetaData(org.knowm.xchange.dto.meta.ExchangeMetaData) Currency(org.knowm.xchange.currency.Currency) Fee(org.knowm.xchange.dto.account.Fee) ArrayList(java.util.ArrayList) FeeTier(org.knowm.xchange.dto.meta.FeeTier) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 42 with CurrencyMetaData

use of org.knowm.xchange.dto.meta.CurrencyMetaData 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)42 Currency (org.knowm.xchange.currency.Currency)34 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)32 CurrencyPairMetaData (org.knowm.xchange.dto.meta.CurrencyPairMetaData)32 BigDecimal (java.math.BigDecimal)19 ExchangeMetaData (org.knowm.xchange.dto.meta.ExchangeMetaData)17 HashMap (java.util.HashMap)14 FeeTier (org.knowm.xchange.dto.meta.FeeTier)7 WalletHealth (org.knowm.xchange.dto.meta.WalletHealth)7 Map (java.util.Map)6 Test (org.junit.Test)6 IOException (java.io.IOException)5 Fee (org.knowm.xchange.dto.account.Fee)5 ArrayList (java.util.ArrayList)4 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 InputStream (java.io.InputStream)2 Field (java.lang.reflect.Field)2 Modifier (java.lang.reflect.Modifier)2 HttpURLConnection (java.net.HttpURLConnection)2