0
$\begingroup$

I would like to download (from Google) the most recent prices for a series of stocks. I have created a portfolio at Google and I can click on "Download to Spreadsheet". That works.

But I would like to automate the process so that I can obtain the spreadsheet using R. I did this previously from Yahoo with the code: read.csv("http://finance.yahoo.com/quotes/DRRX,AAPL,AMZN") However, I can't figure out the comparable code to download from Google. Any help would be appreciated.

$\endgroup$

2 Answers 2

1
$\begingroup$

R is very useful for downloading data from Yahoo/Google . Here is an example for downloading from Google Finance :

library(quantmod)

getSymbols("DRRX;AAPL;AMZN", from="2014-01-01", to="2014-11-20", src='google')

Just adjust the from and to dates as needed. This will download the OHLCV data from google finance to your R global environment.

$\endgroup$
0
$\begingroup$

I explored this further and following that the following works:

require("RCurl") STOCKS <- paste("AAPL", "BIDU", "AMAZ", collapse=",") STRING <- paste0("http://finance.google.com/finance/info?client=ig&q=INDU,IXIC,DRRX,", paste0(STOCKS, collapse=",")) TEMP <- getURL(STRING)

Then, one needs to do some editing (a combination of strsplit and gsub) on the output.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.