public static ExchangeMetaData toMetaData( DSXExchangeInfo dsxExchangeInfo, DSXMetaData dsxMetaData) { Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = new HashMap<>(); Map<Currency, CurrencyMetaData> currencies = new HashMap<>(); if (dsxExchangeInfo != null) { for (Entry<String, DSXPairInfo> e : dsxExchangeInfo.getPairs().entrySet()) { String marketName = e.getKey(); CurrencyPair pair = adaptCurrencyPair(marketName); CurrencyPairMetaData marketMetaData = toMarketMetaData(e.getValue()); currencyPairs.put(pair, marketMetaData); addCurrencyMetaData(pair.base, currencies, dsxMetaData); addCurrencyMetaData(pair.counter, currencies, dsxMetaData); } } RateLimit[] publicRateLimits = new RateLimit[] {new RateLimit(dsxMetaData.publicInfoCacheSeconds, 1, TimeUnit.SECONDS)}; return new ExchangeMetaData(currencyPairs, currencies, publicRateLimits, null, false); }
/** * @return minimum number of milliseconds required between any two remote calls, assuming the * client makes consecutive calls without any bursts or breaks for an infinite period of time. * Returns null if the rateLimits collection is null or empty */ @JsonIgnore public static Long getPollDelayMillis(RateLimit[] rateLimits) { if (rateLimits == null || rateLimits.length == 0) { return null; } long result = 0; for (RateLimit rateLimit : rateLimits) { // this is the delay between calls, we want max, any smaller number is for burst calls result = Math.max(result, rateLimit.getPollDelayMillis()); } return result; }
public static ExchangeMetaData toMetaData( WexExchangeInfo wexExchangeInfo, WexMetaData wexMetaData) { // Initialize with the static meta-data Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = new HashMap<>(wexMetaData.getCurrencyPairs()); Map<Currency, CurrencyMetaData> currencies = new HashMap<>(wexMetaData.getCurrencies()); // Override entries if relevant real-time exchange data is provided if (wexExchangeInfo != null) { for (Entry<String, WexPairInfo> e : wexExchangeInfo.getPairs().entrySet()) { CurrencyPair pair = adaptCurrencyPair(e.getKey()); CurrencyPairMetaData marketMetaData = toMarketMetaData(e.getValue(), wexMetaData); currencyPairs.put(pair, marketMetaData); addCurrencyMetaData(pair.base, currencies, wexMetaData); addCurrencyMetaData(pair.counter, currencies, wexMetaData); } } RateLimit[] publicRateLimits = new RateLimit[] {new RateLimit(wexMetaData.publicInfoCacheSeconds, 1, TimeUnit.SECONDS)}; return new ExchangeMetaData(currencyPairs, currencies, publicRateLimits, null, false); }
/** * @return minimum number of milliseconds required between any two remote calls, assuming the * client makes consecutive calls without any bursts or breaks for an infinite period of time. * Returns null if the rateLimits collection is null or empty */ @JsonIgnore public static Long getPollDelayMillis(RateLimit[] rateLimits) { if (rateLimits == null || rateLimits.length == 0) { return null; } long result = 0; for (RateLimit rateLimit : rateLimits) { // this is the delay between calls, we want max, any smaller number is for burst calls result = Math.max(result, rateLimit.getPollDelayMillis()); } return result; }
public static ExchangeMetaData toMetaData(BTCEExchangeInfo btceExchangeInfo, BTCEMetaData btceMetaData) { Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = new HashMap<>(); Map<Currency, CurrencyMetaData> currencies = new HashMap<>(); if (btceExchangeInfo != null) { for (Entry<String, BTCEPairInfo> e : btceExchangeInfo.getPairs().entrySet()) { CurrencyPair pair = adaptCurrencyPair(e.getKey()); CurrencyPairMetaData marketMetaData = toMarketMetaData(e.getValue(), btceMetaData); currencyPairs.put(pair, marketMetaData); addCurrencyMetaData(pair.base, currencies, btceMetaData); addCurrencyMetaData(pair.counter, currencies, btceMetaData); } } RateLimit[] publicRateLimits = new RateLimit[]{new RateLimit(btceMetaData.publicInfoCacheSeconds, 1, TimeUnit.SECONDS)}; return new ExchangeMetaData(currencyPairs, currencies, publicRateLimits, null, false); }
public static ExchangeMetaData toMetaData( WexExchangeInfo wexExchangeInfo, WexMetaData wexMetaData) { // Initialize with the static meta-data Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = new HashMap<>(wexMetaData.getCurrencyPairs()); Map<Currency, CurrencyMetaData> currencies = new HashMap<>(wexMetaData.getCurrencies()); // Override entries if relevant real-time exchange data is provided if (wexExchangeInfo != null) { for (Entry<String, WexPairInfo> e : wexExchangeInfo.getPairs().entrySet()) { CurrencyPair pair = adaptCurrencyPair(e.getKey()); CurrencyPairMetaData marketMetaData = toMarketMetaData(e.getValue(), wexMetaData); currencyPairs.put(pair, marketMetaData); addCurrencyMetaData(pair.base, currencies, wexMetaData); addCurrencyMetaData(pair.counter, currencies, wexMetaData); } } RateLimit[] publicRateLimits = new RateLimit[] {new RateLimit(wexMetaData.publicInfoCacheSeconds, 1, TimeUnit.SECONDS)}; return new ExchangeMetaData(currencyPairs, currencies, publicRateLimits, null, false); }