markowitz Namespace Reference

Functions

def get_model_text ()
 

Variables

 ws = GamsWorkspace(system_directory = sys.argv[1])
 
 job = ws.add_job_from_string(get_model_text())
 
 opt = ws.add_options()
 
 all_model_types
 
 cp = ws.add_checkpoint()
 
 mi = cp.add_modelinstance()
 
 l = mi.sync_db.add_parameter("lambda", 0, "")
 
list data_points = []
 
 value
 
 min_ret = mi.sync_db["ret"].first_record().level
 
 max_ret = mi.sync_db["ret"].first_record().level
 
float gap = 0.02
 
list intervals = [((0.0, min_ret), (1.0, max_ret))]
 
list i = intervals.pop()
 
 min_l
 
 max_l
 
tuple l_val = (min_l+max_l)/2
 
 cur_ret = mi.sync_db["ret"].first_record().level
 
 key
 
 ret = map(lambda x: x[0], data_points)
 
 var = map(lambda x: x[1], data_points)
 
 marker
 
 markersize
 

Function Documentation

◆ get_model_text()

def markowitz.get_model_text ( )

Definition at line 21 of file markowitz.py.

21def get_model_text():
22 return '''
23$title Standard Markowitz Portfolio Selection Model
24
25set s selected stocks
26 upper(s,s), lower(s,s) parts of covar matrix;
27alias(s,t);
28
29parameter mean(s) mean of daily return
30 covar(s,s) covariance matrix of returns (upper);
31
32$if not set data $abort 'no include file name for data file provided'
33$gdxin %data%
34$load s covar upper lower mean
35
36variables z objective variable
37 ret return
38 var variance
39 x(s) investments;
40
41positive variables x;
42
43equations obj objective
44 budget
45 varcon variance constraint
46 retcon return constraint;
47
48scalar lambda /0/;
49
50obj.. z =e= lambda*ret - (1-lambda)*var;
51budget.. sum(s, x(s)) =e= 1.0;
52varcon.. var =e= sum(upper(s,t), x(s)*covar(s,t)*x(t)) +
53 sum(lower(s,t), x(s)*covar(t,s)*x(t));
54retcon.. ret =e= sum(s, mean(s)*x(s));
55
56model markowitz /all/; '''
57
def get_model_text()
Definition: warehouse.py:17

Variable Documentation

◆ all_model_types

markowitz.all_model_types

Definition at line 66 of file markowitz.py.

◆ cp

markowitz.cp = ws.add_checkpoint()

Definition at line 69 of file markowitz.py.

◆ cur_ret

markowitz.cur_ret = mi.sync_db["ret"].first_record().level

Definition at line 108 of file markowitz.py.

◆ data_points

list markowitz.data_points = []

Definition at line 76 of file markowitz.py.

◆ gap

float markowitz.gap = 0.02

Definition at line 89 of file markowitz.py.

◆ i

list markowitz.i = intervals.pop()

Definition at line 99 of file markowitz.py.

◆ intervals

list markowitz.intervals = [((0.0, min_ret), (1.0, max_ret))]

Definition at line 92 of file markowitz.py.

◆ job

markowitz.job = ws.add_job_from_string(get_model_text())

Definition at line 64 of file markowitz.py.

◆ key

markowitz.key

Definition at line 117 of file markowitz.py.

Referenced by transport12.guss_call(), and warehouse.solve_warehouse().

◆ l

markowitz.l = mi.sync_db.add_parameter("lambda", 0, "")

Definition at line 72 of file markowitz.py.

◆ l_val

tuple markowitz.l_val = (min_l+max_l)/2

Definition at line 103 of file markowitz.py.

◆ marker

markowitz.marker

Definition at line 120 of file markowitz.py.

◆ markersize

markowitz.markersize

Definition at line 120 of file markowitz.py.

◆ max_l

markowitz.max_l

Definition at line 101 of file markowitz.py.

◆ max_ret

markowitz.max_ret = mi.sync_db["ret"].first_record().level

Definition at line 85 of file markowitz.py.

◆ mi

markowitz.mi = cp.add_modelinstance()

Definition at line 71 of file markowitz.py.

◆ min_l

markowitz.min_l

Definition at line 100 of file markowitz.py.

◆ min_ret

markowitz.min_ret = mi.sync_db["ret"].first_record().level

Definition at line 81 of file markowitz.py.

◆ opt

markowitz.opt = ws.add_options()

Definition at line 65 of file markowitz.py.

◆ ret

markowitz.ret = map(lambda x: x[0], data_points)

Definition at line 118 of file markowitz.py.

◆ value

markowitz.value

Definition at line 79 of file markowitz.py.

◆ var

markowitz.var = map(lambda x: x[1], data_points)

Definition at line 119 of file markowitz.py.

◆ ws

markowitz.ws = GamsWorkspace(system_directory = sys.argv[1])

Definition at line 60 of file markowitz.py.