Trying to optimize weights of series of combinations (250 in total) of 10-stock portfolios for Omega Ratio, with weights bound from 0<->1, and total of weights = 1.

2 views (last 30 days)
So I know MATLAB has a function for Omega Ratio: Omega = lpm(-Data, -MAR, 1) / lpm(Data, MAR, 1), that uses "lpm". That is my objective function. I believe I can use "fmincon" - or a linear optimizer for this exercise. My constraints are as per above.
The question I have is, does anyone know of any scripts that I can begin with so I'm not reinventing the wheel?
I want to output the 1 of the 250 combinations with the highest Omega Ratio, its weights (for each of the 10 stocks)
  6 Comments
Andrew Burns
Andrew Burns on 8 Jan 2017
Edited: Walter Roberson on 8 Jan 2017
function [negative_omegas] = f_omega_02(x)
% In this function, i.e., "negative_omegas", the objective function to maximize the omega ratio is multiplied by (-1) given that "fmincon()" seeks a minimimum:
load('returns.mat')
negative_omegas = -1 * lpm(-r * x, -0.04, 1) / lpm(r * x, 0.04, 1);
end
Andrew Burns
Andrew Burns on 8 Jan 2017
Effectively what's going on with the function is it's giving me the right weights (one of the 10 is fully weighted at "1", the other 9 are "0", but when I compare it to Excel, it's not applying the right full "1" weight to the right stock (it should be the one with the highest individual Omega Ratio).
I think it has to do with the input parameters I'm passing fmincon()?

Sign in to comment.

Accepted Answer

Brandon Eidson
Brandon Eidson on 6 Jan 2017
Hey Andrew, it's hard to answer your question precisely without knowing about your Data variable. One would need to know the datatype and what information it contains to know how to pass it and the weights appropriately to "lpm" and "fmincon". Below is essentially psuedo code that you can adjust to meet your needs. What I have provided definitely will not work (specifically because of how weights and Data are passed to "lpm".
%
%data and mars initialized somehow and stored in Data and MAR variables, respectively
%
optimalWeights = zeros(10:250);
optimalOmegas = zeros(1:250);
%Lower bound and upper bound for each weight is 0 and 1, respectively.
lb = zeros(1:10);
up = ones(1:10);
%All weights should add together to equal 1.
Aeq = ones(1:10);
beq=1;
%use even distribution as initial guess
w0 = 0.1*ones(10,1);
for k = 1:250
%The function is multiplied by -1 because fmincon is a minimizer
func = @(weights)-1*lpm(-weights*Data(:,k),-MAR(k),1)/lpm(weights*Data(:,k),MAR(k),1);
[optimalWeights(:,k), optimalOmegas(k)] = fmincon(func,w0,[],[],Aeq,beq,lb,ub);
end
[maxOmega, indexOfMax] = max(optimalOmegas);
Data(:,indexOfMax)
It sounds like you are aware of these documentation pages but, just in case, I have provided links below to "lpm" and "fmincon" so you can see the appropriate way to pass arguments to these functions.
  1 Comment
Andrew Burns
Andrew Burns on 6 Jan 2017
Thanks so much Brandon. I appreciate your input. I'll be working on this over the weekend. Let me employ your suggestions and show you what I come up with - any more input would be hugely appreciated then. Cheers.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!