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;
}
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);
}
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);
}
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());
}
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);
}
Aggregations