Let's assume that you would like to get the data from a lot of equities (>100) from Yahoo and Alpha Vantage (AV) since 2000.
I was wondering if somebody did investigate any of the following 2 questions:
1) What is faster when using getSymbols()? To get each equity separate or all together in one call to getSymbols()?
2) What would be less error prone? Separate calls or one call with all the equities?
Thanks for any help or suggestion in any of the 2 points.
HL
getSymbols is a wrapper to load data from various sources, local or remote. Data is fetched via one of the available getSymbols methods and either saved in the env specified - the parent. frame() by default -- or returned to the caller.
“The quantmod package for R is designed to assist the quantitative trader in the development, testing, and deployment of statistically based trading models.” It is a rapid prototyping environment where enthusiasts can explore various technical indicators with minimum effort.
BatchGetSymbols is a R package for large-scale download of financial data from Yahoo Finance. Based on a set of tickers and date ranges, the package will download and organize the financial data in the tidy/long format.
You can install it by typing the command install. packages("quantmod") in your R console. The prices downloaded in by using quantmod are xts zoo objects. For our calculations we will use tidyquant package which downloads prices in a tidy format as a tibble .
Why not something like the following which will drag in the whole SP500, then you can just filter by ticker
.
library(BatchGetSymbols)
first.date <- Sys.Date()-365
last.date <- Sys.Date()
df.SP500 <- GetSP500Stocks()
tickers <- df.SP500$tickers
l.out <- BatchGetSymbols(tickers = tickers,
first.date = first.date,
last.date = last.date)
print(l.out$df.control)
print(l.out$df.tickers)
df <- l.out$df.control
df2 <- l.out$df.tickers
library(tidyquant)
df2 %>%
filter(ticker == "GOOG") %>%
ggplot(aes(x = ref.date, y = price.close)) +
geom_line() +
labs(title = "GOOG Line Chart", y = "Closing Price", x = "") +
theme_tq()
I am sure tidyquant
has a function to grab the whole SP500 also.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With