【问题标题】:I want to know why I cannot use this function?我想知道为什么我不能使用这个功能?
【发布时间】:2017-09-13 17:23:58
【问题描述】:
yahoo<-function(sym,current = TRUE, a=0,b=1,c=2000,d,e,f,g="d")
{
  if(current){
  f<-as.numeric(substr(as.character(Sys.time()),start = 1,stop = 4))
  d<-as.numeric(substr(as.character(Sys.time()),start = 6,stop = 7))-1
  e<-as.numeric(substr(as.character(Sys.time()),start = 9,stop = 10))
}
  require(data.table)
  tryCatch(
  suppressWarnings(
  fread(paste0("http://ichart.yahoo.com/table.csv",
                   "?s=",sym,
                   "&a=",a,
                   "&b=",b,
                   "&c=",c,
                   "&d=",d,
                   "&e=",e,
                   "&f=",f,
                   "&g=",g,
                   "&ignore=.csv"),sep=",")),
    error = function(e) NULL
  )
}

当我运行 Google

正在尝试 URL 'http://ichart.yahoo.com/table.csv?s=GOOG&a=0&b=1&c=2000&d=8&e=13&f=2017&g=d&ignore=.csv' 内容类型'text/html; charset=utf-8' 长度未知 已下载 1078 字节

那么如何更改该功能使其工作?

【问题讨论】:

  • 这是什么语言?请编辑您的问题以将其作为标签包含在内。
  • 这似乎是R。函数有什么问题?你得到了 1078 字节,这不是预期的吗?

标签: function api yahoo


【解决方案1】:

此代码无效,因为the Yahoo Finance web service which you're trying to access was discontinued in May 2017。您需要为这些数据找到另一个来源。

【讨论】:

    猜你喜欢
    • 2016-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多