Solve Problem for Minimum Tracking Error with Net Return Constraint

This example shows how to use estimateCustomObjectivePortfolio to solve a portfolio problem for minimum tracking error with a net return constraint using a custom objective.

Create Portfolio Object

Create a Portfolio object.

% Create a Portfolio object
p = Portfolio(AssetMean=AssetMean,AssetCovar=AssetCovar);

Define Problem

The portfolio problem for a minimum tracking error problem with a net return constraint is defined as

$\begin{array}{l}\underset{\mathit{x}}{\mathrm{min}}\text{\hspace{0.17em}\hspace{0.17em}}{\left(\mathit{x}-{\mathit{x}}_{0}\right)}^{\mathit{T}}\Sigma \left(\mathit{x}-{\mathit{x}}_{0}\right)\\ \mathit{s}.\mathit{t}.{\mu }^{\mathit{T}}\mathit{x}-{\mathit{c}}_{\mathit{B}}^{\mathit{T}}\mathrm{max}\left(0,\mathit{x}-{\mathit{x}}_{0}\right)-{\mathit{c}}_{\mathit{S}}^{\mathit{T}}\mathrm{max}\left(0,{\mathit{x}}_{0}-\mathit{x}\right)\ge {\mu }_{0}\\ \text{\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}}\sum _{\mathit{i}}{\mathit{x}}_{\mathit{i}}=1\\ \text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\mathit{x}\ge 0\end{array}$

Define Problem Parameters

Define the problem parameters for the Portfolio object.

% Initial portfolio
initPort = 1/p.NumAssets*ones(p.NumAssets,1);
% Sell cost
sellCost = 0.002*ones(p.NumAssets,1);
% Net return target
ret0 = 0.03;

Solve Portfolio Problem

Use estimateCustomObjectivePortfolio to solve this portfolio problem for a minimum tracking error with a net return constraint. When using the estimateCustomObjectivePortfolio function with a Portfolio object, you add return constraints by using the estimateCustomObjectivePortfolio name-value argument TargetReturn with a return target value.

% Long-only, fully invested portfolio
p = setDefaultConstraints(p);
% Set the buy and sell costs

% Set the objective
fun = @(x) (x-initPort)'*p.AssetCovar*(x-initPort);

% Solve the portfolio problem
wFinTbx = estimateCustomObjectivePortfolio(p,fun,TargetReturn=ret0)
wFinTbx = 6×1

0.1633
0.0648
0.1950
0.2618
0.0625
0.2525