Hello everyone,
I am very new to GAMS and managed to construct one model so far!! But now I want to change the variable that has to maximized and find out the corresponding values… sounds complicated, I know. It is a linear problem, I have 25 stocks, monthly returns for 168 periods and use this historic data to infer possible stock price developments for the future. Now I want GAMS to maximize possible return and minimize risk , subject to constraints: sum of all investments is 1, the scalar omega is the maximum percentage one is willing to lose and cannot be set below zero, of course. The higher omega, the higher the expected return and risk.
Here is my code:
*$TITLE formulation for a portfolio management model

define runtime control parameters
$OFFSYMXREF
$OFFSYMLIST
OPTION LIMCOL=0;
OPTION LIMROW=0;
OPTION SOLPRINT=OFF; 
select optimization solver
$offlisting;
OPTION ITERLIM=100000;
OPTION RESLIM=100000;
OPTION LP=GUROBI;
\ 
define the set of asset classes
Define sets
SET class the investment asset classes / S1*S25 /;
SET n / n1*n168 /;
Define Tables, parameters, scalars*
$INCLUDE spreturns.txt
$INCLUDE benchmark.txt
parameter Prob(n) Scenario probabilities;
loop(n, Prob(n)=1/168);
SCALARS
Omega Bound on the expected downside loss /0.055267/ ;
Define variables*
VARIABLES
downside downside losses
yPos(n) Positive deviations
yNeg(n) Negative deviations
hold(class) proportions of asset classes invested at root node
z Objective function value;
POSITIVE VARIABLES yPos, yNeg, hold;
EQUATIONS
downloss downside losses
init_balance asset balance constraint at the root
ObjDef Objective function
Dev(n) Equations defining the deviations ;
Conneg Constraint to bound the expected value of the negative deviations ;
downloss… downside =E= SUM(n, Prob(n) * yNeg(n));
init_balance… sum(class, hold(class)) =E= 1.0;
Conneg … SUM(n, Prob(n) * yNeg(n)) =L= Omega;
Dev(n)… yPos(n)  yNeg(n) =E= sum(class, hold(class)*Ret(n,class))  index(n);
ObjDef … z =E= SUM(n, Prob(n) * yPos(n));
model portfolio / all /;
file resultsputcall25;
resultsputcall25.ap=1;
SOLVE portfolio USING LP MAXIMIZING z ;
put resultsputcall25;
resultsputcall25.nd=5;
put z.l, downside.l /;
put/;
loop(class, put CLASS.tl, hold.l(class) / );
Now I want GAMS to find the portfolio with the highest possible return and give me the corresponding omega, find the portfolio with the lowest omega, and the portfolio with the average return of these 2 portfolios and the corresponding omega.
the files spreturns and benchmark are attached…
So please feel free to ask back questions since I don’t really know what else I have to write for you to understand my question and the problem
Thank you so much!
best regards,
Nils
–
benchmark.txt (1.95 KB)
spreturns.txt (27.4 KB)