Retrieves current market data for a set of coins

current_market(coin_ids, vs_currency = "usd", max_attempts = 3)

Arguments

coin_ids

(character): a vector with IDs of the coins of interest. An up-to-date list of supported coins and their IDs can be obtained with the supported_coins() function.

vs_currency

(character): name of the reference currency to express the price in. An up-to-date list of supported reference currencies (both fiat and cryptocurrencies) can be obtained with the supported_currencies() function. If an unsupported vs_currency is requested, the call will fail with the respective error message.

max_attempts

(double, positive): specifies the maximum number of attempts to call the CoinGecko API (e.g., if the first call fails for some reason). Additional attempts are implemented with an exponential backoff. Defaults to 3.

Value

If the API call succeeds and the requested data exist, this function will return a tibble with as many rows as the length of coin_ids and the following columns:

  • coin_id (character): coin IDs, ordered by market_cap (see below);

  • symbol (character): symbol of the coin;

  • name (character): common name of the coin;

  • vs_currency (character): same as the argument vs_currency;

  • last_updated_at (POSIXct, UTC time zone): timestamp of the last update;

  • current_price (double): current price (as of last_updated_at) expressed in vs_currency;

  • market_cap (double): current market capitalisation;

  • market_cap_rank (integer): current rank of the coin in terms of its market capitalisation;

  • fully_diluted_valuation (double): fully diluted valuation of the coin's project;

  • total_volume (double): total trading volume in the last 24 hours;

  • high_24h (double): max price recorded in the last 24 hours;

  • low_24h (double): min price recorded in the last 24 hours;

  • price_change_24h (double): price change as compared to 24 hours ago;

  • price_change_percentage_24h (double): percentage change of the price as compared to 24 hours ago;

  • market_cap_change_24h (double): market cap change as compared to 24 hours ago; market_cap_change_percentage_24h (double): percentage change of the market cap as compared to 24 hours ago;

  • circulating_supply (double): coin supply currently in circulation;

  • total_supply (double): total supply that can potentially be circulated;

  • max_supply (double): max possible supply;

  • ath (double): all-time high price;

  • ath_change_percentage (double): percentage change of the all-time high price compared to the current price;

  • ath_date (POSIXct, UTC time zone): timestamp of when the all-time high price was recorded;

  • atl (double): all-time low price;

  • atl_change_percentage (double): percentage change of the all-time low price compared to the current price;

  • atl_date (POSIXct, UTC timezone): timestamp of when the all-time low price was recorded;

  • price_change_percentage_<time>_in_currency: columns containing the percentage change in price as compared to various points in the past (in particular, 1 hour, 24 hours, 7 days, 14 days, 30 days, 200 days, and 1 year).

If no data can be retrieved (e.g., because of going over the API rate limit or mis-specifying the query parameters), the function returns nothing (NULL).

Details

If no data can be retrieved (e.g., because of a misspecified query parameter), nothing (NULL) will be returned.

This function is based on the public CoinGecko API, which has a rate limit of 10-30 calls per minute. Please keep this limit in mind when developing your applications.

Examples

if (FALSE) {
r <- current_market(
  coin_ids = c("bitcoin", "ethereum", "cardano"),
  vs_currency = "usd"
)
print(r)
}