You are on page 1of 5

Points in Frontier: 30

Covariance Matrix:
Assets: Rate of Return: Upper Bound: GOOGLE YAHOO CISCO
GOOGLE 1.3 0.75 3 1 -0.5
YAHOO 1.2 0.75 1 2 -0.4
CISCO 1.08 0.75 -0.5 -0.4 1

Efficient Frontier
1.3
Return

1.25

1.2

1.15

1.1

1.05
0 0.5 1 1.5 2 2.5
Risk
Efficient Frontier:
Risk: Return:
0.417375 1.144097
0.417375 1.144097
0.417375 1.144097
0.417375 1.144097
0.417375 1.144097
0.417375 1.144096
0.417375 1.144138
0.420756 1.149828
0.430807 1.155517
0.447528 1.161207
0.470919 1.166897
0.500979 1.172586
0.537708 1.178276
0.581108 1.183965
0.631177 1.189655
0.687916 1.195345
0.751324 1.201034
0.821403 1.206724
0.89815 1.212414
0.981568 1.218103
1.071655 1.223793
1.168412 1.229483
1.271839 1.235172
1.381935 1.240862
1.498701 1.246552
1.622136 1.252241
1.752241 1.257931
1.889016 1.263621
2.03246 1.26931
2.1875 1.275
SET ECHOIN 1
MODEL:
! Solves the generic Markowitz portfolio
model in a loop to generate the points
on the efficient frontier;
SETS:
ASSETS: RATE, UB, X;
COVMAT( ASSETS, ASSETS): COV;
POINTS: RET, VAR;
ENDSETS

DATA:
! Number of points on the
efficient frontier graph;
NPOINTS = 30;
POINTS = 1..NPOINTS;
! The stocks;
ASSETS = @OLE();
! Expected growth rate of each asset;
RATE = @OLE();
! Upper bound on investment in each;
UB = @OLE();
! Covariance matrix;
COV = @OLE();
ENDDATA

! Below are the three objectives we'll use;


SUBMODEL SUB_RET_MAX:
[OBJ_RET_MAX] MAX = RETURN;
ENDSUBMODEL

SUBMODEL SUB_RET_MIN:
[OBJ_RET_MIN] MIN = RETURN;
ENDSUBMODEL

SUBMODEL SUB_MIN_VAR:
[OBJ_MIN_VAR] MIN =
@SUM( COVMAT( I, J): COV( I, J) * X( I) * X( J));
ENDSUBMODEL

!and the constraints;


SUBMODEL SUB_CONSTRAINTS:
! Compute return;
RETURN = @SUM( ASSETS( I): RATE( I) * X( I));
! Must be fully invested;
@SUM( ASSETS( I): X( I)) = 1;
! Upper bounds on each;
@FOR( ASSETS( I): @BND( 0, X( I), UB( I)));
! Must achieve target return;
RETURN >= RET_LIM;
ENDSUBMODEL

CALC:
! Set some parameters;
! Reset all params;
@SET( 'DEFAULT');
! Output error messages only;
@SET( 'TERSEO', 2);
! Suppress status window;
@SET( 'STAWIN', 0);

! Solve to get maximum return;


RET_LIM = 0;
@SOLVE( SUB_RET_MAX, SUB_CONSTRAINTS);

! Save maximum return;


RET_MAX = OBJ_RET_MAX;

! Solve to get minimum return;


@SOLVE( SUB_RET_MIN, SUB_CONSTRAINTS);

! Save minimum return;


RET_MIN = OBJ_RET_MIN;

! Interval between return points;


INTERVAL =
( RET_MAX - RET_MIN) / ( NPOINTS-1);

! Loop over range of possible returns,


minimizing variance;
RET_LIM = RET_MIN;
@FOR( POINTS( I):
@SOLVE( SUB_MIN_VAR, SUB_CONSTRAINTS);
RET( I) = RETURN;
VAR( I) = OBJ_MIN_VAR;
RET_LIM = RET_LIM + INTERVAL;
);
! Display the results;
@WRITE( ' Return Variance', @NEWLINE( 1));
@FOR( POINTS( I): @WRITE( @FORMAT( RET( I), '#12.6G'),
@FORMAT( VAR( I), '#12.6G'), @NEWLINE( 1))
);

! @CHARTCURVE( 'Efficient Frontier', 'Variance/Risk', 'Risk'


'Efficient Frontier', VAR, RET);
ENDCALC

DATA:
@OLE() = VAR, RET;
ENDDATA

END
GO
QUIT

You might also like