Search in sources :

Example 1 with Currency

use of org.knowm.xchange.currency.Currency in project XChange by knowm.

the class BitstampAdapters method adaptMetaData.

public static ExchangeMetaData adaptMetaData(List<BitstampPairInfo> rawSymbols, ExchangeMetaData metaData) {
    Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = adaptCurrencyPairs(rawSymbols);
    Map<CurrencyPair, CurrencyPairMetaData> pairsMap = metaData.getCurrencyPairs();
    Map<Currency, CurrencyMetaData> currenciesMap = metaData.getCurrencies();
    for (Map.Entry<CurrencyPair, CurrencyPairMetaData> entry : currencyPairs.entrySet()) {
        CurrencyPair c = entry.getKey();
        CurrencyPairMetaData cmeta = entry.getValue();
        if (!pairsMap.containsKey(c)) {
            pairsMap.put(c, cmeta);
        } else {
            pairsMap.replace(c, cmeta);
        }
        if (!currenciesMap.containsKey(c.base)) {
            currenciesMap.put(c.base, null);
        }
        if (!currenciesMap.containsKey(c.counter)) {
            currenciesMap.put(c.counter, null);
        }
    }
    return metaData;
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) 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 Currency

use of org.knowm.xchange.currency.Currency in project XChange by knowm.

the class CoinMarketCapMarketDataService method getCurrencies.

public List<Currency> getCurrencies() {
    List<Currency> currencies = new ArrayList<>();
    List<CoinMarketCapCurrency> cmcCurrencies = getCoinMarketCapCurrencies();
    for (CoinMarketCapCurrency cmcCurrency : cmcCurrencies) {
        currencies.add(cmcCurrency.getCurrency());
    }
    return currencies;
}
Also used : CoinMarketCapCurrency(org.knowm.xchange.coinmarketcap.deprecated.v2.dto.marketdata.CoinMarketCapCurrency) CoinMarketCapCurrency(org.knowm.xchange.coinmarketcap.deprecated.v2.dto.marketdata.CoinMarketCapCurrency) Currency(org.knowm.xchange.currency.Currency) ArrayList(java.util.ArrayList)

Example 3 with Currency

use of org.knowm.xchange.currency.Currency in project XChange by knowm.

the class CoinMarketCapExchange method getExchangeSymbols.

@Override
public List<CurrencyPair> getExchangeSymbols() {
    List<Currency> currencies = marketDataService.getCurrencies();
    List<CurrencyPair> pairs = new ArrayList<>();
    for (Currency currency : currencies) {
        pairs.add(new CurrencyPair(currency, Currency.USD));
        pairs.add(new CurrencyPair(currency, Currency.BTC));
    }
    return pairs;
}
Also used : Currency(org.knowm.xchange.currency.Currency) ArrayList(java.util.ArrayList) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 4 with Currency

use of org.knowm.xchange.currency.Currency in project XChange by knowm.

the class LgoAdapters method adaptMetadata.

public static ExchangeMetaData adaptMetadata(ExchangeMetaData metaData, LgoProducts products, LgoCurrencies currencies) {
    Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = metaData.getCurrencyPairs();
    Map<Currency, CurrencyMetaData> currency = metaData.getCurrencies();
    for (LgoCurrency lgoCurrency : currencies.getCurrencies()) {
        currency.put(Currency.getInstance(lgoCurrency.getCode()), new CurrencyMetaData(lgoCurrency.getDecimals(), null));
    }
    for (LgoProduct product : products.getProducts()) {
        BigDecimal minAmount = product.getBase().getLimits().getMin();
        BigDecimal maxAmount = product.getBase().getLimits().getMax();
        Integer baseScale = currency.get(Currency.getInstance(product.getBase().getId())).getScale();
        BigDecimal increment = product.getQuote().getIncrement().stripTrailingZeros();
        currencyPairs.put(toPair(product), new CurrencyPairMetaData(null, minAmount, maxAmount, null, null, baseScale, increment.scale(), null, new FeeTier[0], increment, Currency.USD, true));
    }
    return metaData;
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) LgoCurrency(org.knowm.xchange.lgo.dto.currency.LgoCurrency) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) LgoProduct(org.knowm.xchange.lgo.dto.product.LgoProduct) Currency(org.knowm.xchange.currency.Currency) LgoCurrency(org.knowm.xchange.lgo.dto.currency.LgoCurrency) FeeTier(org.knowm.xchange.dto.meta.FeeTier) BigDecimal(java.math.BigDecimal) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 5 with Currency

use of org.knowm.xchange.currency.Currency in project XChange by knowm.

the class LatokenExchange method remoteInit.

@Override
public void remoteInit() {
    try {
        // Load the static meta-data and override with the dynamic one
        Map<Currency, CurrencyMetaData> currenciesMetaData = exchangeMetaData.getCurrencies();
        Map<CurrencyPair, CurrencyPairMetaData> pairsMetaData = exchangeMetaData.getCurrencyPairs();
        List<LatokenPair> allPairs = latoken.getAllPairs();
        List<LatokenCurrency> allCurrencies = latoken.getAllCurrencies();
        // Save pairs map on the exchange
        this.exchangeSpecification.setExchangeSpecificParametersItem("pairs", allPairs);
        // Update Currency meta-data
        for (LatokenCurrency latokenCurrency : allCurrencies) {
            Currency currency = LatokenAdapters.adaptCurrency(latokenCurrency);
            addCurrencyMetadata(currenciesMetaData, currency, PRECISION);
        }
        // Update CurrencyPair meta-data
        for (LatokenPair latokenPair : allPairs) {
            CurrencyPair pair = LatokenAdapters.adaptCurrencyPair(latokenPair);
            CurrencyPairMetaData pairMetadata = LatokenAdapters.adaptPairMetaData(latokenPair);
            addCurrencyPairMetadata(pairsMetaData, pair, pairMetadata);
        }
    } catch (Exception e) {
        throw new ExchangeException("Failed to initialize: " + e.getMessage(), e);
    }
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) LatokenCurrency(org.knowm.xchange.latoken.dto.exchangeinfo.LatokenCurrency) Currency(org.knowm.xchange.currency.Currency) LatokenCurrency(org.knowm.xchange.latoken.dto.exchangeinfo.LatokenCurrency) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) LatokenPair(org.knowm.xchange.latoken.dto.exchangeinfo.LatokenPair) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Aggregations

Currency (org.knowm.xchange.currency.Currency)159 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)75 BigDecimal (java.math.BigDecimal)67 ArrayList (java.util.ArrayList)60 Balance (org.knowm.xchange.dto.account.Balance)38 CurrencyMetaData (org.knowm.xchange.dto.meta.CurrencyMetaData)35 CurrencyPairMetaData (org.knowm.xchange.dto.meta.CurrencyPairMetaData)32 HashMap (java.util.HashMap)28 Test (org.junit.Test)27 Map (java.util.Map)22 Date (java.util.Date)21 AccountInfo (org.knowm.xchange.dto.account.AccountInfo)19 FundingRecord (org.knowm.xchange.dto.account.FundingRecord)19 IOException (java.io.IOException)18 ExchangeMetaData (org.knowm.xchange.dto.meta.ExchangeMetaData)18 List (java.util.List)17 ExchangeException (org.knowm.xchange.exceptions.ExchangeException)15 OrderType (org.knowm.xchange.dto.Order.OrderType)14 UserTrade (org.knowm.xchange.dto.trade.UserTrade)14 Collectors (java.util.stream.Collectors)11