Read.csv ("http://ichart.finance.yahoo.com/table.csv?s=SPY") Doesn't work

I have been using the following command for a long time with no problems:

spy <- read.csv("http://ichart.finance.yahoo.com/table.csv?s=SPY") 

But in the last few days, he began to cause the following error:

Warning Messages:

1: In file (file, "rt"): The "internal" method cannot handle https redirection to: ' https://ichart.finance.yahoo.com/table.csv?s=SPY '

2: In the file (file, "rt"): the "internal" method failed, so trying "libcurl"

I updated RStudio, R and all packages to the most modern versions to date. Can someone help me solve this problem?

Thanks in advance!

+2
r csv yahoo-api yahoo-finance
Apr 20 '17 at 21:06 on
source share
3 answers

The fix is ​​directly in the error message: use https not http:

 R> spy <- read.csv("https://ichart.finance.yahoo.com/table.csv?s=SPY") R> head(spy) Date Open High Low Close Volume Adj.Close 1 2017-04-19 234.52 234.95 233.18 233.44 66861500 233.44 2 2017-04-18 233.72 234.49 233.08 233.87 80188300 233.87 3 2017-04-17 233.11 234.57 232.88 234.57 63559500 234.57 4 2017-04-13 233.64 234.49 232.51 232.51 83019800 232.51 5 2017-04-12 234.74 234.96 233.77 234.03 76322100 234.03 6 2017-04-11 234.90 235.18 233.34 235.06 85727700 235.06 R> 
+3
Apr 20 '17 at 21:15
source

And if you use the getReturns function from the getReturns package, use the modified getReturns function from the link below:

https://gist.github.com/Maiae/46a058243819ae0973fd38708a32fc31

It basically replaces http: // https: //

0
Apr 26 '17 at 13:01
source

Yahoo stopped the service, if you want to start with a small data set, download csv and use

https://github.com/datasets/s-and-p-500-companies

0
Oct 22 '17 at 4:08 on
source



All Articles