【问题标题】:Cant connect to yahoo with getSymbols in quantmod无法使用 quantmod 中的 getSymbols 连接到雅虎
【发布时间】:2017-07-22 18:00:37
【问题描述】:

我写:

library(quantmod)  
getSymbols("AAPL")

我明白了:

 Error in curl::curl_download(cu, tmp, handle = h) : 
   Couldn't connect to server

我的sessionInfo

> sessionInfo()
R version 3.4.1 (2017-06-30)



attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] quantmod_0.4-10 TTR_0.23-1      xts_0.9-7       zoo_1.8-0      

loaded via a namespace (and not attached):
[1] compiler_3.4.1  tools_3.4.1     curl_2.7        grid_3.4.1      lattice_0.20-35
>

有什么想法吗?

【问题讨论】:

  • 尝试再运行几次
  • 我尝试重新运行几次,仍然得到相同的答案...有什么建议吗?
  • 错误提示curl 无法连接到互联网。运行此命令并将其输出编辑到您的问题中:w <- curl::curl_fetch_memory("https://finance.yahoo.com", curl::new_handle(verbose = TRUE)).
  • 我得到:重建 URL 到:finance.yahoo.com * 不支持名称查找超时 * 正在尝试 87.248.118.23... * TCP_NODELAY 设置 * 4976 毫秒连接时间后,继续! * 连接到 87.248.118.23 端口 443 失败:超时 * 正在尝试 87.248.118.22 ... * TCP_NODELAY 设置 * 在 2359 毫秒连接时间后,继续! * 连接到 87.248.118.22 端口 443 失败:超时 * 连接到 Finance.yahoo.com 端口 443 失败:超时 * 关闭连接 0 curl::curl_fetch_memory("finance.yahoo.com", curl::new_handle(verbose) 中的错误= TRUE)) : 无法连接到服务
  • 可能是您的系统管理员阻止了 URL 或代理。不过不确定。

标签: r quantmod


【解决方案1】:

Yahoo! Finance API has been officially discontinued.

您可能想使用其他来源。对于谷歌:getSymbols("AAPL", src = "google")


您可能还想试试quandl,它从许多发布者那里获取数据。 您还可以将数据存储在索引为 POSIXct 的 xts 对象中,因此您仍然可以使用 quantmod 绘制它:

Quandl("SOURCE/SYMBOL", type="xts")

如果您计划每天进行 50 次以上的调用,则需要一个免费的 API 密钥,该密钥对调用频率或数量没有任何限制。

【讨论】:

    猜你喜欢
    • 2022-11-01
    • 1970-01-01
    • 2018-05-22
    • 1970-01-01
    • 2016-06-02
    • 2020-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多