# Downloading most recent stock prices

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.

## 2 Answers

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.

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.