如何获得所有雅虎金融共同基金在R?

如何获得所有雅虎金融共同基金在R?,r,quantmod,yahoo-finance,R,Quantmod,Yahoo Finance,我想把所有通过Yahoo Finance获得的共同基金列表输入R。TTR包中有一个stockSymbols函数,但它似乎没有获得共同基金 谢谢,我不认为雅虎提供了他们所有共同基金数据的列表 (同样,它们也没有提供所涵盖股票的清单)。 您可以从评论中提到的网站下载该列表, 通过所有的资金循环, 从Yahoo检索相应的“配置文件”页面, 并提取所需的信息——“类别”字段 似乎是最接近你想要的“部门和行业”的东西 # Read the list of funds # I assume the file

我想把所有通过Yahoo Finance获得的共同基金列表输入R。TTR包中有一个stockSymbols函数,但它似乎没有获得共同基金


谢谢,

我不认为雅虎提供了他们所有共同基金数据的列表 (同样,它们也没有提供所涵盖股票的清单)。 您可以从评论中提到的网站下载该列表, 通过所有的资金循环, 从Yahoo检索相应的“配置文件”页面, 并提取所需的信息——“类别”字段 似乎是最接近你想要的“部门和行业”的东西

# Read the list of funds
# I assume the file was downloaded manually from 
#   http://www.eoddata.com/Data/symbollist.aspx?e=USMF
# This requires registration (free).
d <- read.delim( "USMF.txt", stringsAsFactors = FALSE )

# Retrieve the profile page, for each of the funds.
# It takes 1 second for each, and there are 24,000 of them:
# this may take more than 6 hours.
library(RCurl)
library(stringr)
d$Category <- ""
for( i in seq_len(nrow(d)) ) {
  try({
    url <- paste0("http://uk.finance.yahoo.com/q/pr?s=", d$Symbol[i])
    cat( url, " " )
    profile <- getURL(url)
    row  <- str_extract(profile, "Category.*?</tr>")
    cell <- str_extract(row,     "<td.*</td>"      )
    d$Category[i] <- str_replace_all( cell, "<.*?>", "" )
    cat( d$Category[i], "\n" )
  })
}
head(d)
#阅读基金清单
#我假设该文件是从手动下载的
#   http://www.eoddata.com/Data/symbollist.aspx?e=USMF
#这需要注册(免费)。

d
stockSymbol
功能从纳斯达克网站(也列出了一些其他交易所)检索股票列表:如果你知道一个类似的网页列出了你想要的资产,你可以简单地检索和解析它。有一个网站有一个完整的共同基金列表:eoddata.com供感兴趣的人使用。我的问题是,我需要按行业和行业获得共同基金。雅虎财经API最有可能做到这一点