I am trying to download data of the symbol MACQ
by applying the following code:
getSymbols.yahoo("MACQ",.GlobalEnv,from="2010-02-02",to="2016-12-28")
However, I am getting error warning:
Error in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, :
cannot open URL 'http://ichart.finance.yahoo.com/table.csv?s=MACQ&a=1&b=02&c=2010&d=11&e=28&f=2016&g=d&q=q&y=0&z=MACQ&x=.csv'
In addition: Warning message:
In download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, :
cannot open URL 'http://ichart.finance.yahoo.com/table.csv?s=MACQ&a=1&b=02&c=2010&d=11&e=28&f=2016&g=d&q=q&y=0&z=MACQ&x=.csv': HTTP status was '404 Not Found'
From the message above you can see, that the following url is being used: 'http://ichart.finance.yahoo.com/table.csv?s=MACQ&a=1&b=02&c=2010&d=11&e=28&f=2016&g=d&q=q&y=0&z=MACQ&x=.csv'
If you copy/paste this url into web browser you will really encounter Yahoo! 404 Not Found Problem.
However if you look carefully at the URL, you will notice, that it is using incorrect date reference in the url and thus creating invalid url link. The first "mistake" is that the starting date (i.e. the month) is written in the url as 1&b
, but it should have been written as 02&b
and also the the end month 11&e
should have been 12&e
.
So the link: http://ichart.finance.yahoo.com/table.csv?s=MACQ&a=1&b=02&c=2010&d=11&e=28&f=2016&g=d&q=q&y=0&z=MACQ&x=.csv
should have looked like this: http://ichart.finance.yahoo.com/table.csv?s=MACQ&a=02&b=02&c=2010&d=12&e=28&f=2016&g=d&q=q&y=0&z=MACQ&x=.csv
Why is incorrect date used and how to prevent it? This happened to me only when using "MACQ" symbol.
It looks like it's because the MACQ ticker on Yahoo doesn't have much history, and thus the dates are out of scope. Google Finance corroborates this, it appears the stock only has pricing data going back to December 16th, 2016.