无法使用 R 中的 Quantmod 从雅虎财经下载数据 [英] Can't download data from Yahoo Finance using Quantmod in R

查看:79
本文介绍了无法使用 R 中的 Quantmod 从雅虎财经下载数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码从 Yahoo 下载数据:

I'm trying to download data from Yahoo using this code:

library(quantmod)
getSymbols("WOW", auto.assign=F)

这在过去的任何场合都对我有用,除了现在,在我的小组作业到期前 5 天.

This has worked for me in the past in every occasion except now, 5 days before my group assignment is due.

除了现在我收到这个错误:

Except now I receive this error:

Error in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m,  : cannot download all files
In addition: Warning message:
In download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m,  :
  URL 'https://ichart.finance.yahoo.com/table.csv?
s=WOW&a=0&b=01&c=2007&d=4&e=17&f=2017&g=d&q=q&y=0&z=WOW&x=.csv': status was 
'502 Bad Gateway'

推荐答案

价格历史 csv URL 似乎已更改

The price history csv URL's appear to have changed

旧的https://chart.finance.yahoo.com/table.csv?s=AAPL&a=2&b=17&c=2017&d=3&e=17&f=2017&g=d&ignore=.csv

新:https://query1.finance.yahoo.com/v7/finance/download/AAPL?period1=1492438581&period2=1495030581&interval=1d&events=history&crumb=XXXXXXX

新版本附加了一个crumb"字段,它似乎反映了用户浏览器中的 cookie 信息.他们似乎有意阻止自动下载价格历史记录并强制查询提供信息以验证网络浏览器中的 cookie

The new version appends a "crumb" field which appears to reflect cookie information in the user's browser. It seems they are intentionally blocking automated downloads of price histories and forcing queries to provide information to validate cookies in a web browser

这篇关于无法使用 R 中的 Quantmod 从雅虎财经下载数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