Re: [ojAlgo-user] Markowitz Model Optimal Portfolio
Mathematics, linear algebra and optimisation
Brought to you by:
apete
From: Anders P. <an...@op...> - 2013-02-19 20:59:01
|
The problem is your covariance matrix. It has this set of eigenvalues: [(0.5492672834435615 + 0.0i), (0.008437331909258683 + 0.0i), (2.4514803398083397E-6 + 0.0i), (1.2790218090583707E-6 + 0.0i), (0.13451737212621906 + 0.0i), (0.11506560932721471 + 0.0i), (0.040501906544593284 + 0.0i), (0.01745967407048038 + 0.0i), (-2.1722469350130856E-6 + 0.0i), (-6.568799450269596E-7 + 0.0i), (-7.879659671549668E-8 + 0.0i), (0.0 + 0.0i), (0.0 + 0.0i), (0.0 + 0.0i), (0.0 + 0.0i), (0.0 + 0.0i), (0.0 + 0.0i), (0.0 + 0.0i), (0.0 + 0.0i), (0.0 + 0.0i), (0.0 + 0.0i), (0.0 + 0.0i)] The covariance matrix should not have negative or very small (zero) eigenvalues. Before trusting the results of the MarkowitzModel you should check the optimization state - model.getOptimisationState(); In your case it is FAILED. Calling marketEquilibrium.clean() will fix/clean the covariance matrix. There is not 1 optimal portfolio, there is one per risk aversion value - experiment with different values. /Anders On 19 feb 2013, at 15:09, Sydney <moi...@ho...> wrote: > Hello, > > I am very new to Markowitz Model and I would like to use ojAlgo to plot the efficient frontier of a portfolio. I wrote some code but the result does not seem to be correct. > > My first attempt is to find the optimal portfolio. > > The first example is a portfolio with 3 assets. The result seems correct. But then I tried with 22 assets and some of the weights are negative. The portolio expected return is -10393.07457410003 and the variance is -103930.3518485767. > > I attached the code. I did not set the risk aversion parameter because I don't know what this parameter is for. Do you have an example value if you want to find the optimal portfolio. > > Thanks > Sydney > <MM.java>------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_feb_______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |