A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.gams.com/latest/docs/apis/examples_dotnet/Markowitz_2Form1_8cs_source.html below:

Markowitz/Form1.cs Source File

2using

System.Collections.Generic;

3using

System.ComponentModel;

8using

System.Windows.Forms;

11using

System.Reflection;

12using

System.Windows.Forms.DataVisualization.Charting;

23 public partial class Form1

: Form

28 if

(Environment.GetCommandLineArgs().Length > 1)

29

ws =

new GAMSWorkspace

(systemDirectory: Environment.GetCommandLineArgs()[1]);

35

opt.AllModelTypes =

"conopt"

;

36

opt.

Defines

.Add(

"data"

,

"\""

+ Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),

@"..\..\..\..\Data\Markowitz.gdx"

) +

"\""

);

46

List<Tuple<double, double>> dataPoints =

new

List<Tuple<double, double>>();

63

Stack<Tuple<Tuple<double, double>, Tuple<double, double>>> intervals =

new

Stack<Tuple<Tuple<double, double>, Tuple<double, double>>>();

64

intervals.Push(Tuple.Create(Tuple.Create(0.0, minRet), Tuple.Create(1.0, maxRet)));

69 while

(intervals.Count > 0){

71

var i = intervals.Pop();

72 double

minL = i.Item1.Item1;

73

minRet = i.Item1.Item2;

74 double

maxL = i.Item2.Item1;

75

maxRet = i.Item2.Item2;

77 double

lVal = (minL+maxL)/2;

85 if

(curRet - minRet > gap)

86

intervals.Push(Tuple.Create(Tuple.Create(minL, minRet), Tuple.Create(lVal, curRet)));

87 if

(Math.Abs(curRet - maxRet) > gap)

88

intervals.Push(Tuple.Create(Tuple.Create(lVal, curRet), Tuple.Create(maxL, maxRet)));

92

dataPoints.Sort((a, b) => a.Item1.CompareTo(b.Item1));

94

InitializeComponent();

95

this.chart1.Series.Clear();

96

Series s = this.chart1.Series.Add(

"s"

);

97

s.ChartType = SeriesChartType.Line;

98

s.MarkerStyle = MarkerStyle.Circle;

100

this.chart1.ChartAreas[0].AxisX.Title =

"return"

;

101

this.chart1.ChartAreas[0].AxisY.Title =

"variance"

;

102

this.chart1.ChartAreas[0].AxisX.Interval = 0.1;

103

this.chart1.ChartAreas[0].AxisX.Minimum = 0;

105 foreach

(Tuple<double,double> p

in

dataPoints)

106

s.Points.AddXY(p.Item1, p.Item2);

109 static

String GetModelText()

112$title Standard Markowitz Portfolio Selection Model 115 upper(s,s), lower(s,s) parts of covar matrix; 118parameter mean(s) mean of daily return 119 covar(s,s) covariance matrix of returns (upper); 121$if not set data $abort 'no include file name for data file provided' 123$load s covar upper lower mean 125variables z objective variable 132equations obj objective 134 varcon variance constraint 135 retcon return constraint; 139obj.. z =e= lambda*ret - (1-lambda)*var; 140budget.. sum(s, x(s)) =e= 1.0; 141varcon.. var =e= sum(upper(s,t), x(s)*covar(s,t)*x(t)) + 142 sum(lower(s,t), x(s)*covar(t,s)*x(t)); 143retcon.. ret =e= sum(s, mean(s)*x(s));

GAMSModelInstance AddModelInstance(string modelInstanceName=null)

GAMSVariable GetVariable(string variableIdentifier)

GAMSParameter AddParameter(string identifier, int dimension, string explanatoryText="")

void Run(GAMSOptions gamsOptions=null, GAMSCheckpoint checkpoint=null, TextWriter output=null, Boolean createOutDB=true)

void Solve(SymbolUpdateType updateType=SymbolUpdateType.BaseCase, TextWriter output=null, GAMSModelInstanceOpt miOpt=null)

void Instantiate(string modelDefinition, params GAMSModifier[] modifiers)

Dictionary< string, string > Defines

new GAMSParameterRecord FindRecord(params string[] keys)

new GAMSParameterRecord FirstRecord()

new GAMSParameterRecord AddRecord(params string[] keys)

new GAMSVariableRecord FirstRecord()

GAMSJob AddJobFromString(string gamsSource, GAMSCheckpoint checkpoint=null, string jobName=null)

GAMSCheckpoint AddCheckpoint(string checkpointName=null)

GAMSOptions AddOptions(GAMSOptions optFrom=null)

This is a small graphical program that plots the efficient frontier of Markowitz' portfolio selection...


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4