frontcon Migration to Portfolio Objectfrontcon Without Output ArgumentsThis example shows how to migrate frontcon without
output arguments to a Portfolio object.
The basic frontcon functionality is
represented as:
ExpReturn = [ 0.0054; 0.0531; 0.0779; 0.0934; 0.0130 ]; ExpCovariance = [ 0.0569, 0.0092, 0.0039, 0.0070, 0.0022; 0.0092, 0.0380, 0.0035, 0.0197, 0.0028; 0.0039, 0.0035, 0.0997, 0.0100, 0.0070; 0.0070, 0.0197, 0.0100, 0.0461, 0.0050; 0.0022, 0.0028, 0.0070, 0.0050, 0.0573 ]; NumPorts = 10; frontcon(ExpReturn, ExpCovariance, NumPorts);
Undefined function or variable 'frontcon'.
To migrate a frontcon syntax without
output arguments to a Portfolio object:
ExpReturn = [ 0.0054; 0.0531; 0.0779; 0.0934; 0.0130 ]; ExpCovariance = [ 0.0569, 0.0092, 0.0039, 0.0070, 0.0022; 0.0092, 0.0380, 0.0035, 0.0197, 0.0028; 0.0039, 0.0035, 0.0997, 0.0100, 0.0070; 0.0070, 0.0197, 0.0100, 0.0461, 0.0050; 0.0022, 0.0028, 0.0070, 0.0050, 0.0573 ]; NumPorts = 10; p = Portfolio; p = setAssetMoments(p, ExpReturn, ExpCovariance); p = setDefaultConstraints(p); plotFrontier(p, NumPorts);

