Skip to content
Prev 4700 / 15274 Next

n-period return

Thanks Jeff,

I'm not too clear on how to use the GetSeries data type, after using diff().

getSymbols("^GSPC", src="yahoo") 
CloseData <- Cl(GSPC) 
Delta <- diff(CloseData, lag=1) 
for (i in 3:length(Delta)) { 
 if (Delta[i]>Delta[i-1]) sum <- sum + Delta   
}

It seems if the variables have no length? Is this something specific to the
way getSymbols create objects?