Skip to contents

This function lets the user download historical currency exchange rate between two currencies.

Usage

get_currency(
  currency_pair,
  from = Sys.Date() - 99,
  to = Sys.Date(),
  fill = FALSE,
  ...
)

Arguments

currency_pair

Character. Which currency exchange do you wish to get the history from? i.e, USD/COP, EUR/USD...

from

Date. From date

to

Date. To date

fill

Boolean. Fill weekends and non-quoted dates with previous values?

...

Additional parameters.

Value

data.frame. Result of fetching online data for currency_pair

grouped by date.

Examples

# \donttest{
# For today (or any one single date)
get_currency("USD/COP", from = Sys.Date())
#>         date    rate
#> 1 2024-04-22 3904.57
# For multiple dates
get_currency("EUR/USD", from = Sys.Date() - 7, fill = TRUE)
#>         date     rate
#> 1 2024-04-16 1.062146
#> 2 2024-04-17 1.066940
#> 3 2024-04-18 1.064419
#> 4 2024-04-19 1.064419
#> 5 2024-04-20 1.064419
#> 6 2024-04-21 1.065780
#> 7 2024-04-22 1.065780
#> 8 2024-04-23 1.065644
# }