use of org.knowm.xchange.dto.meta.ExchangeMetaData 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.ExchangeMetaData in project XChange by knowm.
the class OkexAdapters method adaptToExchangeMetaData.
public static ExchangeMetaData adaptToExchangeMetaData(ExchangeMetaData exchangeMetaData, List<OkexInstrument> instruments, List<OkexCurrency> currs) {
Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = exchangeMetaData.getCurrencyPairs() == null ? new HashMap<>() : exchangeMetaData.getCurrencyPairs();
Map<Currency, CurrencyMetaData> currencies = exchangeMetaData.getCurrencies() == null ? new HashMap<>() : exchangeMetaData.getCurrencies();
for (OkexInstrument instrument : instruments) {
if (!"live".equals(instrument.getState())) {
continue;
}
CurrencyPair pair = adaptCurrencyPair(instrument);
CurrencyPairMetaData staticMetaData = currencyPairs.get(pair);
int priceScale = numberOfDecimals(new BigDecimal(instrument.getTickSize()));
currencyPairs.put(pair, new CurrencyPairMetaData(new BigDecimal("0.50"), new BigDecimal(instrument.getMinSize()), null, null, null, null, priceScale, null, staticMetaData != null ? staticMetaData.getFeeTiers() : null, null, pair.counter, true));
}
if (currs != null) {
currs.stream().forEach(currency -> currencies.put(adaptCurrency(currency), new CurrencyMetaData(null, new BigDecimal(currency.getMaxFee()), new BigDecimal(currency.getMinWd()), currency.isCanWd() && currency.isCanDep() ? WalletHealth.ONLINE : WalletHealth.OFFLINE)));
}
return new ExchangeMetaData(currencyPairs, currencies, exchangeMetaData.getPublicRateLimits(), exchangeMetaData.getPrivateRateLimits(), true);
}
use of org.knowm.xchange.dto.meta.ExchangeMetaData in project XChange by knowm.
the class BaseExchangeService method verifyOrder.
public void verifyOrder(LimitOrder limitOrder) {
ExchangeMetaData exchangeMetaData = exchange.getExchangeMetaData();
verifyOrder(limitOrder, exchangeMetaData);
BigDecimal price = limitOrder.getLimitPrice().stripTrailingZeros();
if (price.scale() > exchangeMetaData.getCurrencyPairs().get(limitOrder.getCurrencyPair()).getPriceScale()) {
throw new IllegalArgumentException("Unsupported price scale " + price.scale());
}
}
use of org.knowm.xchange.dto.meta.ExchangeMetaData in project XChange by knowm.
the class PoloniexMetaDataDemo method main.
public static void main(String[] args) throws IOException {
// Use the factory to get Poloniex exchange API using default settings
Exchange anx = ExchangeFactory.INSTANCE.createExchange(PoloniexExchange.class);
ExchangeMetaData exchangeMetaData = anx.getExchangeMetaData();
System.out.println(exchangeMetaData.toJSONString());
System.out.println("private poll delay ms: " + ExchangeMetaData.getPollDelayMillis(exchangeMetaData.getPrivateRateLimits()));
System.out.println("public poll delay ms: " + ExchangeMetaData.getPollDelayMillis(exchangeMetaData.getPublicRateLimits()));
}
use of org.knowm.xchange.dto.meta.ExchangeMetaData in project XChange by knowm.
the class BleutradeAdapters method adaptToExchangeMetaData.
public static ExchangeMetaData adaptToExchangeMetaData(List<BleutradeCurrency> bleutradeCurrencies, List<BleutradeMarket> bleutradeMarkets) {
Map<CurrencyPair, CurrencyPairMetaData> marketMetaDataMap = new HashMap<>();
Map<Currency, CurrencyMetaData> currencyMetaDataMap = new HashMap<>();
for (BleutradeCurrency bleutradeCurrency : bleutradeCurrencies) {
// the getTxFee parameter is the withdrawal charge in the currency in question
currencyMetaDataMap.put(Currency.getInstance(bleutradeCurrency.getCurrency()), new CurrencyMetaData(8, null));
}
// https://bleutrade.com/help/fees_and_deadlines 11/25/2015 all == 0.25%
BigDecimal txFee = new BigDecimal("0.0025");
for (BleutradeMarket bleutradeMarket : bleutradeMarkets) {
CurrencyPair currencyPair = CurrencyPairDeserializer.getCurrencyPairFromString(bleutradeMarket.getMarketName());
CurrencyPairMetaData marketMetaData = new CurrencyPairMetaData(txFee, bleutradeMarket.getMinTradeSize(), null, 8, null);
marketMetaDataMap.put(currencyPair, marketMetaData);
}
return new ExchangeMetaData(marketMetaDataMap, currencyMetaDataMap, null, null, null);
}
Aggregations