Kimpro
Kimpro

Reputation: 101

getSymbols() from quantmod in R doesn't work

I tried running getSymbols() from the famous library quantmod in R, but it didn't work. So I want to ask how to solve this problem.

The codes that I tried was the following :

library(quantmod)
getSymbols("AAPL")
Error in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m,  : 
  cannot open URL 'http://ichart.finance.yahoo.com/table.csv?s=AAPL&a=0&b=01&c=2007&d=4&e=30&f=2019&g=d&q=q&y=0&z=AAPL&x=.csv'
In addition: Warning message:
In download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m,  :
  InternetOpenUrl failed: '서버 이름이나 주소를 확인할 수 없습니다.'
getSymbols("AAPL", src="google")
Error in download.file(paste(google.URL, "q=", Symbols.name, "&startdate=",  : 
  cannot open URL 'http://finance.google.com/finance/historical?q=AAPL&startdate=Jan+01,+2007&enddate=May+30,+2019&output=csv'
In addition: Warning message:
In download.file(paste(google.URL, "q=", Symbols.name, "&startdate=",  :
  cannot open URL 'http://finance.google.com/finance/historical?q=AAPL&startdate=Jan+01,+2007&enddate=May+30,+2019&output=csv': HTTP status was '403 Forbidden'

I have ever run this function on the same desktop(OS : Windows 8.1K, x64).


Thank you for telling me about the right lastest version, so I tried upgrading the package like the below, but to fail.

install.packages("quantmod")

It answered that it still calls v0.4-7.

Installing package into ‘C:/Users/fya/Documents/R/win-library/3.3’
(as ‘lib’ is unspecified)
trying URL 'https://mran.revolutionanalytics.com/snapshot/2016-11-01/bin/windows/contrib/3.3/quantmod_0.4-7.zip'
Content type 'application/zip' length 472947 bytes (461 KB)
downloaded 461 KB

package ‘quantmod’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\***\AppData\Local\Temp\RtmpozsYvx\downloaded_packages

Is there more effective way for solving this problem?

I referred to another stackoverflow page about upgrading packages in R : https://stackoverflow.com/questions/21461649/how-to-update-a-package-in-r

Upvotes: 3

Views: 6224

Answers (1)

Joshua Ulrich
Joshua Ulrich

Reputation: 176648

The latest version of quantmod on CRAN is 0.4-14, so you need to upgrade. Also note that Google Finance no longer provides any data.


You're using MRAN and R-3.3.x. MRAN may have quantmod_0.4-14, but they apparently do not for older R versions. And CRAN only provides Windows binaries for the latest minor version of R (currently 3.6.x).

You can install the latest quantmod from CRAN on R-3.3.x, but you will have to do some of the steps manually. Download quantmod_0.4-14 from CRAN then call:

install.packages("quantmod_0.4-14.tar.gz", repos = NULL, type = "source")

I think that should work. Comment if you still have issues.

Upvotes: 2

Related Questions