Search in sources :

Example 1 with RateLimit

use of org.knowm.xchange.dto.meta.RateLimit in project XChange by knowm.

the class IdexExchange method getExchangeMetaData.

@Override
public final ExchangeMetaData getExchangeMetaData() {
    ReturnCurrenciesResponse allCurrenciesStatic = null;
    try {
        allCurrenciesStatic = allCurrenciesStatic();
    } catch (IOException e) {
        e.printStackTrace();
    }
    LinkedHashMap<CurrencyPair, CurrencyPairMetaData> currencyPairs = new LinkedHashMap<>();
    ReturnTickerRequestedWithNull allTickers = IdexMarketDataService.Companion.allTickers;
    allTickers.keySet().forEach(s -> currencyPairs.put(IdexExchange.Companion.getCurrencyPair(s), unavailableCPMeta));
    LinkedHashMap<Currency, CurrencyMetaData> linkedHashMap = new LinkedHashMap<>();
    allCurrenciesStatic.forEach((key, value) -> linkedHashMap.put(Currency.getInstance(key), new IdexCurrencyMeta(0, ZERO, value.getAddress(), value.getName(), value.getDecimals())));
    RateLimit[] publicRateLimits = {};
    return new ExchangeMetaData(currencyPairs, linkedHashMap, publicRateLimits, publicRateLimits, Boolean.FALSE);
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) IdexCurrencyMeta(org.knowm.xchange.idex.IdexExchange.Companion.IdexCurrencyMeta) ReturnCurrenciesResponse(org.knowm.xchange.idex.dto.ReturnCurrenciesResponse) IOException(java.io.IOException) ReturnTickerRequestedWithNull(org.knowm.xchange.idex.dto.ReturnTickerRequestedWithNull) LinkedHashMap(java.util.LinkedHashMap) RateLimit(org.knowm.xchange.dto.meta.RateLimit) ExchangeMetaData(org.knowm.xchange.dto.meta.ExchangeMetaData) Currency(org.knowm.xchange.currency.Currency) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 2 with RateLimit

use of org.knowm.xchange.dto.meta.RateLimit in project XChange by knowm.

the class FtxAdapters method adaptExchangeMetaData.

public static ExchangeMetaData adaptExchangeMetaData(FtxMarketsDto marketsDto) {
    Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = new HashMap<>();
    Map<Currency, CurrencyMetaData> currency = new HashMap<>();
    marketsDto.getMarketList().forEach(ftxMarketDto -> {
        CurrencyPairMetaData currencyPairMetaData = new CurrencyPairMetaData.Builder().amountStepSize(ftxMarketDto.getPriceIncrement()).minimumAmount(ftxMarketDto.getSizeIncrement()).priceScale(ftxMarketDto.getPriceIncrement().scale()).baseScale(ftxMarketDto.getSizeIncrement().scale()).build();
        if ("spot".equals(ftxMarketDto.getType())) {
            CurrencyPair currencyPair = new CurrencyPair(ftxMarketDto.getBaseCurrency(), ftxMarketDto.getQuoteCurrency());
            currencyPairs.put(currencyPair, currencyPairMetaData);
            if (!currency.containsKey(currencyPair.base)) {
                currency.put(currencyPair.base, new CurrencyMetaData(ftxMarketDto.getSizeIncrement().scale(), BigDecimal.ZERO));
            }
            if (!currency.containsKey(currencyPair.counter)) {
                currency.put(currencyPair.counter, new CurrencyMetaData(ftxMarketDto.getPriceIncrement().scale(), BigDecimal.ZERO));
            }
        } else if ("future".equals(ftxMarketDto.getType()) && ftxMarketDto.getName().contains("-")) {
            CurrencyPair futuresContract = new CurrencyPair(ftxMarketDto.getName());
            currencyPairs.put(futuresContract, currencyPairMetaData);
        }
    });
    RateLimit[] rateLimits = { new RateLimit(30, 1, TimeUnit.SECONDS) };
    return new ExchangeMetaData(currencyPairs, currency, rateLimits, rateLimits, true);
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) RateLimit(org.knowm.xchange.dto.meta.RateLimit) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) HashMap(java.util.HashMap) ExchangeMetaData(org.knowm.xchange.dto.meta.ExchangeMetaData) Currency(org.knowm.xchange.currency.Currency) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 3 with RateLimit

