#' @title Index Constituents
#' @description Get index constituents
#'
#' @param index Index ticker - ^GSPC, ^DJI
#'
#' @importFrom tibble tibble
#' @importFrom dplyr mutate
#' @importFrom lubridate now
#'
#' @return
#' @export
#'
#' @examples
#' indices_constituents('^GSPC')
#' indices_constituents('^DJI')
indices_constituents <- function(index, ...){
url <- finnhub_endpoint('indices_constituents')
df <- retry_get(url,
query = list(token = finnhub_key(),
symbol = index))
tibble::tibble(index, constituents = df$constituents) %>%
dplyr::mutate(query_date = lubridate::now())
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.