# minimise tracking error whilst reducing number of trades required

I have a portfolio which is a subset of a benchmark. I want to minimise the tracking error between my portfolio and the benchmark.

Currently I use APT's risk model to do this. I set it to run for 10 iterations. Each iteration reduces the number of trades by approx 10% of the previous iteration and minimises the tracking error.

I wish to use my own risk model rather than APT for various reasons.

I can minimise the tracking error using my own risk model. However I am not sure how to minimise the tracking error and constraining the number of trades like APT does.

One approach which is very crude is to minimise the tracking error and calculate the marginal contribution of each stock to the tracking error and to tell the optimiser that those stocks cannot be traded. What is a better way?

Update

I am using matlab and the tomlab optimiser, with the documentation below. So yes the objective function is non linear and we have linear constraints. I have seen that tomlab provides a mixed integer programming function however not sure how to incorporate it into my current problem?

 % -----------------------------------------------------
%
% QP minimization problem:
%
%
%        min   0.5 * x' * F * x + c' * x.  x in R^n
%         x
%        s/t   x_L <=   x  <= x_U
%              b_L <= A x  <= b_U
%
% Equality equations: Set b_L==b_U
% Fixed    variables: Set x_L==x_U
%
% -----------------------------------------------------
%
% Syntax of qpAssign:
%
% function Prob = qpAssign(F, c, A, b_L, b_U, x_L, x_U, x_0, Name,...
%                 setupFile, nProblem, fLowBnd, x_min, x_max, f_opt, x_opt);
%
% INPUT (One parameter F must always be given. Empty gives default)
%
% F            The matrix F in 0.5 x' F x in the objective function
% c            The vector c in c'x in the objective function
% A            The linear constraint matrix
% b_L          The lower bounds for the linear constraints
% b_U          The upper bounds for the linear constraints
% x_L          Lower bounds on x
% x_U          Upper bounds on x
%
%              b_L, b_U, x_L, x_U must either be empty or of full length
%
% x_0          Starting point x (may be empty)
% Name         The name of the problem (string)
% setupFile    The (unique) name as a TOMLAB Init File. If nonempty qpAssign
%              will create a executable m-file with this name and the given
%              problem defined as the first problem in this file.
%              See qp_prob.m, the TOMLAB predefined QP Init File.
%              If empty, no Init File is created. Also see nProblem.
% nProblem     Number of problems, or problem number, to define in the setupFile
%              Not used if setupFile is empty.
%
%              nProblem = 1 ==> File is created to make it easy to edit new
%              problems into the file. Text are included on how to add new
%              problems. The given problem is set as number 1.
%              If isempty(nProblem) same as nProblem=1.
%
%              length(nProblem) > 1 ==> A file suitable for large test sets
%              are setup, where the problem definition is read from mat-files.
%              Statements for problems nProblem(1) to nProblem(2) are defined.
%              The given input is assumed to be nProblem(1), and the
%              corresponding mat-file is created.
%
%              If nProblem > 1. Additional problems are assumed, and the only
%              thing done is to create a mat-file with the problem.
%
%              If isempty(setupFile), nProblem is not used
%
% fLowBnd      A lower bound on the function value at optimum. Default -1E300
%              A good estimate is not critical. Use [] if not known at all.
%              Only used running some nonlinear TOMLAB solvers with line search
% x_min        Lower bounds on each x-variable, used for plotting
% x_max        Upper bounds on each x-variable, used for plotting
% f_opt        Optimal function value(s), if known (Stationary points)
% x_opt        The x-values corresponding to the given f_opt, if known.
%              If only one f_opt, give x_opt as a 1 by n vector
%              If several f_opt values, give x_opt as a length(f_opt) x n matrix
%              If adding one extra column n+1 in x_opt,
%              0 indicates min, 1 saddle, 2 indicates max.
%              x_opt and f_opt is used in printouts and plots.

• When you say APT, I think you are referring to Advanced Portfolio Technologies and its APTpro optimization tool. bloomberg.com/research/stocks/private/… Unfortunately I don't know how that optimizer works. Oct 24, 2017 at 12:08
• @NegativeJo yes I have just found Gurobi in Matlab. How would I incorporate this into my optimisation? Oct 25, 2017 at 7:01
• Or would I run my original optimisation to minimise my tracking error & then use these suggested weights to then run a MILP solver? Oct 25, 2017 at 9:55

First of all we need to make clear the difference between the risk model and the optimizer.

## The Risk Model

The risk model is how you evaluate the risk and tracking error of your portfolio. In most risk models this would be implemented by using something of the form

w'eSe'w + wI

where

• w is a [nx1] vector of your stocks weight

• S is a [mxm] matrix of the covariance of your risk factor

• I is an [nx1] vector of your stocks idiosyncratic volatility (the volatility which is not explained by the risk factors)

This can come from any risk model vendor or you can create your own as you indicate.

## The Optimization

Now the second problem and where your question is actually difficult to answer is how to optimize. We dont know which software you are currently using or would like to use to solve your optimization problem so I'll try to be quite general.

The optimisation problem you want to solve is to find the set of stock weights such that you minimise

w'eSe'w + wI

typically there would be constraints such that Aw=b (linear constraints) and l < w < b (bound constraints) and potentially other linear or quadratic terms in your objective

Since your objective is of quadratic form and your constraints linear most solver would be able to handle that efficiently.

Now your question relates to the maximum number of trades to be done. This is typically considered to be a Mixed Integer Programming (MIP) where you have an hidden variable which can be 1 or 0 for each of the trade w-w* to be done or not.

This is not a simple task to optimize. What you suggest could actually be used and is a heuristic that can be applied within the general solution : Branch-and-Bound.

Essentially in branch and bound you want to evaluate multiple combinations of that hidden variable to see which one would produce the most optimal solution subject to your constraints and how close it gets to the bound of the relaxed optimal solution. If the dimensionality is particularly high this is not a trivial problem and you would need to define several things such as the actual branching mechanism and the stopping mechanism.

Most (but not all) optimizer (commercially available or open-source) will have such functionalities and I would suggest you rely on them to implement those type of strategies. Otherwise you can read more on branch and bound and have your own implementation (although I would say in most cases this is not the recommended approach)

You can also try different heuristics like the one that you described and hope that you are not too far from the optimal solution. Reading about branch and bound would help you evaluate this in any case.

Without knowing which specific software you are using this is as general advice as I can give.

Good luck !

UPDATE : Since you added which platform you are using : I would look into MILP/MIQP functionalities of the solver. Tomlab doesnt have out of the box solutions for this type of portfolio constraint so it's worth checking with Tomlab what modules you have paid for and would match MILP/MIQP solving.

One word of notice though : it is not trivial to implement, you would need to experiment and if the size of your universe is large (>1000 names) the optimization can be particularly slow.

• If you have time : learn and experiment :) - Expect at least a few weeks (2,4,8...16?) of work to get there even if you know what you are doing
• If you dont have time and no additional budget : Apply the heuristic you described in an iterative way. Or some other reasonable heuristics and compare which ones gives you the lowest T.E. consistently.
• If you have some time and lots of budget go for a commercial solver, possibly specialized in portfolio construction problem that has specific BnB strategies for this type of problems.

Also worth adding : You might want to add a penalty for transaction costs in your utility function with a fixed amount per transaction (and potentially a percent per dollar traded and potentially with a market impact model). This might make the optimization a bit more natural and give you insights when you actually NEED to trade more than usual