GAMS [ Home | Downloads | Documentation | Solvers | APIs | Tools | Model Libraries | Resources | Sales | Support | Contact Us | Search ]

GAMS Python API - Tutorial and Examples
markowitz.py File Reference

This is a small graphical program that plots the efficient frontier of Markowitz' portfolio selection problem with the two objectives return and risk. More...

Go to the source code of this file.

Functions

def markowitz.get_model_text ()
 

Variables

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

Detailed Description

This is a small graphical program that plots the efficient frontier of Markowitz' portfolio selection problem with the two objectives return and risk.

The example utilizes the GamsModelInstance class to solve the parameterized objective max lambda*return - (1-lambda)*risk in the most efficient way. The example requires the matplotlib module.

Definition in file markowitz.py.