use of org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.CmcTicker in project XChange by knowm.
the class CmcAdapter method adaptTickerList.
public static List<Ticker> adaptTickerList(List<CmcTicker> cmcTickerList) {
List<Ticker> tickerList = new ArrayList<>();
cmcTickerList.forEach(cmcTicker -> {
cmcTicker.getQuote().forEach((currencySymbol, quote) -> {
CurrencyPair pair = new CurrencyPair(cmcTicker.getSymbol(), currencySymbol);
tickerList.add(adaptTicker(cmcTicker, pair));
});
});
return tickerList;
}
use of org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.CmcTicker in project XChange by knowm.
the class CmcMarketDataService method getTickers.
@Override
public List<Ticker> getTickers(Params params) throws IOException {
if (!(params instanceof CurrencyPairsParam)) {
throw new IllegalArgumentException("Params must be instance of CurrencyPairsParam");
}
Collection<CurrencyPair> pairs = ((CurrencyPairsParam) params).getCurrencyPairs();
Set<Currency> baseSymbols = new HashSet<>();
Set<Currency> convertSymbols = new HashSet<>();
for (CurrencyPair pair : pairs) {
baseSymbols.add(pair.base);
convertSymbols.add(pair.counter);
}
Map<String, CmcTicker> cmcTickerMap = super.getCmcLatestQuotes(baseSymbols, convertSymbols);
return CmcAdapter.adaptTickerMap(cmcTickerMap);
}
use of org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.CmcTicker in project XChange by knowm.
the class CmcAdapter method adaptTickerMap.
public static List<Ticker> adaptTickerMap(Map<String, CmcTicker> cmcTickerMap) {
List<Ticker> tickerList = new ArrayList<>();
cmcTickerMap.forEach((baseSymbol, cmcTicker) -> {
cmcTicker.getQuote().forEach((currencySymbol, quote) -> {
CurrencyPair pair = new CurrencyPair(cmcTicker.getSymbol(), currencySymbol);
tickerList.add(adaptTicker(cmcTicker, pair));
});
});
return tickerList;
}
use of org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.CmcTicker in project XChange by knowm.
the class CmcAdapter method adaptTicker.
public static Ticker adaptTicker(CmcTicker ticker, CurrencyPair currencyPair) {
Date timestamp = ticker.getLastUpdated();
CmcQuote cmcQuote = ticker.getQuote().get(currencyPair.counter.getCurrencyCode());
BigDecimal price = cmcQuote.getPrice();
BigDecimal volume24h = cmcQuote.getVolume24h();
return new Ticker.Builder().currencyPair(currencyPair).timestamp(timestamp).open(price).last(price).bid(price).ask(price).high(price).low(price).vwap(price).volume(volume24h).build();
}
use of org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.CmcTicker in project XChange by knowm.
the class CmcMarketDataServiceRaw method getCmcLatestQuotes.
public Map<String, CmcTicker> getCmcLatestQuotes(Set<Currency> baseCurrencySet, Set<Currency> convertCurrencySet) throws IOException {
List<String> baseSymbols = baseCurrencySet.stream().map(c -> c.getCurrencyCode()).collect(Collectors.toList());
String commaSeparatedBaseSymbols = StringUtils.join(baseSymbols, ",");
List<String> convertSymbols = convertCurrencySet.stream().map(c -> c.getCurrencyCode()).collect(Collectors.toList());
String commaSeparatedConvertCurrencies = StringUtils.join(convertSymbols, ",");
CmcTickerResponse response = null;
try {
response = cmcAuthenticated.getLatestQuotes(apiKey, commaSeparatedBaseSymbols, commaSeparatedConvertCurrencies);
} catch (HttpStatusIOException ex) {
CmcErrorAdapter.adapt(ex);
}
return response.getData();
}
Aggregations