Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quantmod Error 'cannot open URL'

Tags:

r

quantmod

I started to experience an error today with the quantmod package. Anybody else have the same error when running this code (or requesting symbols in general)?

library(quantmod) getSymbols("CPIAUCNS",src="FRED")

Error:
Error in download.file(paste(FRED.URL, "/", Symbols[[i]], "/", "downloaddata/", : cannot open URL 'http://research.stlouisfed.org/fred2/series/CPIAUCNS/downloaddata/CPIAUCNS.csv'

The URL itself works fine.

like image 973
Wolf Avatar asked Jul 02 '15 14:07

Wolf


2 Answers

FRED changed the URL scheme from http:// to https://. I'm working on determining a patch that will work on all platforms. The current code still works for me on Windows if --internet2 is set.

On unix-alikes, one potential solution is to add method="curl" or method="wget" to the download.file call in getSymbols.FRED.

like image 177
Joshua Ulrich Avatar answered Nov 01 '22 11:11

Joshua Ulrich


Another (temporary) solution is to call one of the following before the actual getSymbols script:

options(download.file.method="libcurl")
or
options(download.file.method="wget")
or
options(download.file.method="wininet")

The first option works for me (on Mac).
Thanks Paul Gilbert from Rmetrics (bottom post)

like image 7
Wolf Avatar answered Nov 01 '22 10:11

Wolf