[R-SIG-Finance] Extracting data from google.finance: getSymbols
Db
pict100 at gmail.com
Thu Dec 8 08:26:54 CET 2011
#Extracting data
require(quantmod)
various.symbols
<-c("RDY","HDB","IBN","INFY","MTE","PTI","REDF","SIFY","SLT","TCL","TTM","WIT","WNS")
mv <- function(symbol,fromd){
setSymbolLookup(ASTOCK=list(src="google",from=fromd,name=symbol))
getSymbols("ASTOCK")
liquidity <- ASTOCK[,5]
res <- aggregate(liquidity,as.yearmon,mean)
print(res)
return(res)
}
start.date="2002-01-01"
dat <- mv("RDY",start.date)
colnames(dat) <- various.symbols[1]
for(i in 2:length(various.symbols)){
cat("Working on:",various.symbols[i],"\n")
datu <- mv(various.symbols[i],start.date)
colnames(datu) <- various.symbols[i]
dat <- cbind(dat,datu,all=TRUE)
}
# Results
tail(dat)
######### Monthly Average Volume
###########################################
--
View this message in context: http://r.789695.n4.nabble.com/Extracting-data-from-google-finance-getSymbols-tp4153191p4171811.html
Sent from the Rmetrics mailing list archive at Nabble.com.
More information about the R-SIG-Finance
mailing list