0

Hi I am trying to download data of multiple stocks from yahoo finance using the quantmod package in R. My method is to create a function using the getSymbols function, and use lapply to apply this to a vector of ticker symbols. Below is my code

get_data <- function(x){getSymbols(x, 
                                   from = "2017-01-01",
                                   to = "2021-03-15",
                                   auto.assign = FALSE)}

tickers <- c("AAPL","GOOG","FB","TSLA")

mydata <- lapply(tickers,get_data)

running the last step does not give me the data, just a list with all the tickers stored as characters. Would appreciate if anyone could tell me where my code is going wrong. Cheers

Yoseph
  • 1
  • 1
  • It works for me. – G. Grothendieck Mar 23 '21 at 14:28
  • It works also for me, what is your output of `mydata` ? – Basti Mar 23 '21 at 14:29
  • what kind of output do you get? my output is a list with the ticker symbols stored as character values, instead of xts objects which i would expect to get.. – Yoseph Mar 23 '21 at 14:29
  • `mydata` [[1]] AAPL.Open AAPL.High AAPL.Low AAPL.Close AAPL.Volume AAPL.Adjusted 2017-01-03 28.9500 29.0825 28.6900 29.0375 115127600 27.45994 2017-01-04 28.9625 29.1275 28.9375 29.0050 84472400 27.42920 2017-01-05 28.9800 29.2150 28.9525 29.1525 88774400 27.56869 – Basti Mar 23 '21 at 14:31
  • Can you update with your output of `mydata` ? – Basti Mar 23 '21 at 14:34
  • This is weird..your output is what i would expect to get. Thanks anyways. I will try again after restarting – Yoseph Mar 23 '21 at 14:35
  • So this is my output. > data[[1]] [1] "AAPL" – Yoseph Mar 23 '21 at 14:43
  • Maybe you can try update quantmod package but this looks very strange and i really don't know where it could come from – Basti Mar 23 '21 at 15:03

0 Answers0