#' given a matrix of portfolio composition, minimizee the portfolio turnover
#' @export
#'
minTurnover <-function(mat, thershold = 0.005){
out = mat
pos = mat[1,] #before change position
for(i in 2:(nrow(out))){
if(sum(abs(pos-mat[i,]))>thershold){
out[i, ] = mat[i, ]
pos = out[i, ]
}else{
out[i, ] = pos
}
}
out
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.