R/q_price_single.R

Defines functions q_price_single

q_price_single <- function(ticker,
                        start_date = NULL,
                        end_date = NULL,
                        frequency = NULL){

if(is.null(start_date)){
  start_date = "2000-12-31"
}

  dat <- q_construct_url(ticker = ticker,
                          start_date = start_date,
                          end_date = end_date,
                          frequency = frequency) %>%
    jsonlite::fromJSON() %>%
    as_tibble() %>%
    mutate(date = as.Date(date),
           q_ticker = ticker) %>%
    mutate_at(c("close",
                "high",
                "low",
                "open",
                "volume",
                "adjClose",
                "adjHigh",
                "adjLow",
                "adjOpen",
                "adjVolume",
                "divCash","splitFactor"),
              as.double) %>%
    mutate_at(c("close",
                "high",
                "low",
                "open",
                "volume",
                "adjClose",
                "adjHigh",
                "adjLow",
                "adjOpen",
                "adjVolume",
                "divCash","splitFactor"),
              round,digits = 2) %>%
    dplyr::select(q_ticker,everything()) %>%
    dplyr::filter(date <= Sys.Date())

  dat
}
zac-garland/equityresearch documentation built on July 30, 2020, 2:29 p.m.