[ojAlgo-user] Risk Aversion Factor Question
Mathematics, linear algebra and optimisation
Brought to you by:
apete
From: <bru...@uk...> - 2009-06-16 14:15:03
|
Hi, when looking at the javadoc of the QuadraticSolver class, the following can be read: QuadraticSolver solves optimisation problems of the form: min 1/2 [X]T[Q][X] - [C]T[X] when [AE][X] == [BE] and [AI][X] <= [BI] I wondered how it would be possible to optimise the following problem with QuadraticSolver: min k*[X]T[Q][X] - (1-k)*[R]T[X] where R is the vector of the returns and 0 <= k <= 1 when [AE][X] == [BE] and [AI][X] <= [BI] Typically I want to either: - maximise the return for a target volatility [X]T[Q][X] = targetVol - minimise the volatility for a target return [R]T[X] = targetReturn How can I do that with QuadraticSolver? Here is the code I wrote as an attempt to solve my problem. It gives me weights but I am not sure if I have set the problem correctly. public boolean solveProblem() { Variable[] variables = new Variable[allReturns[0].length]; //R is the vector of the assets' returns //Inequality constraints are between 0 and 1 for the weights for (int i = 0; i < variables.length; i++) { variables[i] = new Variable("w"+(i+1)); variables[i].setContributionWeight( R.toBigDecimal(i, 0) ); variables[i].setLowerLimit("0" ); variables[i].setUpperLimit("1" ); } QuadraticModel quadraticModel = new QuadraticModel(variables); //Q is the correlation matrix of the assets' returns //The question is: What do I do if I want to set a volatility target? How do I specify it? // How is it related to the contribution? Expression expression = quadraticModel.addCorrelationExpression("Variance", Q ); BigDecimal riskAversion = new BigDecimal("1"); expression.setContributionWeight(riskAversion.multiply(new BigDecimal("0.5"))); // set balance expression, sum of weights equal to 1 expression = quadraticModel.addSimpleWeightExpression("Balance"); expression.setLowerLimit(new BigDecimal("1")); expression.setUpperLimit(new BigDecimal("1")); res = quadraticModel.getDefaultSolver().solve(); solverState = res.getState(); return solverState == solverState.OPTIMAL; } Regards BF -------- This communication is confidential, may be privileged and is meant only for the intended recipient. If you are not the intended recipient, please notify the sender by reply and delete the message from your system. Any unauthorised dissemination, distribution or copying hereof is prohibited. BNP Paribas Trust Corporation UK Limited, BNP Paribas UK Limited, BNP Paribas Commodity Futures Limited, BNP Paribas Asset Management UK Limited and Investment Fund Services Limited are authorised and regulated by the Financial Services Authority. BNP Paribas London Branch and BNP Paribas Wealth Management London Branch are authorised by the CECEI and supervised by the Commission Bancaire. BNP Paribas London Branch is authorised and subject to limited regulation by the Financial Services Authority. Details about the extent of our authorisation and regulation by the Financial Services Authority are available from us on request. BNP Paribas is also a member of the London Stock Exchange. BNP Paribas Wealth Management London Branch is subject to limited regulation by the Financial Services Authority. Details about the extent of our authorisation and regulation by the Financial Services Authority are available from us on request. BNP Paribas Securities Services London Branch is authorised by the CECEI and supervised by the AMF, and subject to limited regulation by the Financial Services Authority. Details on the extent of our regulation by the Financial Services Authority are available from us on request. BNP Paribas Securities Services is also a member of the London Stock Exchange. BNP Paribas Trust Corporation UK Limited is registered in England and Wales (registered no. 4042668) at registered office 55 Moorgate, London EC2R 6PA. BNP Paribas UK Limited is registered in England and Wales (registered no. 1488108) at registered office 10 Harewood Avenue, London NW1 6AA. BNP Paribas Commodity Futures Limited is registered in England and Wales (registered no. 2391477) at registered office 10 Harewood Avenue, London NW1 6AA. BNP Paribas Asset Management UK Limited is registered in England and Wales (registered no. 2474627) at registered office 10 Harewood Avenue, London NW1 6AA. Investment Fund Services Limited is registered in England and Wales (registered no. 6110770) at registered office 55 Moorgate, London EC2R 6PA. BNP Paribas London Branch is registered in England and Wales (registered no. FC13447) at registered office 10 Harewood Avenue, London NW1 6AA. BNP Paribas Wealth Management London Branch is registered in England and Wales (registered no. FC023926) at registered office 10 Harewood Avenue, London NW1 6AA. BNP Paribas Securities Services London Branch is registered in England and Wales (registered no. BR006393) at registered office 55 Moorgate, London, EC2R 6PA. |