Exists() 和 getSymbols() 无法找到在 Yahoo 上列出的符号。

huangapple go评论105阅读模式
英文:

Exists() and getSymbols() can't find symbol listed in yahoo

问题

PRIO3F.SA在雅虎金融上列出,但在使用exists()函数时未找到任何内容。这是一个学校项目,使用这种方法找不到相当多的符号。quantmod(或者可能是雅虎金融)是否不是我最好的选择?

我尝试了多种不同的符号变体,仍然失败。

如果我尝试使用getSymbols()函数,会出现以下错误:

  1. > getSymbols("PRIO3F.SA", src = "yahoo", auto.assign = FALSE)
  2. Error in getSymbols.yahoo(Symbols = "PRIO3F.SA", env = <environment>, :
  3. Unable to import PRIO3F.SA”.
  4. attempt to set an attribute on NULL
英文:

For some reason, even though PRIO3F.SA is listed on yahoo(and also other symbols aside from this one specifically), when I do exists() it simply doesn't find anything.
This is for a school project and quite a few symbols can't be found with this method. Is quantmod (or maybe yahoo finance) not my best place to go to?

I've tried multiple different symbol variations and still failing.

  1. &gt; exists(&quot;PRIO3F.SA&quot;)
  2. [1] FALSE
  3. &gt; exists(&quot;PRIO3.SA&quot;)
  4. [1] FALSE
  5. &gt; exists(&quot;PRIO3F&quot;)
  6. [1] FALSE
  7. &gt; exists(&quot;PRIO3&quot;)
  8. [1] FALSE

If by any chance I try to use getSymbols() instead, this is what greets me:

  1. &gt; getSymbols(&quot;PRIO3F.SA&quot;, src = &quot;yahoo&quot;, auto.assign = FALSE)
  2. Error in getSymbols.yahoo(Symbols = &quot;PRIO3F.SA&quot;, env = &lt;environment&gt;, :
  3. Unable to import PRIO3F.SA”.
  4. attempt to set an attribute on NULL

答案1

得分: 2

Yahoo不为每个股票符号提供历史每日数据。这就是这种情况下的问题。

英文:

Yahoo does not provide historical daily data for every ticker symbol. That's the problem in this case.

Exists() 和 getSymbols() 无法找到在 Yahoo 上列出的符号。

答案2

得分: 1

由于我可以成功调用 getSymbols(&quot;MSFT&quot;,src=&quot;yahoo&quot;,auto.assign = FALSE),而 getSymbols(&quot;PRIO3F.SA&quot;,src=&quot;yahoo&quot;,auto.assign = FALSE) 失败(对我也是如此),这表明 API 可能已经发生了变化。我在调试 getSymbols.yahoo(内部函数)时发现自动生成的 URL 如下所示:

  1. yahoo.URL
  2. # [1] &quot;https://query2.finance.yahoo.com/v8/finance/chart/PRIO3F.SA?period1=1167609600&amp;period2=1688688000&amp;interval=1d&quot;

而在 Yahoo! 自己的财务页面中显示的 URL 则不同。在调试过程中,如果我将其替换为以下内容(在深度调试时):

  1. yahoo.URL &lt;- &quot;https://query1.finance.yahoo.com/v8/finance/chart/PRIO3F.SA?region=US&amp;lang=en-US&amp;includePrePost=false&amp;interval=2m&amp;useYfid=true&amp;range=1d&amp;corsDomain=finance.yahoo.com&amp;.tsrc=finance&quot;
  2. ## 用于比较的其他 URL...
  3. https://query2.finance.yahoo.com/v8/finance/chart/PRIO3F.SA?period1=1167609600&amp;period2=1688688000&amp;interval=1d
  4. https://query1.finance.yahoo.com/v8/finance/chart/PRIO3F.SA?region=US&amp;lang=en-US&amp;includePrePost=false&amp;interval=2m&amp;useYfid=true&amp;range=1d&amp;corsDomain=finance.yahoo.com&amp;.tsrc=finance

它可以正常工作。请注意,由 getSymbols.yahoo 生成的 URL 包括期间,而我在浏览器中嗅探到的 URL 则不包括。我确信这将是进一步调查的源头。

我建议您向作者提交一个 bug 报告,因为看起来 Yahoo! 可能已经更新了他们的 API 和/或收紧了他们的期望。可能是 CORS、我的请求来源国家或其他任何事情。

英文:

Since I can call getSymbols(&quot;MSFT&quot;,src=&quot;yahoo&quot;,auto.assign = FALSE) successfully while getSymbols(&quot;PRIO3F.SA&quot;,src=&quot;yahoo&quot;,auto.assign = FALSE) fails (for me as well), that suggests the API may have changed. I debugged the call to getSymbols.yahoo (internal) and it appears that the URL being generated automatically

  1. yahoo.URL
  2. # [1] &quot;https://query2.finance.yahoo.com/v8/finance/chart/PRIO3F.SA?period1=1167609600&amp;period2=1688688000&amp;interval=1d&quot;

and the URL shown within Yahoo!'s own finance page are different. While debugging, if I replace it with (while deep within debugging)

  1. yahoo.URL &lt;- &quot;https://query1.finance.yahoo.com/v8/finance/chart/PRIO3F.SA?region=US&amp;lang=en-US&amp;includePrePost=false&amp;interval=2m&amp;useYfid=true&amp;range=1d&amp;corsDomain=finance.yahoo.com&amp;.tsrc=finance&quot;
  2. ## for comparison ...
  3. https://query2.finance.yahoo.com/v8/finance/chart/PRIO3F.SA?period1=1167609600&period2=1688688000&interval=1d
  4. https://query1.finance.yahoo.com/v8/finance/chart/PRIO3F.SA?region=US&lang=en-US&includePrePost=false&interval=2m&useYfid=true&range=1d&corsDomain=finance.yahoo.com&.tsrc=finance

it works. Note that the url generated by getSymbols.yahoo includes the period whereas the url I sniffed in the browser does not. I'm sure this will be the source of some more investigation.

I suggest you submit a bug-report to the authors, since it appears Yahoo! may have updated their API and/or tightened their expectations. (Perhaps it's CORS or the source country of my request or any number of things.)

huangapple
  • 本文由 发表于 2023年7月7日 06:31:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/76632893.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定