use of org.knowm.xchange.dto.meta.ExchangeMetaData 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.ExchangeMetaData in project XChange by knowm.
the class KucoinMarketDataServiceIntegration method testGetMarketData.
@Test
public void testGetMarketData() throws Exception {
KucoinExchange exchange = exchange();
ExchangeMetaData exchangeMetaData = exchange.getExchangeMetaData();
exchangeMetaData.getCurrencyPairs().entrySet().forEach(pair -> {
assertThat(pair.getValue().getMinimumAmount()).isNotNull();
assertThat(pair.getValue().getMaximumAmount()).isNotNull();
assertThat(pair.getValue().getCounterMinimumAmount()).isNotNull();
assertThat(pair.getValue().getCounterMaximumAmount()).isNotNull();
assertThat(pair.getValue().getBaseScale()).isNotNull();
assertThat(pair.getValue().getPriceScale()).isNotNull();
assertThat(pair.getValue().getTradingFeeCurrency()).isNotNull();
});
}
use of org.knowm.xchange.dto.meta.ExchangeMetaData 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;
}
use of org.knowm.xchange.dto.meta.ExchangeMetaData in project XChange by knowm.
the class BitfinexAdapters method adaptMetaData.
public static ExchangeMetaData adaptMetaData(BitfinexAccountInfosResponse[] bitfinexAccountInfos, ExchangeMetaData exchangeMetaData) {
final Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = exchangeMetaData.getCurrencyPairs();
// lets go with the assumption that the trading fees are common across all trading pairs for
// now.
// also setting the taker_fee as the trading_fee for now.
final CurrencyPairMetaData metaData = new CurrencyPairMetaData(bitfinexAccountInfos[0].getTakerFees().movePointLeft(2), null, null, null, null);
currencyPairs.keySet().parallelStream().forEach(currencyPair -> currencyPairs.merge(currencyPair, metaData, (oldMetaData, newMetaData) -> new CurrencyPairMetaData(newMetaData.getTradingFee(), oldMetaData.getMinimumAmount(), oldMetaData.getMaximumAmount(), oldMetaData.getPriceScale(), oldMetaData.getFeeTiers())));
return exchangeMetaData;
}
use of org.knowm.xchange.dto.meta.ExchangeMetaData in project XChange by knowm.
the class CoinbaseProMetadataTest method unmarshalTest.
// @Test
public void unmarshalTest() throws IOException {
JacksonObjectMapperFactory factory = new DefaultJacksonObjectMapperFactory();
ObjectMapper mapper = factory.createObjectMapper();
InputStream is = getClass().getResourceAsStream("/org/knowm/xchange/coinbasepro/dto/products.json");
CoinbaseProProduct[] products = mapper.readValue(is, CoinbaseProProduct[].class);
assertThat(products).hasSize(10);
ExchangeSpecification specification = new ExchangeSpecification(CoinbaseProExchange.class);
specification.setShouldLoadRemoteMetaData(false);
Exchange exchange = ExchangeFactory.INSTANCE.createExchange(specification);
ExchangeMetaData exchangeMetaData = exchange.getExchangeMetaData();
exchangeMetaData = CoinbaseProAdapters.adaptToExchangeMetaData(exchangeMetaData, products, new CoinbaseProCurrency[] {});
assertThat(exchangeMetaData.getCurrencyPairs().get(CurrencyPair.ETC_BTC).getPriceScale()).isEqualTo(5);
}
Aggregations