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 次查看(过去 30 天)
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 个评论
Andrew Burns
Andrew Burns 2017-1-8
编辑:Walter Roberson 2017-1-8
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 2017-1-8
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()?

请先登录,再进行评论。

采纳的回答

Brandon Eidson
Brandon Eidson 2017-1-6
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 个评论
Andrew Burns
Andrew Burns 2017-1-6
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by