[ojAlgo-user] MarkowitzModel vs ExpressionsBasedModel
Mathematics, linear algebra and optimisation
Brought to you by:
apete
From: Anthony E. <ant...@al...> - 2014-02-26 15:35:11
|
Hi I am trying to explore the efficient frontier using an ExpressionsBasedModel, as the MarkowitzModel doesnt let me enter the constraints I would like to use. Ive been looking at the posts and test cases and it seems that to do this i should follow the steps below: My approach with the ExpressionBasedModel is: 1) vars = [Create the variables and set upper and lower limits for them] 2) ExpressionsBasedModel model = new ExpressionsBasedModel(vars) 3) covarExpr = [Create the covariance Expression based on the covariance matrix]. 4) covarExpr.setQuadraticFactors(model.getVariables(), covar_matrix); 5) balanceExpr = [Create the balance so sum of weights = 1] 6) riskAversion = BigMath.PI.multiply(BigMath.E) 7) covarExpr.weight(riskAversion.multiply(BigMath.HALF)); I have a couple of questions. 1) Are steps 5 and 6 sensible. It seems to be what yoou do in some of the tests, but I’d like to understand if thats right 2) On the MarkowitzModel I can get out of it .getRiskAversion(), .getSharpeRatio() and getMeanReturn(). How do I calculate those on an ExpressionsBasedModel? Apologies if this sounds obvious, but this isnt really my sort of thing! Thanks |