如何从例如使用R获取公司描述,统计数据。雅虎财经?

时间:2013-12-06 16:31:03

标签: r yahoo finance quantmod

我正在寻找方法使用R获取雅虎财经(或其他金融网站)的公司描述,关键统计数据,主席名称,例如包quantmod。

有大量信息如何获得当前和历史价格等,但这不是我想要的。

最好的,

2 个答案:

答案 0 :(得分:0)

此R套餐不支持亚洲交易所的查询。问题似乎与底层的Yahoo API有关。

答案 1 :(得分:0)

您可以使用Intrinio's API获取该功能。他们的data tag directory允许您查找所需的标签,在您的情况下,“long_description”和“ceo”将为您提供所需的数据:

#Install httr, which you need to request data via API
install.packages("httr")
require("httr")

#Create variables for your usename and password, get those at intrinio.com/login
username <- "Your_API_Username"
password <- "Your_API_Password"

#Making an api call for roic. This puts together the different parts of the API call

base <- "https://api.intrinio.com/"
endpoint <- "data_point"
stock <- "T"
item1 <- "long_description"
item2 <- "ceo"

#Pasting them together to make the API call
call1 <- paste(base,endpoint,"?","ticker","=", stock, "&","item","=",item1, sep="")
call2 <- paste(base,endpoint,"?","ticker","=", stock, "&","item","=",item2, sep="")


#Now we use the API call to request the data from Intrinio's database

ATT_description <- GET(call1, authenticate(username,password, type = "basic"))
ATT_CEO <- GET(call2, authenticate(username,password, type = "basic"))

#That gives us the ROIC value, but it isn't in a good format so we parse it

test1 <- unlist(content(ATT_description,"parsed"))
test2 <- unlist(content(ATT_CEO,"parsed"))

#Then make your data frame:

df1 <- data.frame(test1)

df2 <- data.frame(test2)

#From here you can rbind or cbind, and create loops to get the same data for many tickers

您可以获取API密钥here。完整的API文档here。这就是首席执行官数据框架的样子:

CEO of ATT

Long Description of ATT