Main Content


Set up maximum portfolio tracking error constraint



obj = setTrackingError(obj,TrackingError) sets up a maximum portfolio tracking error constraint for a Portfolio object. For details on the workflow when using a Portfolio object, see Portfolio Object Workflow.


obj = setTrackingError(___,TrackingPort,NumAssets) sets up a maximum portfolio tracking error constraint using optional arguments for TrackingPort and NumAssets.


collapse all

Create a Portfolio object.

AssetMean = [ 0.05; 0.1; 0.12; 0.18 ];
AssetCovar = [ 0.0064 0.00408 0.00192 0;
    0.00408 0.0289 0.0204 0.0119;
    0.00192 0.0204 0.0576 0.0336;
    0 0.0119 0.0336 0.1225 ];

p = Portfolio('mean', AssetMean, 'covar', AssetCovar, 'lb', 0, 'budget', 1)
p = 
  Portfolio with properties:

          BuyCost: []
         SellCost: []
     RiskFreeRate: []
        AssetMean: [4x1 double]
       AssetCovar: [4x4 double]
    TrackingError: []
     TrackingPort: []
         Turnover: []
      BuyTurnover: []
     SellTurnover: []
             Name: []
        NumAssets: 4
        AssetList: []
         InitPort: []
      AInequality: []
      bInequality: []
        AEquality: []
        bEquality: []
       LowerBound: [4x1 double]
       UpperBound: []
      LowerBudget: 1
      UpperBudget: 1
      GroupMatrix: []
       LowerGroup: []
       UpperGroup: []
           GroupA: []
           GroupB: []
       LowerRatio: []
       UpperRatio: []
     MinNumAssets: []
     MaxNumAssets: []
        BoundType: []

Estimate the Sharpe ratio for the Portfolio object p and define the tracking error.

x0 = estimateMaxSharpeRatio(p);
te = 0.08;
p = setTrackingError(p, te, x0);

Input Arguments

collapse all

Object for portfolio, specified using a Portfolio object. For more information on creating a portfolio object, see Portfolio.

Data Types: object

Upper bound for portfolio tracking error, specified using a nonnegative and finite scalar.

Given an upper bound for portfolio tracking error in TrackingError and a tracking portfolio in TrackingPort, the tracking error constraint requires any portfolio in Port to satisfy

(Port - TrackingPort)'*AssetCovar*(Port - TrackingPort) <= TrackingError^2.
For more information, see Tracking Error Constraints.

Data Types: double

Tracking portfolio weights, specified using a vector. TrackingPort must be a finite vector with NumAssets > 0 elements.

If no TrackingPort is specified, it is assumed to be 0. If TrackingPort is specified as a scalar and NumAssets exists, then TrackingPort undergoes scalar expansion.

Data Types: double

Number of assets in portfolio, specified using a scalar. If it is not possible to obtain a value for NumAssets, it is assumed that NumAssets is 1.

Data Types: double

Output Arguments

collapse all

Updated portfolio object, returned as a Portfolio object. For more information on creating a portfolio object, see Portfolio.


The tracking error constraints can be used with any of the other supported constraints in the Portfolio object without restrictions. However, since the portfolio set necessarily and sufficiently must be a non-empty compact set, the application of a tracking error constraint can result in an empty portfolio set. Use estimateBounds to confirm that the portfolio set is non-empty and compact.


You can also use dot notation to set up a maximum portfolio tracking error constraint.

obj = obj.setTrackingError(TrackingError, NumAssets);

To remove a tracking portfolio, call this function with an empty argument ([]) for TrackingError.

obj = setTrackingError(obj, [ ]);

Version History

Introduced in R2015b