Search in sources :

Example 1 with ExchangeMetaData

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

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);
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) ExchangeMetaData(org.knowm.xchange.dto.meta.ExchangeMetaData) Currency(org.knowm.xchange.currency.Currency) OkexCurrency(org.knowm.xchange.okex.v5.dto.marketdata.OkexCurrency) OkexInstrument(org.knowm.xchange.okex.v5.dto.marketdata.OkexInstrument) BigDecimal(java.math.BigDecimal) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 3 with ExchangeMetaData

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

Example 4 with ExchangeMetaData

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()));
}
Also used : PoloniexExchange(org.knowm.xchange.poloniex.PoloniexExchange) Exchange(org.knowm.xchange.Exchange) ExchangeMetaData(org.knowm.xchange.dto.meta.ExchangeMetaData)

Example 5 with ExchangeMetaData

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

Aggregations

ExchangeMetaData (org.knowm.xchange.dto.meta.ExchangeMetaData)33 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)23 CurrencyPairMetaData (org.knowm.xchange.dto.meta.CurrencyPairMetaData)22 Currency (org.knowm.xchange.currency.Currency)18 CurrencyMetaData (org.knowm.xchange.dto.meta.CurrencyMetaData)18 HashMap (java.util.HashMap)12 BigDecimal (java.math.BigDecimal)11 Test (org.junit.Test)9 Exchange (org.knowm.xchange.Exchange)5 FeeTier (org.knowm.xchange.dto.meta.FeeTier)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 RateLimit (org.knowm.xchange.dto.meta.RateLimit)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Fee (org.knowm.xchange.dto.account.Fee)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 InputStream (java.io.InputStream)2 MathContext (java.math.MathContext)2