Retrieves TRX market data for previous days

get_trx_market_data_for_last_n_days(
  vs_currency = "usd",
  days,
  interval = NULL,
  max_attempts = 3L
)

Arguments

vs_currency

(character): name of the base currency to benchmark TRX against (usd by default). An up-to-date list of supported currencies (both fiat and cryptocurrencies) can be retrieved with the get_supported_coingecko_currencies() function. If an unsupported vs_currency is requested, the call will fail with the respective error message.

days

(numeric or "max"): number of days to look back. If the requested number of days covers dates before 2017-11-09, the retrived data will be clipped at 2017-11-09 (the beginning of history for TRX). If days = "max", the entire available history will be retrieved. Depending on the value of days, the time interval used to present the data will differ - see "Details".

interval

(character or NULL): time interval to present the data. The only currently supported interval is daily. Defaults to NULL.

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 the following columns:

  • timestamp (POSIXct);

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

  • price (double): TRX price, as of datetime;

  • total_trading_vol (double): a 24 h rolling-window trading volume, as of datetime;

  • market_cap (double): TRX market cap, as of datetime.

Details

If days = 1 and interval = NULL, the data will be presented for every few minutes (typically 3-8 minutes). If days is between 2 and 90 (inclusive) and interval = NULL, an (approximately) hourly time step will be used. Daily data are used for days above 90. If interval = "daily", daily data will be used irrespective of the value of days.

Examples

r <- get_trx_market_data_for_last_n_days( vs_currency = "gbp", days = 30 ) print(r)
#> # A tibble: 721 x 5 #> timestamp vs_currency price total_trading_vol market_cap #> <dttm> <chr> <dbl> <dbl> <dbl> #> 1 2021-06-12 22:01:14 gbp 0.0487 903566765. 3487634163. #> 2 2021-06-12 23:01:11 gbp 0.0486 894340986. 3478379281. #> 3 2021-06-13 00:01:41 gbp 0.0484 872891643. 3485310799. #> 4 2021-06-13 01:00:37 gbp 0.0487 866839417. 3471402650. #> 5 2021-06-13 02:06:54 gbp 0.0491 854218052. 3512810468. #> 6 2021-06-13 03:01:45 gbp 0.0486 825231596. 3487461917. #> 7 2021-06-13 04:03:45 gbp 0.0478 799819340. 3443169652. #> 8 2021-06-13 05:02:57 gbp 0.0479 794260346. 3414856192. #> 9 2021-06-13 06:04:21 gbp 0.0476 792537509. 3413766509. #> 10 2021-06-13 07:06:56 gbp 0.0477 803574787. 3418660686. #> # … with 711 more rows