The Portfolio object writes to the current figure window rather than create a new window each time a plot is generated.
frontcon with Output ArgumentsThis example shows how to migrate frontcon with
output arguments to a Portfolio object.
The basic frontcon functionality is
represented as:
ExpReturn = [ 0.0054; 0.0531; 0.0779; 0.0934; 0.0130 ]; ExpCovariance = [ 0.0569, 0.0092, 0.0039, 0.0070, 0.0022; 0.0092, 0.0380, 0.0035, 0.0197, 0.0028; 0.0039, 0.0035, 0.0997, 0.0100, 0.0070; 0.0070, 0.0197, 0.0100, 0.0461, 0.0050; 0.0022, 0.0028, 0.0070, 0.0050, 0.0573 ]; NumPorts = 10; [PortRisk, PortReturn, PortWts] = frontcon(ExpReturn, ExpCovariance, NumPorts); display(PortWts);
Undefined function or variable 'frontcon'.
To migrate a frontcon syntax with output
arguments:
ExpReturn = [ 0.0054; 0.0531; 0.0779; 0.0934; 0.0130 ]; ExpCovariance = [ 0.0569, 0.0092, 0.0039, 0.0070, 0.0022; 0.0092, 0.0380, 0.0035, 0.0197, 0.0028; 0.0039, 0.0035, 0.0997, 0.0100, 0.0070; 0.0070, 0.0197, 0.0100, 0.0461, 0.0050; 0.0022, 0.0028, 0.0070, 0.0050, 0.0573 ]; NumPorts = 10; p = Portfolio; p = setAssetMoments(p, ExpReturn, ExpCovariance); p = setDefaultConstraints(p); PortWts = estimateFrontier(p, NumPorts); [PortRisk, PortReturn] = estimatePortMoments(p, PortWts); display(PortWts);
PortWts =
0.2103 0.1744 0.1386 0.1027 0.0668 0.0309 0 0 0 0
0.2746 0.2657 0.2567 0.2477 0.2387 0.2298 0.2168 0.1791 0.0557 0
0.1157 0.1296 0.1436 0.1575 0.1714 0.1854 0.1993 0.2133 0.2183 0
0.1594 0.2193 0.2791 0.3390 0.3988 0.4587 0.5209 0.5985 0.7260 1.0000
0.2400 0.2110 0.1821 0.1532 0.1242 0.0953 0.0629 0.0091 0 0The Portfolio object returns PortWts with
portfolios going down columns, not across rows. Portfolio risks and
returns are still in column format.
frontcon for Target Returns Within Range of Efficient Portfolio ReturnsThis example shows how to migrate frontcon target
returns within range of efficient portfolio returns to a Portfolio
object.
frontcon can obtain portfolios with
specific targeted levels of return but requires that the targeted
returns fall within the range of efficient returns. The Portfolio
object handles this by selecting portfolios at the ends of the efficient
frontier.
ExpReturn = [ 0.0054; 0.0531; 0.0779; 0.0934; 0.0130 ];
ExpCovariance = [ 0.0569, 0.0092, 0.0039, 0.0070, 0.0022;
0.0092, 0.0380, 0.0035, 0.0197, 0.0028;
0.0039, 0.0035, 0.0997, 0.0100, 0.0070;
0.0070, 0.0197, 0.0100, 0.0461, 0.0050;
0.0022, 0.0028, 0.0070, 0.0050, 0.0573 ];
NumPorts = 10;
TargetReturn = [ 0.05; 0.06; 0.07; 0.08; 0.09 ];
[PortRisk, PortReturn, PortWts] = frontcon(ExpReturn, ExpCovariance, [], TargetReturn);
disp(' Efficient Target');
disp([PortReturn, TargetReturn]);Undefined function or variable 'frontcon'.
To migrate a frontcon syntax for target
returns within range of efficient portfolio returns to a Portfolio
object:
ExpReturn = [ 0.0054; 0.0531; 0.0779; 0.0934; 0.0130 ];
ExpCovariance = [ 0.0569, 0.0092, 0.0039, 0.0070, 0.0022;
0.0092, 0.0380, 0.0035, 0.0197, 0.0028;
0.0039, 0.0035, 0.0997, 0.0100, 0.0070;
0.0070, 0.0197, 0.0100, 0.0461, 0.0050;
0.0022, 0.0028, 0.0070, 0.0050, 0.0573 ];
NumPorts = 10;
TargetReturn = [ 0.05; 0.06; 0.07; 0.08; 0.09 ];
p = Portfolio;
p = setAssetMoments(p, ExpReturn, ExpCovariance);
p = setDefaultConstraints(p);
PortWts = estimateFrontierByReturn(p, TargetReturn);
[PortRisk, PortReturn] = estimatePortMoments(p, PortWts);
disp(' Efficient Target');
disp([PortReturn, TargetReturn]);Efficient Target
0.0500 0.0500
0.0600 0.0600
0.0700 0.0700
0.0800 0.0800
0.0900 0.0900frontcon for Target Returns Outside Range of Efficient Portfolio ReturnsThis example shows how to migrate frontcon target
returns outside of range of efficient portfolio returns to a Portfolio
object.
When the target return is outside of the range of efficient
portfolio returns, frontcon generates an error.
The Portfolio object handles this effectively by selecting portfolios
at the ends of the efficient frontier.
ExpReturn = [ 0.0054; 0.0531; 0.0779; 0.0934; 0.0130 ];
ExpCovariance = [ 0.0569, 0.0092, 0.0039, 0.0070, 0.0022;
0.0092, 0.0380, 0.0035, 0.0197, 0.0028;
0.0039, 0.0035, 0.0997, 0.0100, 0.0070;
0.0070, 0.0197, 0.0100, 0.0461, 0.0050;
0.0022, 0.0028, 0.0070, 0.0050, 0.0573 ];
NumPorts = 10;
TargetReturn = [ 0.05; 0.06; 0.07; 0.08; 0.09; 0.10 ];
[PortRisk, PortReturn, PortWts] = frontcon(ExpReturn, ExpCovariance, [], TargetReturn);
disp(' Efficient Target');
disp([PortReturn, TargetReturn]);Undefined function or variable 'frontcon'.
To migrate a frontcon syntax for target
returns outside of the range of efficient portfolio returns to a Portfolio
object:
ExpReturn = [ 0.0054; 0.0531; 0.0779; 0.0934; 0.0130 ];
ExpCovariance = [ 0.0569, 0.0092, 0.0039, 0.0070, 0.0022;
0.0092, 0.0380, 0.0035, 0.0197, 0.0028;
0.0039, 0.0035, 0.0997, 0.0100, 0.0070;
0.0070, 0.0197, 0.0100, 0.0461, 0.0050;
0.0022, 0.0028, 0.0070, 0.0050, 0.0573 ];
NumPorts = 10;
TargetReturn = [ 0.05; 0.06; 0.07; 0.08; 0.09; 0.10 ];
p = Portfolio;
p = setAssetMoments(p, ExpReturn, ExpCovariance);
p = setDefaultConstraints(p);
PortWts = estimateFrontierByReturn(p, TargetReturn);
[PortRisk, PortReturn] = estimatePortMoments(p, PortWts);
disp(' Efficient Target');
disp([PortReturn, TargetReturn]);Warning: One or more target return values are outside the feasible range [
0.0427391, 0.0934 ].
Will return portfolios associated with endpoints of the range for these
values.
> In Portfolio/estimateFrontierByReturn (line 106)
Efficient Target
0.0500 0.0500
0.0600 0.0600
0.0700 0.0700
0.0800 0.0800
0.0900 0.0900
0.0934 0.1000frontcon Syntax When Using BoundsThis example shows how to migrate frontcon syntax
for AssetBounds to a Portfolio object.
Use frontcon with an input specification
for AssetBounds that contains the lower and upper
bounds on the weight allocated to each asset in the portfolio:
ExpReturn = [ 0.0054; 0.0531; 0.0779; 0.0934; 0.0130 ]; ExpCovariance = [ 0.0569, 0.0092, 0.0039, 0.0070, 0.0022; 0.0092, 0.0380, 0.0035, 0.0197, 0.0028; 0.0039, 0.0035, 0.0997, 0.0100, 0.0070; 0.0070, 0.0197, 0.0100, 0.0461, 0.0050; 0.0022, 0.0028, 0.0070, 0.0050, 0.0573 ]; NumPorts = 10; AssetBounds = [ 0.1, 0.1, 0.1, 0.1, 0.1; 0.5, 0.5, 0.5, 0.5, 0.5 ]; [PortRisk, PortReturn, PortWts] = frontcon(ExpReturn, ExpCovariance, NumPorts, [], AssetBounds); disp([PortRisk, PortReturn]);
Undefined function or variable 'frontcon'.
To migrate a frontcon syntax using AssetBounds to
a Portfolio object:
ExpReturn = [ 0.0054; 0.0531; 0.0779; 0.0934; 0.0130 ]; ExpCovariance = [ 0.0569, 0.0092, 0.0039, 0.0070, 0.0022; 0.0092, 0.0380, 0.0035, 0.0197, 0.0028; 0.0039, 0.0035, 0.0997, 0.0100, 0.0070; 0.0070, 0.0197, 0.0100, 0.0461, 0.0050; 0.0022, 0.0028, 0.0070, 0.0050, 0.0573 ]; NumPorts = 10; AssetBounds = [ 0.1, 0.1, 0.1, 0.1, 0.1; 0.5, 0.5, 0.5, 0.5, 0.5 ]; LowerBound = AssetBounds(1,:); UpperBound = AssetBounds(2,:); p = Portfolio; p = setAssetMoments(p, ExpReturn, ExpCovariance); p = setDefaultConstraints(p); p = setBounds(p, LowerBound, UpperBound); PortWts = estimateFrontier(p, NumPorts); [PortRisk, PortReturn] = estimatePortMoments(p, PortWts); disp([PortRisk, PortReturn]);
0.1288 0.0427 0.1291 0.0457 0.1299 0.0487 0.1313 0.0516 0.1332 0.0546 0.1356 0.0576 0.1385 0.0605 0.1419 0.0635 0.1461 0.0665 0.1519 0.0694
frontcon Syntax When Using GroupsThis example shows how to migrate frontcon syntax
for Groups and GroupBounds to
a Portfolio object.
Use frontcon with an input specification
for Groups (asset groups or classes.) and GroupBounds (the
lower and upper bounds of the total weights of all assets in a group).
Consider three groups: Assets 2, 3, and 4 can constitute up to 80%
of a portfolio, Assets 1 and 2 can constitute up to 70% of a portfolio,
and Assets 3, 4, and 5 can constitute up to 90% of a portfolio.
ExpReturn = [ 0.0054; 0.0531; 0.0779; 0.0934; 0.0130 ];
ExpCovariance = [ 0.0569, 0.0092, 0.0039, 0.0070, 0.0022;
0.0092, 0.0380, 0.0035, 0.0197, 0.0028;
0.0039, 0.0035, 0.0997, 0.0100, 0.0070;
0.0070, 0.0197, 0.0100, 0.0461, 0.0050;
0.0022, 0.0028, 0.0070, 0.0050, 0.0573 ];
NumPorts = 10;
Groups = [ 0 1 1 1 0; 1 1 0 0 0; 0 0 1 1 1 ];
GroupBounds = [ 0, 0.8; 0, 0.7; 0, 0.9 ];
[PortRisk, PortReturn, PortWgts] = frontcon(ExpReturn, ExpCovariance, NumPorts, [], [], ...
Groups, GroupBounds);
disp([PortRisk, PortReturn]);
Undefined function or variable 'frontcon'.
To migrate a frontcon syntax using Groups and GroupBounds to
a Portfolio object:
ExpReturn = [ 0.0054; 0.0531; 0.0779; 0.0934; 0.0130 ]; ExpCovariance = [ 0.0569, 0.0092, 0.0039, 0.0070, 0.0022; 0.0092, 0.0380, 0.0035, 0.0197, 0.0028; 0.0039, 0.0035, 0.0997, 0.0100, 0.0070; 0.0070, 0.0197, 0.0100, 0.0461, 0.0050; 0.0022, 0.0028, 0.0070, 0.0050, 0.0573 ]; NumPorts = 10; Groups = [ 0 1 1 1 0; 1 1 0 0 0; 0 0 1 1 1 ]; GroupBounds = [ 0, 0.8; 0, 0.7; 0, 0.9 ]; LowerGroup = GroupBounds(:,1); UpperGroup = GroupBounds(:,2); p = Portfolio; p = setAssetMoments(p, ExpReturn, ExpCovariance); p = setDefaultConstraints(p); p = setGroups(p, Groups, LowerGroup, UpperGroup); PortWts = estimateFrontier(p, NumPorts); [PortRisk, PortReturn] = estimatePortMoments(p, PortWts); disp([PortRisk, PortReturn]);
0.1288 0.0427 0.1292 0.0465 0.1306 0.0503 0.1328 0.0540 0.1358 0.0578 0.1395 0.0615 0.1440 0.0653 0.1504 0.0690 0.1590 0.0728 0.1806 0.0766
addInequality | estimateFrontier | estimateFrontierByReturn | estimatePortMoments | pcalims | pcgcomp | pcglims | portcons | Portfolio | portopt | setAssetMoments | setBounds | setDefaultConstraints | setGroups | setInequality