0

I am trying to maximize active return and minimize active risk using portfolio analytics optimization. is this possible using this package? i am trying to minimize the active weight.. so Min(Portw -Benchw)*Cov. is there a way to add in the bench weight as part of the objective function?

Here is my code currently.. any help would be greatly appreciated! thank you.

#this dataframe is the current benchmark weightings. i would like to 
#specify my objective function so that i am minimizing the active risk, not 
#total risk. is there a way to feed the benchmark weights into the 
#add.objective function?

BenchWeight <- arrange(BenchWeight,Product)%>%
  spread(Product,Weight)    

#CovMatrix is a dataframe turned into xts object with 120 daily returns on 
#various bond market sectors.

CovMatrix <- select(ExcessReturns, Date,Product,Excess_Returns_Daily)%>%
spread(Product,Excess_Returns_Daily)%>%
select(-Universal)%>%
arrange(desc(Date))%>%
slice(1:120)


optimdata <- xts(CovMatrix[,-1], order.by = CovMatrix[,1])

optimweight <- portfolio.spec(colnames(optimdata))
optimweight <- add.constraint(optimweight, type= "weight_sum", min_sum=0, 
max_sum=1)
optimweight <- add.constraint(optimweight, type = "long_only")
optimweight <- add.objective(optimweight, type="return", name = "mean")
optimweight <- add.objective(optimweight, type = "risk",name = "StdDev", 
target = 0.5)


optimweight1 <- optimize.portfolio(optimdata,optimweight, optimize_method 
= "ROI")
  • Please provide a minimal reproducible example. – Christoph Nov 05 '19 at 17:27
  • sorry.. So CovMatrix is a dataframe that is turned into an xts object that contains 120 days of excess returns on various bond sectors. i have the benchmark weights for those sectors in another dataframe called BenchWeight <- read.csv("BenchWeight.csv"). my problem is i dont know how to specify the objective function so that i am solving for minimizing the active risk, instead of total risk. CovMatrix <- select(ExcessReturns, Date,Product,Excess_Returns_Daily)%>% spread(Product,Excess_Returns_Daily)%>% select(-Universal)%>% arrange(desc(Date))%>% slice(1:120) – akennedy12345 Nov 05 '19 at 17:47
  • Please read [(1)](https://stackoverflow.com/help/how-to-ask) how do I ask a good question, [(2)](https://stackoverflow.com/help/mcve) how to create a MCVE as well as [(3)](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example#answer-5963610) how to provide a minimal reproducible example in R. Then edit and improve your question accordingly. I.e., abstract from your real problem... – Christoph Nov 05 '19 at 19:38

0 Answers0