Using Yahoo! database without quantmod functions

204 views Asked by At

The problem I am trying to solve is looping a string through R with Yahoo! finance api. This would make a bunch of data frame files, but if I could convert it into xts, that would be awesome. However, the xts part is not as important.

library(quantmod)
DB <- quantmod:::DDB_Yahoo()       
for (i in length(DB$db)){
  symbols <- DB$db[i] #symbols are c('AAIT', 'AAL', 'AAME', ...   #Thousands Essentially 
URL <- "http://ichart.finance.yahoo.com/table.csv?s=symbols"
dat[i] <- read.csv(URL[i])
dat$Date <- as.Date(dat$Date, "%Y-%m-%d")

I know that we can't have symbols in ("") quotations, but it is for logical purposes.

p.s. For this instance, I am not using quantmod functions on purpose.

1

There are 1 answers

6
user227710 On BEST ANSWER
x<-c('AAIT', 'AAL', 'AAME')
kk<-lapply(x,function(i) download.file(paste0("http://ichart.finance.yahoo.com/table.csv?s=",i),paste0(i,".csv")))

if you want to directly read the file:

jj<- lapply(x,function(i) read.csv(paste0("http://ichart.finance.yahoo.com/table.csv?s=",i)))