Search in sources :

Example 1 with OkexInstrument

use of org.knowm.xchange.okex.v5.dto.marketdata.OkexInstrument 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)

Aggregations

BigDecimal (java.math.BigDecimal)1 Currency (org.knowm.xchange.currency.Currency)1 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)1 CurrencyMetaData (org.knowm.xchange.dto.meta.CurrencyMetaData)1 CurrencyPairMetaData (org.knowm.xchange.dto.meta.CurrencyPairMetaData)1 ExchangeMetaData (org.knowm.xchange.dto.meta.ExchangeMetaData)1 OkexCurrency (org.knowm.xchange.okex.v5.dto.marketdata.OkexCurrency)1 OkexInstrument (org.knowm.xchange.okex.v5.dto.marketdata.OkexInstrument)1