Coin-specific market data for a given historical date

coin_history_snapshot(coin_id, date, vs_currencies = "usd", max_attempts = 3)

Arguments

coin_id

(character): ID of the coin of interest or a vector with several IDs. The maximum number of coins that can be queried simultaneously is 5. An up-to-date list of supported coins and their IDs can be retrieved with the supported_coins() function.

date

(Date): date of interest. If no data exist for the requested date, nothing (NULL) will be returned.

vs_currencies

(character): a vector with names of the reference currencies to express the price in, e.g. c("usd", "eur", "btc"). An up-to-date list of supported vs_currencies (both fiat and cryptocurrencies) can be obtained with the supported_currencies() function. If vs_currencies contains at least one unsupported currency, 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, the function returns a tibble with the following columns:

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

  • symbol (character): symbol of the coin;

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

  • date (Date): same as the argument date;

  • vs_currency (character): reference currency, in which the price is expressed (ordered alphabetically);

  • price (double): price of the coin;

  • market_cap (double): market capitalisation of the coin;

  • total_volume (double): total trading volume recorded on that date.

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

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 <- coin_history_snapshot(
  coin_id = "cardano",
  date = as.Date("2021-05-01"),
  vs_currencies = c("usd", "eth")
)
print(r)
}