use of org.knowm.xchange.dto.meta.CurrencyPairMetaData 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();
}
use of org.knowm.xchange.dto.meta.CurrencyPairMetaData in project XChange by knowm.
the class KrakenAdapters method adaptToExchangeMetaData.
public static ExchangeMetaData adaptToExchangeMetaData(ExchangeMetaData originalMetaData, Map<String, KrakenAssetPair> krakenPairs, Map<String, KrakenAsset> krakenAssets) {
Map<CurrencyPair, CurrencyPairMetaData> pairs = new HashMap<>();
// add assets before pairs to Utils!
KrakenUtils.setKrakenAssets(krakenAssets);
KrakenUtils.setKrakenAssetPairs(krakenPairs);
for (String krakenPairCode : krakenPairs.keySet()) {
// skip dark markets!
if (!krakenPairCode.endsWith(".d")) {
KrakenAssetPair krakenPair = krakenPairs.get(krakenPairCode);
pairs.put(adaptCurrencyPair(krakenPairCode), adaptPair(krakenPair, pairs.get(adaptCurrencyPair(krakenPairCode))));
}
}
Map<Currency, CurrencyMetaData> currencies = new HashMap<>();
for (String krakenAssetCode : krakenAssets.keySet()) {
KrakenAsset krakenAsset = krakenAssets.get(krakenAssetCode);
Currency currencyCode = KrakenAdapters.adaptCurrency(krakenAssetCode);
currencies.put(currencyCode, new CurrencyMetaData(krakenAsset.getScale(), null));
}
return new ExchangeMetaData(pairs, currencies, originalMetaData == null ? null : originalMetaData.getPublicRateLimits(), originalMetaData == null ? null : originalMetaData.getPrivateRateLimits(), originalMetaData == null ? null : originalMetaData.isShareRateLimits());
}
use of org.knowm.xchange.dto.meta.CurrencyPairMetaData in project XChange by knowm.
the class BitflyerAdapters method adaptMetaData.
public static ExchangeMetaData adaptMetaData(List<BitflyerMarket> markets) {
Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = new HashMap<>();
Map<Currency, CurrencyMetaData> currencies = new HashMap<>();
for (BitflyerMarket market : markets) {
CurrencyPair pair = adaptCurrencyPair(market.getProductCode());
currencyPairs.put(pair, null);
}
return new ExchangeMetaData(currencyPairs, currencies, null, null, false);
}
use of org.knowm.xchange.dto.meta.CurrencyPairMetaData in project wildfly-camel by wildfly-extras.
the class XChangeMetadataIntegrationTest method testCurrencyPairMetaData.
@Test
public void testCurrencyPairMetaData() throws Exception {
try (CamelContext camelctx = new DefaultCamelContext()) {
Assume.assumeTrue(checkAPIConnection());
camelctx.addRoutes(createRouteBuilder());
camelctx.start();
ProducerTemplate template = camelctx.createProducerTemplate();
CurrencyPairMetaData metadata = template.requestBody("direct:currencyPairMetaData", CurrencyPair.EOS_ETH, CurrencyPairMetaData.class);
Assert.assertNotNull("CurrencyPairMetaData not null", metadata);
metadata = template.requestBodyAndHeader("direct:currencyPairMetaData", null, HEADER_CURRENCY_PAIR, CurrencyPair.EOS_ETH, CurrencyPairMetaData.class);
Assert.assertNotNull("CurrencyPairMetaData not null", metadata);
}
}
use of org.knowm.xchange.dto.meta.CurrencyPairMetaData in project XChange by knowm.
the class BitfinexAdapters method adaptMetaData.
public static ExchangeMetaData adaptMetaData(List<CurrencyPair> currencyPairs, ExchangeMetaData metaData) {
Map<CurrencyPair, CurrencyPairMetaData> pairsMap = metaData.getCurrencyPairs();
Map<Currency, CurrencyMetaData> currenciesMap = metaData.getCurrencies();
// Remove pairs that are no-longer in use
pairsMap.keySet().retainAll(currencyPairs);
// Remove currencies that are no-longer in use
Set<Currency> currencies = currencyPairs.stream().flatMap(pair -> Stream.of(pair.base, pair.counter)).collect(Collectors.toSet());
currenciesMap.keySet().retainAll(currencies);
// Add missing pairs and currencies
for (CurrencyPair c : currencyPairs) {
if (!pairsMap.containsKey(c)) {
pairsMap.put(c, null);
}
if (!currenciesMap.containsKey(c.base)) {
currenciesMap.put(c.base, new CurrencyMetaData(2, // When missing, add default meta-data with scale of 2 (Bitfinex's minimal
null));
// scale)
}
if (!currenciesMap.containsKey(c.counter)) {
currenciesMap.put(c.counter, new CurrencyMetaData(2, null));
}
}
return metaData;
}
Aggregations