use of org.knowm.xchange.dto.meta.CurrencyPairMetaData 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;
}
use of org.knowm.xchange.dto.meta.CurrencyPairMetaData in project XChange by knowm.
the class LatokenAdapters method adaptPairMetaData.
public static CurrencyPairMetaData adaptPairMetaData(LatokenPair latokenPair) {
BigDecimal tradingFee = latokenPair.getTakerFee();
BigDecimal minAmount = latokenPair.getMinOrderAmount().setScale(latokenPair.getAmountPrecision(), RoundingMode.HALF_DOWN);
int priceScale = latokenPair.getPricePrecision();
return new CurrencyPairMetaData(tradingFee, minAmount, null, priceScale, null);
}
use of org.knowm.xchange.dto.meta.CurrencyPairMetaData 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;
}
use of org.knowm.xchange.dto.meta.CurrencyPairMetaData 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);
}
}
use of org.knowm.xchange.dto.meta.CurrencyPairMetaData in project XChange by knowm.
the class LatokenExchange method addCurrencyPairMetadata.
/**
* Updates the meta-data entry of a given {@link CurrencyPair}. <br>
* Used for overriding the static meta-data with dynamic one received from the exchange.
*
* @param pairs
* @param pair
* @param precision
*/
private void addCurrencyPairMetadata(Map<CurrencyPair, CurrencyPairMetaData> pairs, CurrencyPair pair, CurrencyPairMetaData pairMetadata) {
CurrencyPairMetaData baseMetaData = pairs.get(pair);
// Preserve MaxAmount if exists
BigDecimal maxAmount = baseMetaData == null ? pairMetadata.getMaximumAmount() : baseMetaData.getMaximumAmount();
// Override static meta-data
pairs.put(pair, new CurrencyPairMetaData.Builder().tradingFee(pairMetadata.getTradingFee()).minimumAmount(pairMetadata.getMinimumAmount()).maximumAmount(maxAmount).priceScale(pairMetadata.getPriceScale()).build());
}
Aggregations