Description Usage Arguments Details Value Note Author(s) Examples
Performance a backtest of a investmentstrategy with annual rebalancing
1 |
data |
Return matrix for with historic data |
risk |
Risk profil (low,medium,high) |
Cno |
Number of clusters for the hierarchical clustering |
used to backtest and evaluate performance
returns accummulated wealth over a period specified by the return matrix
RIS
Thomas
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (data, risk, Cno)
{
btPeriods <- round(dim(data)[1] - dim(data)[2] * 2)
wealth <- rep(1, btPeriods)
rebalanc <- dim(data)[1]/52
ret <- list()
time <- names(data[(length(data[, 1]) - btPeriods):(length(data[,
1])), 1])
for (t in 1:btPeriods) {
data.avail <- data[t:(length(data[, 1]) - btPeriods +
t - 1), ]
data.act <- data[(length(data[, 1]) - btPeriods + t),
]
if (t == 1 || (t%%rebalanc) == 0) {
allocate <- Selector(data.avail, risk, Cno)
alloc <- rep(1/Cno, Cno)
names(alloc) <- allocate
}
wealth[t + 1] <- wealth[t] * sum(alloc * data.act[allocate])
}
names(wealth) <- rownames(data)[(length(rownames(data)) -
length(wealth) + 1):length(rownames(data))]
return(wealth)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.