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 22 of file markowitz.py.

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

Variable Documentation

◆ all_model_types

markowitz.all_model_types

Definition at line 67 of file markowitz.py.

◆ cp

markowitz.cp = ws.add_checkpoint()

Definition at line 70 of file markowitz.py.

◆ cur_ret

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

Definition at line 109 of file markowitz.py.

◆ data_points

list markowitz.data_points = []

Definition at line 77 of file markowitz.py.

◆ gap

float markowitz.gap = 0.02

Definition at line 90 of file markowitz.py.

◆ i

list markowitz.i = intervals.pop()

Definition at line 100 of file markowitz.py.

◆ intervals

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

Definition at line 93 of file markowitz.py.

◆ job

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

Definition at line 65 of file markowitz.py.

◆ key

markowitz.key

Definition at line 118 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 73 of file markowitz.py.

◆ l_val

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

Definition at line 104 of file markowitz.py.

◆ marker

markowitz.marker

Definition at line 121 of file markowitz.py.

◆ markersize

markowitz.markersize

Definition at line 121 of file markowitz.py.

◆ max_l

markowitz.max_l

Definition at line 102 of file markowitz.py.

◆ max_ret

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

Definition at line 86 of file markowitz.py.

◆ mi

markowitz.mi = cp.add_modelinstance()

Definition at line 72 of file markowitz.py.

◆ min_l

markowitz.min_l

Definition at line 101 of file markowitz.py.

◆ min_ret

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

Definition at line 82 of file markowitz.py.

◆ opt

markowitz.opt = ws.add_options()

Definition at line 66 of file markowitz.py.

◆ ret

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

Definition at line 119 of file markowitz.py.

◆ value

markowitz.value

Definition at line 80 of file markowitz.py.

◆ var

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

Definition at line 120 of file markowitz.py.

◆ ws

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

Definition at line 61 of file markowitz.py.