#' @title Stock Splits
#' @description Get stock split history
#'
#' @param symbol Stock ticker
#' @param from Begin date
#' @param to End date
#'
#' @importFrom purrr set_names
#' @importFrom dplyr mutate
#' @importFrom lubridate ymd today
#'
#' @return
#' @export
#'
#' @examples
#' stock_splits('AAPL')
#' stock_splits('AAPL', from = lubridate::today() - 720)
stock_splits <- function(symbol,
from = '1900-01-01',
to = lubridate::today(),
...){
url <- finnhub_endpoint('stock_splits')
df <- retry_get(url,
query = list(token = finnhub_key(),
symbol = symbol,
from = from,
to = to))
df %>%
dplyr::mutate(date = lubridate::ymd(date, tz = finnhub_timezone)) %>%
purrr::set_names(c('symbol', 'date', 'from_factor', 'to_factor'))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.