[R-SIG-Finance] getSymbols fails for Yahoo symbols

Mark Knecht markknecht at gmail.com
Tue Dec 31 23:43:23 CET 2013


Mark,
   Thanks for sharing this solution. As written it does work fine here
but seemed to leave a symbol file behind in /tmp so I added

file.remove(file)

after the assign statement to take care of that.

Cheers,
Mark

On Tue, Dec 31, 2013 at 11:40 AM, markbreman . <breman.mark at gmail.com> wrote:
> Hi Ivan,
>
> I noticed this too this morning when i needed some data. Maybe Jeff can fix
> this in quantmod when he reads this.
>
> In the mean time i wrote some code to get the data i needed:
>
> asof=Sys.Date()
> #asof=as.Date("2011-11-29")
> universe = c('DIA', 'IEF', 'GLD')
>
> cat("as-of date: ", format(asof), "\n")
>
> from=asof-(89*4)
> to=asof
> a=as.character(as.integer(format(from, "%m"))-1)
> b=format(from, "%d")
> c=format(from, "%Y")
> d=as.character(as.integer(format(to, "%m"))-1)
> e=format(to, "%d")
> f=format(to, "%Y")
>
> for(symbol in universe) {
>     url=paste("http://ichart.finance.yahoo.com/table.csv?s=", symbol,
> "&a=", a, "&b=", b, "&c=", c, "&d=", d, "&e=", e, "&f=", f,
> "&g=d&q=q&y=0&z=", symbol, "&x=.csv", sep="")
>     file=paste("/tmp/", symbol, ".csv", sep="")
>     download.file(url, file)
>     assign(symbol, as.xts(read.csv(file, header=FALSE, skip=1,
> col.names=c("Date", "Open", "High", "Low", "Close", "Volume", "Adjusted"),
> row.names=1)))
> }
>
> HTH,
>
> -Mark-
>
>
> 2013/12/31 Ivan Popivanov <ivan.popivanov at gmail.com>
>
>> Looks like Yahoo have stopped providing web interface via chart.yahoo.com,
>> which is used by getSymbols.yahoo. The site used to download data through
>> the web interface is ichart.finance.yahoo.com, which seems to use the same
>> interface.
>>
>> Happy New Year,
>> Ivan
>>
>>         [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-SIG-Finance at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> -- Subscriber-posting only. If you want to post, subscribe first.
>> -- Also note that this is not the r-help list where general R questions
>> should go.
>>
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.



More information about the R-SIG-Finance mailing list