n-period return
Try:
?diff
library(quantmod)
getSymbols("AAPL")
AAPL.Cl <- Cl(AAPL)
diff(log(AAPL.Cl), lag=11)
diff(log(AAPL.Cl), lag=90)
diff(log(AAPL.Cl), lag=180)
Or using quantmod's Delt:
Delt(Cl(AAPL), k=c(11,90,180), type="log")
HTH
Jeff
On Mon, Aug 3, 2009 at 5:55 AM,
ehxpieterse<eduard.pieterse at macquarie.com> wrote:
Apologies if this has been asked before. I am looking for a function to calculate the n-period return for a time series. For example, the user would specify 11, 90 or 180 and then generate an accompanying n-period delta. Thanks in advance. Eduard -- View this message in context: http://www.nabble.com/n-period-return-tp24788735p24788735.html Sent from the Rmetrics mailing list archive at Nabble.com.
_______________________________________________ R-SIG-Finance at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. -- If you want to post, subscribe first.
Jeffrey Ryan jeffrey.ryan at insightalgo.com ia: insight algorithmics www.insightalgo.com