#' @title Forex Rates
#' @description Get currency exchange rates
#'
#' @param base_currency Select base currency - USD, EUR, etc
#'
#' @importFrom purrr set_names
#' @importFrom dplyr bind_cols mutate select everything
#' @importFrom lubridate now
#'
#' @return
#' @export
#'
#' @examples
#' forex_rates('USD')
#' forex_rates('EUR')
forex_rates <- function(base_currency = 'USD', ...){
url <- finnhub_endpoint('forex_rates')
df <- retry_get(url,
query = list(token = finnhub_key(),
base = base_currency)
)
df %>%
dplyr::bind_cols() %>%
purrr::set_names(tolower) %>%
dplyr::mutate(query_date = lubridate::now(tz = finnhub_timezone)) %>%
dplyr::select(base, query_date, dplyr::everything())
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.