# Return-based tracking portfolios

In this note we shall look at simple return-based tracking-portfolio models. A tracking portfolio is one that tries to come close to another portfolio, e.g. to replicate its performance, or to explain its risk (see e.g. Sharpe, 1992). I shall refer to the portfolio to be tracked as the benchmark.

Let $$r$$ be the return of the portfolio, and $$r^{\scriptsize\mathrm{b}}$$ the return of the benchmark. Then a tracking portfolio should be one for which the absolute return difference $\mid r - r^{\scriptsize\mathrm{b}} \mid$ is 'small' in some sense. Typical specifications include the mean absolute value of the difference, or the mean square, or the variance. (Note that the minimising the mean of return differences is equivalent to minimising their sum.)

Suppose have ns return scenarios (which might be historical data) for na assets. Let us create some random data, stored in a matrix R. Every column holds the returns of one asset; every row holds the returns at one point in time.

library("NMOF")
ns <- 24
na <- 5
R <- randomReturns(na = 1 + na,
ns = ns,
sd = 0.03,
mean = 0.005,
rho = 0.7)
var <- cov(R)


Note that I have created 1 + na columns. The first asset is the benchmark. The remaining assets are those that we use to build a tracking portfolio. The variance–covariance matrix is computed from all columns.

When we minimise squares or variance, we can conveniently simplify the model and write it as a quadratic programme. For its solution, we can use solve.QP from package quadprog. The set up is the following.

wmin <- rep(0, na)     ## no short-sales
wmax <- rep(0.5, na)   ## maximum weight is 50%
A <- rbind(rep(1, na), -diag(na), diag(na))
b <- c(1, -wmax, wmin)
cbind(A = A, b)

                        b
[1,]  1  1  1  1  1  1.0
[2,] -1  0  0  0  0 -0.5
[3,]  0 -1  0  0  0 -0.5
[4,]  0  0 -1  0  0 -0.5
[5,]  0  0  0 -1  0 -0.5
[6,]  0  0  0  0 -1 -0.5
[7,]  1  0  0  0  0  0.0
[8,]  0  1  0  0  0  0.0
[9,]  0  0  1  0  0  0.0
[10,]  0  0  0  1  0  0.0
[11,]  0  0  0  0  1  0.0


It remains to call solve.QP. The matrix Dmat is the variance–covariance matrix of our assets, and dvec is the vector of covariances between our assets and the benchmark (see Gilli 2019, chapter 14). Note that we use only the variance–covariance matrix, not R.

library("quadprog")
sol.qp <- solve.QP(Dmat = var[-1, -1],
dvec = var[1, -1],
Amat = t(A),
bvec = b,
meq  = 1L)


Let us provide some 'computational proof' that this computation indeed minimises the variance of return differences by using a more direct way of optimisation.

The function te computes the variance of $$R_{-1}w - R_1$$, in which $$R_{-1}$$ is our matrix R without the first column, and $$R_1$$ is the first column of matrix R, i.e. the benchmark returns.

te <- function(w, R)
var(R[, -1] %*% w - R[, 1])


Now we run a Local Search: the algorithm will move through the space of portfolios and find a portfolio that minimises te.

library("neighbours")  ## https://github.com/enricoschumann/neighbours
nb <- neighbours::neighbourfun(type = "numeric",
min = 0,    ## no short-sales
max = 0.5,  ## maximum weight is 50%
stepsize = 0.01)

sol.ls <- LSopt(te,
list(neighbour = nb,
nI = 2000,
x0 = rep(1/na, na)),
R = R)


Let us compare the solutions (i.e. portfolio weights) of both methods.

data.frame(QP = round(100*sol.qp$solution, 1), LS = round(100*sol.ls$xbest, 1))

    QP   LS
1 44.9 44.9
2 21.9 21.9
3 25.4 25.4
4  0.0  0.0
5  7.8  7.8


A nice thing about the Local Search is that we can easily change it: if wanted another definition of 'small' instead of variance, we could simply write it into the objective function. See for instance Gilli and Këllezi (2002).

The NMOF package has a function trackingPortfolio that implements the computation of such tracking portfolios.

## References

@INPROCEEDINGS{Gilli2002,
author    = {Manfred Gilli and Evis K{\"e}llezi},
title     = {The Threshold Accepting Heuristic for Index Tracking},
booktitle = {Financial Engineering, E-Commerce and Supply Chain},
year      = 2002,
editor    = {P. Pardalos and V. K. Tsitsiringos},
series    = {Applied Optimization Series},
pages     = {1--18},
}

@ARTICLE{Sharpe1992,
author    = {Sharpe, William F.},
title     = {Asset Allocation: Management Style and Performance Measurement},
year      = 1992,
journal   = {Journal of Portfolio Management},
volume    = 18,
number    = 2,
pages     = {7--19}
url       = {http://www.stanford.edu/~wfsharpe/art/sa/sa.htm},
}

@BOOK{Gilli2019,
title     = {Numerical Methods and Optimization in Finance},