Is there a way to adjust constraints per period when using optimize.portfolio.rebalancing in the PortfolioAnalytics r package? For active management, constraints are not static through time but vary based on the benchmark weights.
my latest attempt was to create a function similar to momentFUN. momentFUN allows for time varying portfolio moments when using optimize.portfolio.rebalancing.
update.constraints <- function(bm)
{
tmpR <- bm[index(bm)==index(tail(R,1)),]
add.constraints(port,type = 'box',indexnum = 2, min = max(0,bm-0.03), max = bm+0.03)
}
then i try to call this in the same way momentFUN is called in the optimization function
opt <- optimize.portfolio.rebalancing(R = returns,
portfolio = port,optimize_method = 'random',trace = TRUE,rp=rp,
momentFUN="moment.ranking",constraints = update.constraints,bm=bm
rebalance_on = "months",training_period = 12)