use of org.knowm.xchange.dto.meta.FeeTier 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.FeeTier in project XChange by knowm.
the class CCEXAdapters method adaptToExchangeMetaData.
public static ExchangeMetaData adaptToExchangeMetaData(ExchangeMetaData exchangeMetaData, List<CCEXMarket> products) {
Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = new HashMap<>();
Map<CurrencyPair, CurrencyPairMetaData> existingCurrencyPairMetadata = exchangeMetaData.getCurrencyPairs();
Map<Currency, CurrencyMetaData> currencies = new HashMap<>();
for (CCEXMarket product : products) {
BigDecimal minSize = product.getMinTradeSize();
CurrencyPair pair = adaptCurrencyPair(product);
CurrencyPairMetaData existingMetaForPair = existingCurrencyPairMetadata.get(pair);
FeeTier[] existingFeeTiers = null;
if (existingMetaForPair != null) {
existingFeeTiers = existingMetaForPair.getFeeTiers();
}
CurrencyPairMetaData cpmd = new CurrencyPairMetaData(null, minSize, null, 0, existingFeeTiers);
currencyPairs.put(pair, cpmd);
currencies.put(pair.base, null);
currencies.put(pair.counter, null);
}
return new ExchangeMetaData(currencyPairs, currencies, null, null, true);
}
use of org.knowm.xchange.dto.meta.FeeTier in project XChange by knowm.
the class HuobiAdapters method adaptPair.
private static CurrencyPairMetaData adaptPair(HuobiAssetPair pair, CurrencyPairMetaData metadata) {
BigDecimal minQty = metadata == null ? null : metadata.getMinimumAmount().setScale(pair.getAmountPrecision(), RoundingMode.DOWN);
FeeTier[] feeTiers = metadata == null ? null : metadata.getFeeTiers();
return new CurrencyPairMetaData(fee, minQty, null, null, null, new Integer(pair.getAmountPrecision()), new Integer(pair.getPricePrecision()), null, feeTiers, null, null, true);
}
use of org.knowm.xchange.dto.meta.FeeTier in project XChange by knowm.
the class HitbtcAdapters method adaptToExchangeMetaData.
public static ExchangeMetaData adaptToExchangeMetaData(List<HitbtcSymbol> symbols, Map<Currency, CurrencyMetaData> currencies, Map<CurrencyPair, CurrencyPairMetaData> currencyPairs) {
if (symbols != null) {
for (HitbtcSymbol symbol : symbols) {
CurrencyPair pair = adaptSymbol(symbol);
BigDecimal tickSize = symbol.getTickSize();
// not 100% sure this is correct
int priceScale = tickSize.scale();
BigDecimal tradingFee = symbol.getTakeLiquidityRate();
BigDecimal minimumAmount = symbol.getQuantityIncrement();
BigDecimal maximumAmount = null;
FeeTier[] feeTiers = null;
if (currencyPairs.containsKey(pair)) {
CurrencyPairMetaData existing = currencyPairs.get(pair);
minimumAmount = existing.getMinimumAmount();
maximumAmount = existing.getMaximumAmount();
feeTiers = existing.getFeeTiers();
}
CurrencyPairMetaData meta = new CurrencyPairMetaData(tradingFee, minimumAmount, maximumAmount, priceScale, feeTiers);
currencyPairs.put(pair, meta);
}
}
return new ExchangeMetaData(currencyPairs, currencies, null, null, null);
}
use of org.knowm.xchange.dto.meta.FeeTier in project XChange by knowm.
the class HitbtcExchange method remoteInit.
@Override
public void remoteInit() throws IOException {
HitbtcMarketDataServiceRaw dataService = ((HitbtcMarketDataServiceRaw) marketDataService);
List<HitbtcSymbol> hitbtcSymbols = dataService.getHitbtcSymbols();
Map<Currency, CurrencyMetaData> currencies = dataService.getHitbtcCurrencies().stream().collect(Collectors.toMap(hitbtcCurrency -> new Currency(hitbtcCurrency.getId()), hitbtcCurrency -> new CurrencyMetaData(null, hitbtcCurrency.getPayoutFee())));
Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = hitbtcSymbols.stream().collect(Collectors.toMap(hitbtcSymbol -> new CurrencyPair(new Currency(hitbtcSymbol.getBaseCurrency()), new Currency(hitbtcSymbol.getQuoteCurrency())), hitbtcSymbol -> new CurrencyPairMetaData((BigDecimal) null, hitbtcSymbol.getQuantityIncrement(), (BigDecimal) null, hitbtcSymbol.getTickSize().scale(), (FeeTier[]) null)));
exchangeMetaData = HitbtcAdapters.adaptToExchangeMetaData(hitbtcSymbols, currencies, currencyPairs);
}
Aggregations