[R] HTTP status was '404 Not Found'

Joshua Ulrich josh.m.ulrich at gmail.com
Wed Mar 8 04:19:35 CET 2017


On Tue, Mar 7, 2017 at 2:52 AM, Allan Tanaka <allantanaka11 at yahoo.com> wrote:
> HiSo I tried running the p but i'm stuck as i get the following error:
> In download.file(url, destfile, method = method, quiet = quiet) :  cannot open URL 'http://chart.yahoo.com/table.csv?s=DJI&a=2&b=13&c=2012&d=2&e=07&f=2017&g=d&q=q&y=0&z=DJI&x=.csv': HTTP status was '404 Not Found'
>
> Here is the R code:
> library(vars)library(tawny)library(quantmod)library(MASS)library(stats)library(DEoptim)library(sn)library(SkewHyperbolic)library(tseries)symbols<-getSymbols(c("^GSPC", "^DJI"))endDate <- Sys.Date()startDate <- endDate - as.difftime(52*5, unit="weeks")quoteType <- "Close"p <- do.call(cbind, lapply(symbols, get.hist.quote, start=startDate, end=endDate,  quote=quoteType))
>
Please try to post *minimal* reproducible examples.  Only two packages
are needed to run your code.

library(quantmod)
library(tseries)

symbols<-getSymbols(c("^GSPC", "^DJI"))
endDate <- Sys.Date()
startDate <- endDate - as.difftime(52*5, unit="weeks")
quoteType <- "Close"
p <- do.call(cbind, lapply(symbols, get.hist.quote,
  start=startDate, end=endDate,  quote=quoteType))

Your calls with get.hist.quote() are not what you expect.  Note that
the tickers you passed to getSymbols() are "^GSPC" and "^DJI".  But
those are not the objects that getSymbols() creates (or the adjusted
ticker symbols it returns), because they are not syntatically valid R
names (because they start with a circumflex).

So you call get.hist.quote() with tickers "GSPC" and "DJI", which are
not the S&P 500 and Dow Jones Industrial indexes, respectively.  The
GSPC data is not what you expect, and there's no data for DJI.

>         [[alternative HTML version deleted]]
>
Please follow the posting guide and do not post HTML.  The list server
does not like it and can mangle your message, as it did in this case.

> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com
R/Finance 2017 | www.rinfinance.com



More information about the R-help mailing list