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 个评论
采纳的回答
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.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!