private static CurrencyPairMetaData adaptPair( HuobiAssetPair pair, CurrencyPairMetaData metadata) { BigDecimal minQty = metadata == null ? null : metadata.getMinimumAmount().setScale(Integer.parseInt(pair.getAmountPrecision())); FeeTier[] feeTiers = metadata == null ? null : metadata.getFeeTiers(); return new CurrencyPairMetaData( fee, minQty, // Min amount null, // Max amount new Integer(pair.getPricePrecision()), // Price scale feeTiers); }
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); }
public void updateMetadata(ExchangeMetaData exchangeMetaData) throws IOException { Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = exchangeMetaData.getCurrencyPairs(); Map<Currency, CurrencyMetaData> currencies = exchangeMetaData.getCurrencies(); Map<String, Map<String, String>> map = exmo.pairSettings(); for (String marketName : map.keySet()) { CurrencyPair currencyPair = adaptMarket(marketName); Map<String, String> data = map.get(marketName); Integer priceScale = null; BigDecimal tradingFee = null; if (currencyPairs.containsKey(currencyPair)) { priceScale = currencyPairs.get(currencyPair).getPriceScale(); tradingFee = currencyPairs.get(currencyPair).getTradingFee(); } CurrencyPairMetaData staticMeta = currencyPairs.get(currencyPair); // min_quantity or min_amount ??? CurrencyPairMetaData currencyPairMetaData = new CurrencyPairMetaData( tradingFee, new BigDecimal(data.get("min_quantity")), new BigDecimal(data.get("max_quantity")), priceScale, staticMeta != null ? staticMeta.getFeeTiers() : null); currencyPairs.put(currencyPair, currencyPairMetaData); if (!currencies.containsKey(currencyPair.base)) currencies.put(currencyPair.base, new CurrencyMetaData(8, null)); if (!currencies.containsKey(currencyPair.counter)) currencies.put(currencyPair.counter, new CurrencyMetaData(8, null)); } }
private static CurrencyPairMetaData adaptPair( BitmexTicker ticker, CurrencyPairMetaData originalMeta) { if (originalMeta != null) { return new CurrencyPairMetaData( ticker.getTakerFee(), originalMeta.getMinimumAmount(), originalMeta.getMaximumAmount(), Math.max(0, ticker.getTickSize().stripTrailingZeros().scale()), originalMeta.getFeeTiers()); } else { return new CurrencyPairMetaData( ticker.getTakerFee(), null, null, Math.max(0, ticker.getTickSize().stripTrailingZeros().scale()), null); } }
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) { BigDecimal minSize = product.getMinLimitQuantity() == null ? BigDecimal.ZERO : product.getMinLimitQuantity(); minSize = minSize.setScale(product.getPriceScale(), BigDecimal.ROUND_UNNECESSARY); CurrencyPair pair = adaptCurrencyPair(product); CurrencyPairMetaData staticMetaData = exchangeMetaData.getCurrencyPairs().get(pair); int priceScale = staticMetaData == null ? 8 : staticMetaData.getPriceScale(); if (currencyPairs.containsKey(pair)) { CurrencyPairMetaData existing = currencyPairs.get(pair); currencyPairs.put( pair, new CurrencyPairMetaData( existing.getTradingFee(), minSize, existing.getMaximumAmount(), priceScale, existing.getFeeTiers())); } else { currencyPairs.put(pair, new CurrencyPairMetaData(null, minSize, null, priceScale, null)); } 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); }
@Override public void remoteInit() { Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = exchangeMetaData.getCurrencyPairs(); CoindirectMarketDataService coindirectMarketDataService = (CoindirectMarketDataService) marketDataService; try { List<CoindirectMarket> coindirectMarketList = coindirectMarketDataService.getCoindirectMarkets(1000); for (CoindirectMarket market : coindirectMarketList) { CurrencyPair currencyPair = CoindirectAdapters.toCurrencyPair(market.symbol); CurrencyPairMetaData staticMeta = currencyPairs.get(currencyPair); CurrencyPairMetaData adaptedMeta = new CurrencyPairMetaData( staticMeta.getTradingFee(), market.minimumQuantity, market.maximumQuantity, staticMeta.getPriceScale(), staticMeta.getFeeTiers()); currencyPairs.put(currencyPair, adaptedMeta); } } catch (IOException exception) { } } }
public static ExchangeMetaData adaptMetaData( BitfinexAccountInfosResponse[] bitfinexAccountInfos, ExchangeMetaData exchangeMetaData) { final Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = exchangeMetaData.getCurrencyPairs(); // lets go with the assumption that the trading fees are common across all trading pairs for // now. // also setting the taker_fee as the trading_fee for now. final CurrencyPairMetaData metaData = new CurrencyPairMetaData( bitfinexAccountInfos[0].getTakerFees().movePointLeft(2), null, null, null, null); currencyPairs .keySet() .parallelStream() .forEach( currencyPair -> currencyPairs.merge( currencyPair, metaData, (oldMetaData, newMetaData) -> new CurrencyPairMetaData( newMetaData.getTradingFee(), oldMetaData.getMinimumAmount(), oldMetaData.getMaximumAmount(), oldMetaData.getPriceScale(), oldMetaData.getFeeTiers()))); return exchangeMetaData; }
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(); int priceScale = tickSize.scale(); // not 100% sure this is correct 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); }
public static ExchangeMetaData adaptToExchangeMetaData( ExchangeMetaData exchangeMetaData, CoinbaseProProduct[] products) { Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = exchangeMetaData.getCurrencyPairs(); Map<Currency, CurrencyMetaData> currencies = exchangeMetaData.getCurrencies(); for (CoinbaseProProduct product : products) { BigDecimal minSize = product.getBaseMinSize(); BigDecimal maxSize = product.getBaseMaxSize(); CurrencyPair pair = adaptCurrencyPair(product); CurrencyPairMetaData staticMetaData = exchangeMetaData.getCurrencyPairs().get(pair); int priceScale = numberOfDecimals(product.getQuoteIncrement()); CurrencyPairMetaData cpmd = new CurrencyPairMetaData( null, minSize, maxSize, priceScale, staticMetaData != null ? staticMetaData.getFeeTiers() : null); currencyPairs.put(pair, cpmd); 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, exchangeMetaData.getPublicRateLimits(), exchangeMetaData.getPrivateRateLimits(), true); }
: oldMetaData.getMaximumAmount(), oldMetaData.getPriceScale(), newMetaData.getFeeTiers() != null ? newMetaData.getFeeTiers() : oldMetaData.getFeeTiers()));
private static CurrencyPairMetaData adaptPair( BitmexTicker ticker, CurrencyPairMetaData originalMeta) { if (originalMeta != null) { return new CurrencyPairMetaData( ticker.getTakerFee(), originalMeta.getMinimumAmount(), originalMeta.getMaximumAmount(), Math.max(0, ticker.getTickSize().stripTrailingZeros().scale()), originalMeta.getFeeTiers()); } else { return new CurrencyPairMetaData( ticker.getTakerFee(), null, null, Math.max(0, ticker.getTickSize().stripTrailingZeros().scale()), null); } }
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(); int priceScale = tickSize.scale(); // not 100% sure this is correct 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); }
public static ExchangeMetaData adaptMetaData( BitfinexAccountInfosResponse[] bitfinexAccountInfos, ExchangeMetaData exchangeMetaData) { final Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = exchangeMetaData.getCurrencyPairs(); // lets go with the assumption that the trading fees are common across all trading pairs for // now. // also setting the taker_fee as the trading_fee for now. final CurrencyPairMetaData metaData = new CurrencyPairMetaData( bitfinexAccountInfos[0].getTakerFees().movePointLeft(2), null, null, null, null); currencyPairs .keySet() .parallelStream() .forEach( currencyPair -> currencyPairs.merge( currencyPair, metaData, (oldMetaData, newMetaData) -> new CurrencyPairMetaData( newMetaData.getTradingFee(), oldMetaData.getMinimumAmount(), oldMetaData.getMaximumAmount(), oldMetaData.getPriceScale(), oldMetaData.getFeeTiers()))); return exchangeMetaData; }
: oldMetaData.getMaximumAmount(), oldMetaData.getPriceScale(), newMetaData.getFeeTiers() != null ? newMetaData.getFeeTiers() : oldMetaData.getFeeTiers()));