use of org.knowm.xchange.dto.meta.ExchangeMetaData in project XChange by knowm.
the class CoinbaseProExchangeIntegration method testExchangeMetaData.
@Test
public void testExchangeMetaData() {
final Exchange exchange = ExchangeFactory.INSTANCE.createExchange(CoinbaseProExchange.class);
ExchangeMetaData exchangeMetaData = exchange.getExchangeMetaData();
Assert.assertNotNull(exchangeMetaData);
Assert.assertNotNull(exchangeMetaData.getCurrencies());
Assert.assertNotNull("USDC is not defined", exchangeMetaData.getCurrencies().get(new Currency("USDC")));
}
use of org.knowm.xchange.dto.meta.ExchangeMetaData in project XChange by knowm.
the class DsxAdapters method adaptToExchangeMetaData.
public static ExchangeMetaData adaptToExchangeMetaData(List<DsxSymbol> symbols, Map<Currency, CurrencyMetaData> currencies, Map<CurrencyPair, CurrencyPairMetaData> currencyPairs) {
if (symbols != null) {
for (DsxSymbol symbol : symbols) {
CurrencyPair pair = adaptSymbol(symbol);
BigDecimal tickSize = symbol.getTickSize();
// not 100% sure this is correct
int priceScale = tickSize.scale();
BigDecimal tradingFee = symbol.getTakeLiquidityRate();
BigDecimal minimumAmount = symbol.getQuantityIncrement();
BigDecimal maximumAmount = null;
FeeTier[] feeTiers = null;
if (currencyPairs.containsKey(pair)) {
CurrencyPairMetaData existing = currencyPairs.get(pair);
minimumAmount = existing.getMinimumAmount();
maximumAmount = existing.getMaximumAmount();
feeTiers = existing.getFeeTiers();
}
CurrencyPairMetaData meta = new CurrencyPairMetaData(tradingFee, minimumAmount, maximumAmount, priceScale, feeTiers);
currencyPairs.put(pair, meta);
}
}
return new ExchangeMetaData(currencyPairs, currencies, null, null, null);
}
use of org.knowm.xchange.dto.meta.ExchangeMetaData in project XChange by knowm.
the class CryptopiaAdaptersTest method testExchangeMetaDataAdapter.
@Test
public void testExchangeMetaDataAdapter() throws IOException {
// Read in the JSON from the example resources
InputStream is = CryptopiaAdaptersTest.class.getResourceAsStream("/org/knowm/xchange/cryptopia/dto/marketdata/example-currencies.json");
// Use Jackson to parse it
ObjectMapper mapper = new ObjectMapper();
CryptopiaBaseResponse<List<CryptopiaCurrency>> cryptopiaCurrencies = mapper.readValue(is, CryptopiaBaseResponseCryptopiaCurrency.class);
is.close();
assertThat(cryptopiaCurrencies).isNotNull();
is = CryptopiaAdaptersTest.class.getResourceAsStream("/org/knowm/xchange/cryptopia/dto/marketdata/example-trade-pairs.json");
CryptopiaBaseResponse<List<CryptopiaTradePair>> cryptopiaTradePairs = mapper.readValue(is, CryptopiaBaseResponseCryptopiaTradePair.class);
is.close();
assertThat(cryptopiaTradePairs).isNotNull();
ExchangeMetaData exchangeMetaData = CryptopiaAdapters.adaptToExchangeMetaData(cryptopiaCurrencies.getData(), cryptopiaTradePairs.getData());
assertThat(exchangeMetaData).isNotNull();
assertThat(exchangeMetaData.getCurrencies()).containsKey(Currency.ETH);
assertThat(exchangeMetaData.getCurrencies().get(Currency.ETH).getScale()).isEqualTo(8);
assertThat(exchangeMetaData.getCurrencyPairs()).containsKey(CurrencyPair.ETH_BTC);
assertThat(exchangeMetaData.getCurrencyPairs().get(CurrencyPair.ETH_BTC).getTradingFee().toString()).isEqualTo("0.20000000");
}
use of org.knowm.xchange.dto.meta.ExchangeMetaData in project XChange by knowm.
the class BitcoinChartsAdapters method adaptMetaData.
public static ExchangeMetaData adaptMetaData(ExchangeMetaData exchangeMetaData, BitcoinChartsTicker[] tickers) {
Map<CurrencyPair, CurrencyPairMetaData> pairs = new HashMap<>();
for (BitcoinChartsTicker ticker : tickers) {
BigDecimal anyPrice = firstNonNull(ticker.getAsk(), ticker.getBid(), ticker.getClose(), ticker.getHigh(), ticker.getHigh());
int scale = anyPrice != null ? anyPrice.scale() : 0;
pairs.put(new CurrencyPair(Currency.BTC, Currency.getInstance(ticker.getSymbol())), new CurrencyPairMetaData(null, null, null, scale, null));
}
return new ExchangeMetaData(pairs, exchangeMetaData.getCurrencies(), exchangeMetaData.getPublicRateLimits(), exchangeMetaData.getPrivateRateLimits(), exchangeMetaData.isShareRateLimits());
}
use of org.knowm.xchange.dto.meta.ExchangeMetaData in project XChange by knowm.
the class BleutradeAdaptersTest method shouldAdaptExchangeMetaData.
@Test
public void shouldAdaptExchangeMetaData() throws IOException {
// given
final BleutradeCurrenciesReturn currenciesResponse = parse(BleutradeCurrenciesReturn.class);
final BleutradeMarketsReturn marketsResponse = parse(BleutradeMarketsReturn.class);
final CurrencyPairMetaData[] expectedMetaDataList = expectedMetaDataList();
final String[] expectedMetaDataStr = expectedMetaDataStr();
// when
ExchangeMetaData exchangeMetaData = BleutradeAdapters.adaptToExchangeMetaData(currenciesResponse.getResult(), marketsResponse.getResult());
// then
Map<Currency, CurrencyMetaData> currencyMetaDataMap = exchangeMetaData.getCurrencies();
assertThat(currencyMetaDataMap).hasSize(2);
assertThat(currencyMetaDataMap.get(Currency.BTC).getScale()).isEqualTo(8);
assertThat(currencyMetaDataMap.get(Currency.LTC).getScale()).isEqualTo(8);
Map<CurrencyPair, CurrencyPairMetaData> marketMetaDataMap = exchangeMetaData.getCurrencyPairs();
assertThat(marketMetaDataMap).hasSize(2);
// there is no reliable information about valid tradingFee calculation formula
BleutradeAssert.assertEquals(marketMetaDataMap.get(CurrencyPair.DOGE_BTC), expectedMetaDataList[0]);
assertThat(marketMetaDataMap.get(CurrencyPair.DOGE_BTC).toString()).isEqualTo(expectedMetaDataStr[0]);
BleutradeAssert.assertEquals(marketMetaDataMap.get(BLEU_BTC_CP), expectedMetaDataList[1]);
assertThat(marketMetaDataMap.get(BLEU_BTC_CP).toString()).isEqualTo(expectedMetaDataStr[1]);
}
Aggregations