Retrieves the current TRX price and market data against other currencies

get_current_trx_price(
  vs_currencies = "usd",
  include_market_cap = FALSE,
  include_24h_vol = FALSE,
  include_24h_change = FALSE,
  max_attempts = 3L
)

Arguments

vs_currencies

(character): a vector with names of the base currencies to benchmark TRX against, e.g. c("usd", "eur", "btc"). An up-to-date list of supported currencies (both fiat and cryptocurrencies) can be retrieved with the get_supported_coingecko_currencies() function. If vs_currencies contains at least one unsupported currency, the call will fail with the respective error message.

include_market_cap

(boolean, defaults to FALSE): whether to return the market cap information.

include_24h_vol

(boolean, defaults to FALSE): whether to return the trading volume for the last 24 hours.

include_24h_change

(boolean, defaults to FALSE): whether to return the price percentage change compared to 24 hours ago.

max_attempts

(integer, positive): specifies the maximum number of additional attempts to call a URL if the first attempt fails (i.e. its call status is different from 200). Additional attempts are implemented with an exponential backoff. Defaults to 3.

Value

A tibble with as many rows as the length of vs_currencies and at at least 3 columns: trx_price (double), vs_currency (character), and last_updated_at (POSIXct, UTC timezone). If the boolean arguments of this function are all TRUE, then the resultant tibble will include additional three columns: market_cap (double), vol_24h (double) and price_percent_change_24h (double).

Details

This function is based on the public CoinGecko API, which has a limit of 100 calls per minute. Please keep this limit in mind when developing your code.

Examples

r <- get_current_trx_price(vs_currencies = c("usd", "eur")) print(r)
#> # A tibble: 2 x 3 #> trx_price vs_currency last_updated_at #> <dbl> <chr> <dttm> #> 1 0.0603 usd 2021-07-12 22:03:53 #> 2 0.0509 eur 2021-07-12 22:03:53