Retrieve exchange rates or convert amounts between currencies
Source:R/fx_convert.R, R/fx_get.R
fx_get.RdThese functions are used to convert amounts from one currency to another, or to directly return the exchange rates between two specified currencies.
Arguments
- amount
Numeric; the amount of money to convert from the
fromcurrency to thetocurrency. Only used infx_convert().- from
The ISO currency code (as a character string) for the base currency.
- to
The ISO currency code (as a character string) for the target currency.
- fxdate
The date for which to retrieve exchange rates, in "YYYY-MM-DD" format.
- bank
A character string specifying the source of the exchange rate data. Default is "ecb" (European Central Bank).
- ...
Reserved
- .interpolate
If a weekend date is requested, should the previous days rate be returned. If this is false, a weekend date will result in an error.
Value
For fx_convert(), the converted amount in the to currency.
fx_convert() relies directly on the exchange rates retrieved using
fx_get(), and simply multiplies the amount with the rates that fx_get()
return.
For fx_get(), a numeric value representing the exchange rate from
the from currency to the to currency on the specified fxdate. The
exchange rate betweenfrom and to, given in a way that to convert, from
from to to one would multiply by the exchange rate. This means that the
function may not always give the expected value for well-known currency
pairs that are always quoted in the same direction.