Downloading Yahoo stock prices in R

后端 未结 8 675
野趣味
野趣味 2020-12-12 13:46

This is a newbie question in R. I am downloading yahoo finance monthly stock price data using R where the ticker names are read from a text file. I am using a loop to read

8条回答
  •  甜味超标
    2020-12-12 14:27

    Maybe give the BatchGetSymbols library a try. What I like about it over quantmod is that you can specify a time period for your data.

    library(BatchGetSymbols)
    
    # set dates
    first.date <- Sys.Date() - 60
    last.date <- Sys.Date()
    freq.data <- 'daily'
    # set tickers
    tickers <- c('FB','MMM','PETR4.SA','abcdef')
    
    l.out <- BatchGetSymbols(tickers = tickers, 
                             first.date = first.date,
                             last.date = last.date, 
                             freq.data = freq.data,
                             cache.folder = file.path(tempdir(), 
                                                      'BGS_Cache') ) # cache in tempdir()
    

提交回复
热议问题