View source: R/get_prices_from_tickers.R
get_prices_from_tickers | R Documentation |
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: |
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
.
Prices of securities as "list"
, "zoo"
, or
"data.frame"
.
getSymbols
## Download historical prices of seven companies' stocks:
## Not run:
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")
## End(Not run)
## The result of the above code is stored in:
data(prices)
## Download historical prices of S&P 500 index:
## Not run:
prices_indx <- get_prices_from_tickers("^GSPC",
start = as.Date("2019-04-01"),
end = as.Date("2020-04-01"),
quote = "Close",
retclass = "zoo")
## End(Not run)
## The result of the above code is stored in:
data(prices_indx)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.