use of org.knowm.xchange.dto.meta.RateLimit in project XChange by knowm.

the class BitcointoyouExchangeTest method testExchangeMetaData.

@Test
public void testExchangeMetaData() throws Exception {
    final SoftAssertions softly = new SoftAssertions();
    ExchangeMetaData exchangeMetaData = sut.getExchangeMetaData();
    softly.assertThat(exchangeMetaData).isNotNull();
    softly.assertThat(exchangeMetaData.isShareRateLimits()).isTrue();
    softly.assertThat(exchangeMetaData.getCurrencies()).size().isEqualTo(1);
    Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = exchangeMetaData.getCurrencyPairs();
    softly.assertThat(currencyPairs).size().isEqualTo(1);
    softly.assertThat(currencyPairs).size().isEqualTo(1);
    softly.assertThat(exchangeMetaData.isShareRateLimits()).isTrue();
    RateLimit rateLimit = exchangeMetaData.getPrivateRateLimits()[0];
    softly.assertThat(rateLimit.getPollDelayMillis()).isEqualTo(10000);
    softly.assertAll();
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) RateLimit(org.knowm.xchange.dto.meta.RateLimit) SoftAssertions(org.assertj.core.api.SoftAssertions) ExchangeMetaData(org.knowm.xchange.dto.meta.ExchangeMetaData) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) Test(org.junit.Test)

Example 4 with RateLimit

use of org.knowm.xchange.dto.meta.RateLimit in project XChange by knowm.

the class BitcointoyouExchangeIntegration method testExchangeMetaData.

@Test
public void testExchangeMetaData() throws Exception {
    final SoftAssertions softly = new SoftAssertions();
    ExchangeMetaData exchangeMetaData = sut.getExchangeMetaData();
    softly.assertThat(exchangeMetaData).isNotNull();
    softly.assertThat(exchangeMetaData.isShareRateLimits()).isTrue();
    softly.assertThat(exchangeMetaData.getCurrencies()).size().isEqualTo(1);
    Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = exchangeMetaData.getCurrencyPairs();
    softly.assertThat(currencyPairs).size().isEqualTo(1);
    softly.assertThat(currencyPairs).size().isEqualTo(1);
    softly.assertThat(exchangeMetaData.isShareRateLimits()).isTrue();
    RateLimit rateLimit = exchangeMetaData.getPrivateRateLimits()[0];
    softly.assertThat(rateLimit.getPollDelayMillis()).isEqualTo(10000);
    softly.assertAll();
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) RateLimit(org.knowm.xchange.dto.meta.RateLimit) SoftAssertions(org.assertj.core.api.SoftAssertions) ExchangeMetaData(org.knowm.xchange.dto.meta.ExchangeMetaData) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) Test(org.junit.Test)

Aggregations

CurrencyPair (org.knowm.xchange.currency.CurrencyPair)4 CurrencyPairMetaData (org.knowm.xchange.dto.meta.CurrencyPairMetaData)4 ExchangeMetaData (org.knowm.xchange.dto.meta.ExchangeMetaData)4 RateLimit (org.knowm.xchange.dto.meta.RateLimit)4 SoftAssertions (org.assertj.core.api.SoftAssertions)2 Test (org.junit.Test)2 Currency (org.knowm.xchange.currency.Currency)2 CurrencyMetaData (org.knowm.xchange.dto.meta.CurrencyMetaData)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 IdexCurrencyMeta (org.knowm.xchange.idex.IdexExchange.Companion.IdexCurrencyMeta)1 ReturnCurrenciesResponse (org.knowm.xchange.idex.dto.ReturnCurrenciesResponse)1 ReturnTickerRequestedWithNull (org.knowm.xchange.idex.dto.ReturnTickerRequestedWithNull)1