Cannot download Brent Crude oil data from yahoo finance R

本小妞迷上赌 提交于 2019-12-24 12:25:04

问题


I am very new to R, so this question might seem very easy for most of you. I am trying to download brent oil price from yahoo finance, but R is giving me an error. So here's what I did:

getSymbols(Symbols = "BZK16.NYM",from="2015-11-02",to="2016-03-10",src="yahoo")

and R gives me this:

Error in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, : cannot open URL 'http://ichart.finance.yahoo.com/table.csv?s=BZK16.NYM&a=10&b=02&c=2015&d=2&e=10&f=2016&g=d&q=q&y=0&z=BZK16.NYM&x=.csv' In addition: Warning message: In download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, : cannot open: HTTP status was '404 Not Found'

Also I tried to download data from russian source: Finam.ru:

getSymbols("BR",from="2015-11-02",to="2016-03-10",src="Finam")

And R gives me just:

[1] "BR"

I don't know if I am doing something wrong or is it my computer/R problem?


回答1:


BZK16.NYM is the Brent crude oil price at the NYMEX. Yahoo does not provide this data as far as I know, but you can obtain it from Quandl using the homonymous R package. The only difference is that the price provided by Quandl is established at the Chicago Mercantile Exchange, and not at the New York Mercantile Exchange.

To load this time series data using R, try

library(Quandl)
BR <- Quandl("CME/BZK2016")
#> head(BR)
#        Date  Open  High   Low  Last Change Settle Volume Open Interest
#1 2016-03-11 40.25 41.02 40.03 40.32   0.34  40.39  22689         15498
#2 2016-03-10 40.84 41.00 39.65 40.30   1.02  40.05  28194         16081
#3 2016-03-09 39.52 41.24 39.40 40.84   1.42  41.07  29231         16117
#4 2016-03-08 40.84 41.48 39.31 39.52   1.19  39.65  35089         16606
#5 2016-03-07 38.99 41.04 38.88 40.73   2.12  40.84  33252         18177
#6 2016-03-04 36.96 38.98 36.83 38.94   1.65  38.72  32203         18575

Hope this helps.



来源:https://stackoverflow.com/questions/35973551/cannot-download-brent-crude-oil-data-from-yahoo-finance-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!