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)); } }
: currencyPairs .get(currencyPair) .getTradingFee(), // Take tradingFee from static metaData if exists bitfinexSymbolDetail .getMinimum_order_size()
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; }
new CurrencyPairMetaData( oldMetaData.getTradingFee(), newMetaData.getMinimumAmount(),
: currencyPairs .get(currencyPair) .getTradingFee(), // Take tradingFee from static metaData if exists bitfinexSymbolDetail .getMinimum_order_size()
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; }
new CurrencyPairMetaData( oldMetaData.getTradingFee(), newMetaData.getMinimumAmount(),