Search in sources :

Example 16 with CurrencyMetaData

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

the class GeminiAdapters method adaptMetaData.

public static ExchangeMetaData adaptMetaData(List<CurrencyPair> currencyPairs, ExchangeMetaData metaData) {
    Map<CurrencyPair, CurrencyPairMetaData> pairsMap = metaData.getCurrencyPairs();
    Map<Currency, CurrencyMetaData> currenciesMap = metaData.getCurrencies();
    for (CurrencyPair c : currencyPairs) {
        if (!pairsMap.containsKey(c)) {
            pairsMap.put(c, null);
        }
        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) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 17 with CurrencyMetaData

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

the class LivecoinAdapters method adaptToExchangeMetaData.

public static ExchangeMetaData adaptToExchangeMetaData(ExchangeMetaData exchangeMetaData, List<LivecoinRestriction> products) {
    Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = exchangeMetaData.getCurrencyPairs();
    Map<Currency, CurrencyMetaData> currencies = exchangeMetaData.getCurrencies();
    for (LivecoinRestriction product : products) {
        CurrencyPair pair = adaptCurrencyPair(product);
        CurrencyPairMetaData staticMetaData = exchangeMetaData.getCurrencyPairs().get(pair);
        CurrencyPairMetaData.Builder builder;
        if (staticMetaData == null) {
            builder = new CurrencyPairMetaData.Builder();
        } else {
            builder = CurrencyPairMetaData.Builder.from(staticMetaData);
        }
        if (product.getPriceScale() != null) {
            builder.priceScale(product.getPriceScale());
        } else if (staticMetaData != null && staticMetaData.getPriceScale() == null) {
            builder.priceScale(FALLBACK_PRICE_SCALE);
        }
        if (!(staticMetaData != null && staticMetaData.getBaseScale() != null)) {
            builder.baseScale(LIVECOIN_BASE_SCALE);
        }
        if (product.getMinLimitQuantity() != null) {
            builder.minimumAmount(product.getMinLimitQuantity());
        }
        currencyPairs.put(pair, builder.build());
        if (!currencies.containsKey(pair.base))
            currencies.put(pair.base, null);
        if (!currencies.containsKey(pair.counter))
            currencies.put(pair.counter, null);
    }
    return new ExchangeMetaData(currencyPairs, currencies, null, null, true);
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) ExchangeMetaData(org.knowm.xchange.dto.meta.ExchangeMetaData) Currency(org.knowm.xchange.currency.Currency) LivecoinRestriction(org.knowm.xchange.livecoin.dto.marketdata.LivecoinRestriction) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 18 with CurrencyMetaData

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

the class LgoAdaptersTest method adaptsMetadata.

@Test
public void adaptsMetadata() {
    ExchangeMetaData metaData = LgoAdapters.adaptMetadata(emptyMeta(), products(), currencies());
    assertThat(metaData).isNotNull();
    assertThat(metaData.getCurrencies()).hasSize(2).containsKeys(Currency.BTC, Currency.USD);
    assertThat(metaData.getCurrencies().get(Currency.BTC)).isEqualToComparingFieldByField(new CurrencyMetaData(8, null));
    assertThat(metaData.getCurrencies().get(Currency.USD)).isEqualToComparingFieldByField(new CurrencyMetaData(4, null));
    assertThat(metaData.getCurrencyPairs()).hasSize(1).containsKeys(CurrencyPair.BTC_USD);
}
Also used : CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) ExchangeMetaData(org.knowm.xchange.dto.meta.ExchangeMetaData) LgoProductsTest(org.knowm.xchange.lgo.dto.product.LgoProductsTest) Test(org.junit.Test)

Example 19 with CurrencyMetaData

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

the class KrakenAdapters method adaptToExchangeMetaData.

public static ExchangeMetaData adaptToExchangeMetaData(ExchangeMetaData originalMetaData, Map<String, KrakenAssetPair> krakenPairs, Map<String, KrakenAsset> krakenAssets) {
    Map<CurrencyPair, CurrencyPairMetaData> pairs = new HashMap<>();
    // add assets before pairs to Utils!
    KrakenUtils.setKrakenAssets(krakenAssets);
    KrakenUtils.setKrakenAssetPairs(krakenPairs);
    for (String krakenPairCode : krakenPairs.keySet()) {
        // skip dark markets!
        if (!krakenPairCode.endsWith(".d")) {
            KrakenAssetPair krakenPair = krakenPairs.get(krakenPairCode);
            pairs.put(adaptCurrencyPair(krakenPairCode), adaptPair(krakenPair, pairs.get(adaptCurrencyPair(krakenPairCode))));
        }
    }
    Map<Currency, CurrencyMetaData> currencies = new HashMap<>();
    for (String krakenAssetCode : krakenAssets.keySet()) {
        KrakenAsset krakenAsset = krakenAssets.get(krakenAssetCode);
        Currency currencyCode = KrakenAdapters.adaptCurrency(krakenAssetCode);
        currencies.put(currencyCode, new CurrencyMetaData(krakenAsset.getScale(), null));
    }
    return new ExchangeMetaData(pairs, currencies, originalMetaData == null ? null : originalMetaData.getPublicRateLimits(), originalMetaData == null ? null : originalMetaData.getPrivateRateLimits(), originalMetaData == null ? null : originalMetaData.isShareRateLimits());
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) KrakenAssetPair(org.knowm.xchange.kraken.dto.marketdata.KrakenAssetPair) KrakenAsset(org.knowm.xchange.kraken.dto.marketdata.KrakenAsset) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) HashMap(java.util.HashMap) ExchangeMetaData(org.knowm.xchange.dto.meta.ExchangeMetaData) Currency(org.knowm.xchange.currency.Currency) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 20 with CurrencyMetaData

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

the class BitflyerAdapters method adaptMetaData.

public static ExchangeMetaData adaptMetaData(List<BitflyerMarket> markets) {
    Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = new HashMap<>();
    Map<Currency, CurrencyMetaData> currencies = new HashMap<>();
    for (BitflyerMarket market : markets) {
        CurrencyPair pair = adaptCurrencyPair(market.getProductCode());
        currencyPairs.put(pair, null);
    }
    return new ExchangeMetaData(currencyPairs, currencies, null, null, false);
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) BitflyerMarket(org.knowm.xchange.bitflyer.dto.account.BitflyerMarket) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) HashMap(java.util.HashMap) ExchangeMetaData(org.knowm.xchange.dto.meta.ExchangeMetaData) Currency(org.knowm.xchange.currency.Currency) 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