#' @title Stock Quote
#' @description Get current stock quote
#'
#' @param symbol Stock ticker
#'
#' @importFrom purrr set_names
#' @importFrom dplyr bind_rows mutate select
#' @importFrom lubridate as_datetime
#'
#' @return
#' @export
#'
#' @examples
#' stock_quote('NVDA')
stock_quote <- function(symbol, ...){
url <- finnhub_endpoint('stock_quote')
df <- retry_get(url,
query = list(token = finnhub_key(),
symbol = symbol))
df %>%
dplyr::bind_rows() %>%
dplyr::mutate(date = lubridate::as_datetime(t, tz = finnhub_timezone),
symbol = symbol) %>%
purrr::set_names('close', 'high', 'low', 'open', 'previous_close',
'unixtime', 'date', 'symbol') %>%
dplyr::select(symbol, date, open, high, low, close, previous_close, unixtime)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.