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")
)

Arguments

...

character vectors indicating tickers (should be valid in Yahoo Finance).

start

an object of Date class specifying the first date of the observed time period.

end

an object of Date class specifying the last date of the observed time period.

quote

a character indicating the type of the price: "Open" (default) or "Close".

retclass

a character specifying the return class: "list" (default), "zoo" or "data.frame".

Value

Prices of securities as "list", "zoo", or "data.frame".

Details

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.

See also

Examples

## 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)