使用雅虎!没有 quantmod 函数的数据库
Using Yahoo! database without quantmod functions
我要解决的问题是使用 Yahoo! 通过 R 循环字符串。金融 api。这会生成一堆数据框文件,但如果我可以将其转换为 xts
,那就太棒了。但是,xts
部分并不重要。
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")
我知道 ("") 引号中不能有符号,但这是出于逻辑目的。
p.s。对于这种情况,我不是故意使用 quantmod
函数。
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")))
如果要直接读取文件:
jj<- lapply(x,function(i) read.csv(paste0("http://ichart.finance.yahoo.com/table.csv?s=",i)))
我要解决的问题是使用 Yahoo! 通过 R 循环字符串。金融 api。这会生成一堆数据框文件,但如果我可以将其转换为 xts
,那就太棒了。但是,xts
部分并不重要。
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")
我知道 ("") 引号中不能有符号,但这是出于逻辑目的。
p.s。对于这种情况,我不是故意使用 quantmod
函数。
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")))
如果要直接读取文件:
jj<- lapply(x,function(i) read.csv(paste0("http://ichart.finance.yahoo.com/table.csv?s=",i)))