Retrieve current conversion rate between two currencies as well as historical rates.
Usage
currency_converter(
from = "EUR",
to = "USD",
start = NULL,
end = NULL,
period = "ytd",
interval = "1d"
)
Arguments
- from
Currency to convert from.
- to
Currency to convert to.
- start
Specific starting date.
String
ordate
object inyyyy-mm-dd
format.- end
Specific ending date.
String
ordate
object inyyyy-mm-dd
format.- period
Length of time. Defaults to
'ytd'
Valid values are:'1d'
'5d'
'1mo'
'3mo'
'6mo'
'1y'
'2y'
'5y'
'10y'
'ytd'
'max'
- interval
Time between data points. Defaults to
'1d'
Valid values are:'1h'
'1d'
'5d'
'1wk'
'1mo'
'3mo'
Examples
# \donttest{
currency_converter('GBP', 'USD', '2022-07-01', '2022-07-10')
#> date high low open close volume adj_close
#> 1 2022-06-30 23:00:00 1.216205 1.198064 1.215998 1.216086 0 1.216086
#> 2 2022-07-03 23:00:00 1.216515 1.208634 1.210580 1.210273 0 1.210273
#> 3 2022-07-04 23:00:00 1.212606 1.190051 1.211402 1.211446 0 1.211446
#> 4 2022-07-05 23:00:00 1.198638 1.187761 1.194957 1.194914 0 1.194914
#> 5 2022-07-06 23:00:00 1.202183 1.191001 1.191895 1.192321 0 1.192321
#> 6 2022-07-07 23:00:00 1.205531 1.192194 1.203196 1.202805 0 1.202805
currency_converter('GBP', 'USD', period = '1mo', interval = '1d')
#> Error in `$<-.data.frame`(`*tmp*`, "adj_close", value = c(1.25297582149506, 1.25788068771362, 1.25490987300873, 1.25192487239838, 1.23802220821381, 1.2426837682724, 1.25109469890594, 1.24778521060944, 1.2359870672226, 1.22993671894073, 1.22049450874329, 1.22333145141602, 1.2213442325592, 1.22433483600616, 1.22369062900543, 1.21710026264191, 1.23313677310944, 1.2335399389267, 1.23142087459564, 1.235391497612, 1.24440014362335)): replacement has 21 rows, data has 22
# }