Returns daily Open or Close prices between start
and end
date for given tickers.
get_prices_from_tickers( ..., start, end, quote = c("Open", "Close"), retclass = c("list", "zoo", "data.frame") )
... | character vectors indicating tickers (should be valid in Yahoo Finance). |
---|---|
start | an object of |
end | an object of |
quote | a character indicating the type of the price: |
retclass | a character specifying the return class: |
Prices of securities as "list"
, "zoo"
, or
"data.frame"
.
This function uses the function getSymbols
form the quantmod
package. The provider is set automatically to Yahoo Finance. The function
returns the data in different class-containers: list of zoo
's,
zoo
, or data.frame
.
## Download historical prices of seven companies' stocks: if (FALSE) { library("magrittr") tickers <- c("AMZN", "ZM", "UBER", "NFLX", "SHOP", "FB", "UPWK") prices <- tickers %>% get_prices_from_tickers(start = as.Date("2019-04-01"), end = as.Date("2020-04-01"), quote = "Close", retclass = "zoo") } ## The result of the above code is stored in: data(prices) ## Download historical prices of S&P 500 index: if (FALSE) { prices_indx <- get_prices_from_tickers("^GSPC", start = as.Date("2019-04-01"), end = as.Date("2020-04-01"), quote = "Close", retclass = "zoo") } ## The result of the above code is stored in: data(prices_indx)