use of org.knowm.xchange.coinmarketcap.deprecated.v2.dto.marketdata.CoinMarketCapTicker in project XChange by knowm.
the class CoinMarketCapMarketDataService method getNewTickers.
private Map<String, CoinMarketCapTicker> getNewTickers() throws IOException {
Map<String, CoinMarketCapTicker> freshTickers = new HashMap<>();
List<CoinMarketCapTicker> tt = getCoinMarketCapTickers();
for (CoinMarketCapTicker t : tt) {
freshTickers.put(t.getSymbol(), t);
}
return freshTickers;
}
use of org.knowm.xchange.coinmarketcap.deprecated.v2.dto.marketdata.CoinMarketCapTicker in project XChange by knowm.
the class CoinMarketCapMarketDataService method getTicker.
@Override
public Ticker getTicker(CurrencyPair currencyPair, final Object... args) throws IOException {
Currency b = currencyPair.base;
Currency c = currencyPair.counter;
if (!tickers.containsKey(b.getCurrencyCode()) && b.getCurrencyCode().compareTo("USD") != 0)
throw new IOException("unsupported ISO 4217 Currency: " + b.getCurrencyCode());
if (!tickers.containsKey(c.getCurrencyCode()) && c.getCurrencyCode().compareTo("USD") != 0)
throw new IOException("unsupported ISO 4217 Currency: " + c.getCurrencyCode());
if (b.getCurrencyCode().compareTo(c.getCurrencyCode()) == 0)
throw new IOException("base and counter currency must not be identical");
CoinMarketCapTicker cmcB = tickers.get(b.getCurrencyCode());
BigDecimal price;
BigDecimal volume;
try {
price = cmcB.getQuotes().get(c.toString()).getPrice();
volume = cmcB.getQuotes().get(c.toString()).getVolume24h();
} catch (NullPointerException npe) {
throw new NotAvailableFromExchangeException();
}
return new Ticker.Builder().currencyPair(currencyPair).timestamp(cmcB.getLastUpdated()).last(price).bid(price).ask(price).high(price).low(price).vwap(price).volume(volume).build();
}
use of org.knowm.xchange.coinmarketcap.deprecated.v2.dto.marketdata.CoinMarketCapTicker in project XChange by knowm.
the class CoinMarketCapMarketDataService method getCoinMarketCapCurrencies.
@Override
public List<CoinMarketCapCurrency> getCoinMarketCapCurrencies() {
Collection<CoinMarketCapTicker> tickers = this.tickers.values();
List<CoinMarketCapCurrency> currencies = new ArrayList<>();
for (CoinMarketCapTicker ticker : tickers) currencies.add(ticker.getBaseCurrency());
return currencies;
}
use of org.knowm.xchange.coinmarketcap.deprecated.v2.dto.marketdata.CoinMarketCapTicker in project XChange by knowm.
the class CoinMarketCapMarketDataServiceRaw method getCoinMarketCapCurrencies.
/**
* Unauthenticated resource that returns currencies supported on CoinMarketCap.
*
* @return A list of currency names and their corresponding ISO code.
* @throws IOException
*/
public List<CoinMarketCapCurrency> getCoinMarketCapCurrencies() throws IOException {
List<CoinMarketCapTicker> tickers = getCoinMarketCapTickers();
List<CoinMarketCapCurrency> currencies = new ArrayList<>();
for (CoinMarketCapTicker ticker : tickers) currencies.add(ticker.getBaseCurrency());
return currencies;
}
Aggregations