Description Usage Arguments Value Author(s) See Also Examples
View source: R/pub01_utilityFuncs.R
get a return of different periods of the rtn series(including overall cumulative and annualized return).
1 | rtn.periods(rtn, freq = "year", from, to)
|
rtn |
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns |
freq |
An interval specification, one of "day", "week", "month", "quarter" and "year", optionally preceded by an integer and a space, or followed by "s".See |
from |
starting dates, a vector of class Date,timeDate or character.See |
to |
ending dates a vector of class Date,timeDate or character.See |
a matrix
Ruifei.Yin
1 2 3 4 5 | rtn.long <- zoo(rnorm(100,0.001,0.02),as.Date("2010-01-01")+1:100)
rtn.short <- rtn.long + rnorm(100,-0.001,0.003)
rtn <- merge(rtn.long,rtn.short)
rtn.periods(rtn,"month")
rtn.periods(rtn,from=c("2010-02-03","2010-03-04"),to=c("2010-03-09","2010-03-30"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.