Search in sources :

Example 1 with FeeTier

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;
}
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 2 with FeeTier

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);
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) HashMap(java.util.HashMap) ExchangeMetaData(org.knowm.xchange.dto.meta.ExchangeMetaData) Currency(org.knowm.xchange.currency.Currency) CCEXMarket(org.knowm.xchange.ccex.dto.marketdata.CCEXMarket) FeeTier(org.knowm.xchange.dto.meta.FeeTier) BigDecimal(java.math.BigDecimal) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 3 with FeeTier

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);
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) FeeTier(org.knowm.xchange.dto.meta.FeeTier) BigDecimal(java.math.BigDecimal)

Example 4 with FeeTier

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);
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) ExchangeMetaData(org.knowm.xchange.dto.meta.ExchangeMetaData) HitbtcSymbol(org.knowm.xchange.hitbtc.v2.dto.HitbtcSymbol) FeeTier(org.knowm.xchange.dto.meta.FeeTier) BigDecimal(java.math.BigDecimal) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 5 with FeeTier

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);
}
Also used : HttpURLConnection(java.net.HttpURLConnection) Logger(org.slf4j.Logger) HitbtcMetaData(org.knowm.xchange.hitbtc.v2.dto.HitbtcMetaData) LoggerFactory(org.slf4j.LoggerFactory) IOException(java.io.IOException) Field(java.lang.reflect.Field) Collectors(java.util.stream.Collectors) FeeTier(org.knowm.xchange.dto.meta.FeeTier) HitbtcMarketDataService(org.knowm.xchange.hitbtc.v2.service.HitbtcMarketDataService) BigDecimal(java.math.BigDecimal) HitbtcAccountService(org.knowm.xchange.hitbtc.v2.service.HitbtcAccountService) List(java.util.List) Currency(org.knowm.xchange.currency.Currency) CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) BaseExchange(org.knowm.xchange.BaseExchange) ExchangeSpecification(org.knowm.xchange.ExchangeSpecification) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) Modifier(java.lang.reflect.Modifier) Map(java.util.Map) HitbtcSymbol(org.knowm.xchange.hitbtc.v2.dto.HitbtcSymbol) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) HitbtcMarketDataServiceRaw(org.knowm.xchange.hitbtc.v2.service.HitbtcMarketDataServiceRaw) HitbtcTradeService(org.knowm.xchange.hitbtc.v2.service.HitbtcTradeService) InputStream(java.io.InputStream) CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) HitbtcMarketDataServiceRaw(org.knowm.xchange.hitbtc.v2.service.HitbtcMarketDataServiceRaw) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) Currency(org.knowm.xchange.currency.Currency) HitbtcSymbol(org.knowm.xchange.hitbtc.v2.dto.HitbtcSymbol) FeeTier(org.knowm.xchange.dto.meta.FeeTier) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Aggregations

FeeTier (org.knowm.xchange.dto.meta.FeeTier)12 BigDecimal (java.math.BigDecimal)10 CurrencyPairMetaData (org.knowm.xchange.dto.meta.CurrencyPairMetaData)10 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)9 Currency (org.knowm.xchange.currency.Currency)7 CurrencyMetaData (org.knowm.xchange.dto.meta.CurrencyMetaData)7 ExchangeMetaData (org.knowm.xchange.dto.meta.ExchangeMetaData)5 ArrayList (java.util.ArrayList)4 Fee (org.knowm.xchange.dto.account.Fee)4 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 HitbtcSymbol (org.knowm.xchange.hitbtc.v2.dto.HitbtcSymbol)2 KrakenFee (org.knowm.xchange.kraken.dto.marketdata.KrakenFee)2 InputStream (java.io.InputStream)1 Field (java.lang.reflect.Field)1 Modifier (java.lang.reflect.Modifier)1 HttpURLConnection (java.net.HttpURLConnection)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1