R/ownership.R

Defines functions ownership

Documented in ownership

#' @title Investor ownership
#' @description Investor ownership in a company
#'  
#' @param symbol Ticker symbol
#' 
#' @importFrom purrr set_names
#' @importFrom dplyr mutate
#' @importFrom lubridate ymd
#' @importFrom tibble as_tibble
#' 
#' @return
#' @export
#' 
#' @examples
#' ownership('NVDA')
ownership <- function(symbol, limit = 50, ...){
  
  url <- finnhub_endpoint('investor_ownership')
  
  df <- retry_get(url, 
                  query = list(token = finnhub_key(),
                               symbol = symbol,
                               limit = limit)) 
  df %>% 
  .[['ownership']] %>%
  purrr::set_names(c('name', 'share', 'change', 'filing_date')) %>%
  dplyr::mutate(filing_date = lubridate::ymd(filing_date, tz = finnhub_timezone), 
                symbol = symbol) %>% 
    tibble::as_tibble()
}
threadingdata/finnhubr documentation built on Aug. 10, 2020, 12:48 a.m.