Index-tracking portfolio optimization model
Guillermo Navas-Palencia∗
October 18, 2016

Abstract
In the present tutorial report we examine the theory and computational aspects behind
the index-tracking portfolio optimization model. This model is compared with Markowitz
mean-variance model. This report is distributed with an example in C using the NAG C
Library.

1Introduction

The index-tracking is a form of passive fund management. The index-tracking problem is theproblem of reproducing the performance of a stock market index by considering a portfolioof assets comprised on the index. This approach differs from the full replication strategy,
where a fund purchases all the stocks that make up a particular market index. A passively
managed fund whose objective is to reproduce the return on an index is known as an index
fund, or a tracker fund. The classical index-tracking approach represents the problem in a leastsquare framework with errors computed using a sample of historical data. A new approachdescribed in [2], which this report is based on, replaces the classical risk measure of portfolio
variance by the variance of tracking error between stochastic index return and the return on
the portfolio selection. In this report we formulate the index-tracking portfolio optimization
model and present an illustrative example where we compare the presented model with theclassical Markowitz mean-variance portfolio optimization model.

2Index-tracking optimization model

Consider a market index M and select a portfolio P with n assets. The portfolio P reproduces
the performance of the market index if the return on P , denoted by rP , follows very closely
the return of the index, denoted by rM , at every unit time period. Thus, the goal is to obtain
the portfolio P that minimizes the variance of the difference between both returns, rP and rM .
Denote the return on asset i by ri and its mean by µi , for i = 1, . . . , n. The variance-covariancematrix of assets returns is denoted by V , where σij denotes the covariance between the returnsof two assets, and σii the variance of ri . The covariance between asset returns and market
index returns is given by σiM = Cov (ri , rM ). The beta of asset i relative to the market index
M is given byσiM
βi = 2(1)σM2where σMdenotes the variance of the market index returns. As previously stated, the index22
tracking model aims to minimize Var (rP − rM ) = σP2 + σM− 2σMβP , the so-called measureof goodness of the index-tracking portfolio. Thus, the optimization problems is formulated as∗ Numerical Algorithms Group (NAG) Ltd., Oxford, UK. Email: guillermo.navas@nag.co.uk

1follows

1 T2x V x − σM
βT x2nXµi xi = mminimizexsubject toi=1nX(2)xi = 1i=1

and −1 ≤ xi ≤ 1, i ∈ {1, . . . , n}. Therefore, we need to solve a constrained convex quadratic
programming problem (QP). Given that the matrix V is symmetric positive semi-definitiveand dense, we select the solver e04ncc. The following measures are used to determine thecharacteristics of the optimal portfolio• Portfolio variance: σP2 = xT V x.
Pn
• Portfolio beta: βP = i=1 βi xi .
22
• Portfolio P (measure of goodness): V ar(rp − rM ) = σP2 + σM− 2σMβP .

Note that the tracking-efficient (TE) portfolio is equivalent to Markowitz mean-variance
2β T x is removed from the objective function. A review(MV) portfolio when the linear term −σMof the basic Markowitz portfolio optimization theory and solution using the NAG Library canbe found in [3].

3Example

We present a simple example to illustrate the described methodology. We select 7 technology
stocks in order to track the S&P 500 index. The data for this example was downloaded fromYahoo Finance [4] using a Python script with the module urllib2. For this example wedownloaded monthly prices from 01/2009 to 01/2016, see Figure 1. From a sample of historical
data we can compute the one-period returns for each stock by using the well-known formula
rt =pricet − pricet−1.
pricet−1(3)

Having the returns we can easily determine the mean vector, standard deviation vector,
covariance matrix and beta vector, see Table 1 and 2.
800
700Monthly price

600
500

7 technology stocks from 01/2009 to 01/2016
AAPL
CSCO
GOOG
IBMMSFT
ORCL
YHOO

400
300
200
10000201

12012201

3201
Year

4201

5201

6201

Figure 1: Monthly prices for seven technology stocks from January 2009 to January 2016.

2Asset
ˆGSPC
AAPL
CSCO
GOOGIBMMSFT
ORCL
YHOO

Mean (µ)(%)
1.11
2.82
1.08
2.00
0.72
1.79
1.21
1.49

Std. dev (σ)(%)
4.15
7.44
7.8
7.3
4.57
6.78
6.96
8.47

Beta (β)
1.026
1.250
0.975
0.595
0.994
1.199
0.941

Table 1: Mean, standard deviation and beta.

AAPL
CSCO
GOOG
IBM
MSFT
ORCL
YHOO

AAPL
0.005528
0.002689
0.001983
0.001417
0.001996
0.0021670.001418

CSCO
0.002689
0.006082
0.002637
0.001873
0.002812
0.003305
0.002146

GOOG
0.001983
0.002637
0.005324
0.001132
0.002193
0.001718
0.001765IBM
0.001417
0.001873
0.001132
0.002084
0.001021
0.001571
0.000677

MSFT
0.001996
0.002812
0.002193
0.001021
0.004599
0.002502
0.001350

ORCL
0.002167
0.003305
0.001718
0.001571
0.002502
0.004843
0.002146

YHOO
0.001418
0.002146
0.001765
0.000677
0.001350
0.002146
0.007173Table 2: Variance-covariance matrix V .
Following the example in [2], we set the desired portfolio mean m = µM , where µM represents S&P 500 index mean return. Table 3 shows that the index-tracking model, using themarket index mean, reduces the number of short positions in the portfolio with respect toMarkowitz portfolio. Markowitz portfolio has 2 short positions (CSCO and ORCL) whereas
the index-tracking portfolio only one short position (AAPL). In addition, the index-tracking
portfolio tends to reduce extreme position, for example IBM changes the long position from
72.1% to a more conservative 44.9%.
TickerAAPLCSCO
GOOGIBM
MSFT
ORCL
YHOO

MV
0.019969-0.123901
0.076037
0.721647
0.171989-0.001755
0.136014

TE-0.023608
0.072067
0.076785
0.449256
0.115741
0.193798
0.115961

Table 3: Mean-variance and index-tracking optimal portfolios.
Table 4 shows the main portfolio measures. The value of the measure of goodness indicatesthat the TE portfolio tracks the S&P 500 index more closely with Var (rP − rM ) = 0.000707
compared with the MV portfolio, Var (rP − rM ) = 0.001049.
MeasurePortfolio variance
Portfolio beta
Measure of goodness

MV0.001620
0.666135
0.001049

TE0.001962
0.864691
0.000707

Table 4: Portfolio measures.

3

3.1

Compilation

The presented problem has been solved using the NAG C Library. For example to compile
it with NAG C Library for Linux Mark 25, CLL6I25DCL, using the gcc compiler follow theinstructions below. For other platforms please refer to the appropriate User’s notes of yourNAG C Library, see https://www.nag.co.uk/doc/inun/cl25.html
Listing 1: Linux instructions.
gcc - O3 index_ trackin g . c -I ../ CL25 / cll6i25dcl / include /../ CL25 / cll6i25dcl / lib / libnagc_nag . so - lpthread - lm -o index_tr acking . exe

Listing 2: To run the example we pass the downloaded data as standard input.
./ index_ tracking . exe < index_ trackin g . txt

Listing 3: Example data.
7 85
GSPC AAPL CSCO GOOG IBM MSFT ORCL YHOO
1.9 E +03 9.8 E +01 2.5 E +01 7.3 E +02 1.3 E +02

5.2 E +01

3.5 E +01 3.1 E +01

Listing 4: Example output.
Optimal portfolio selection :---------------------------GSPC : market index
AAPL : -2.36%
CSCO :
7.21%
GOOG :
7.68%
IBM : 44.93%
MSFT : 11.57%
ORCL : 19.38%
YHOO : 11.60%
Portfolio measures :---------------------------Portfolio variance : 0.001962
Portfolio beta: 0.864691
Measure of goodness : 0.000707

4Conclusions

We described one of the available methods for index-tracking optimal portfolio selection. Finally, a different approach for this problem based on heuristics is presented in [1].

References[1] J. E. Beasley, N. Meade, T. -J. Chang. An evolutionary heuristic for the index tracking
problem. European Journal of Operational Research, 148, 621-643, (2003).
[2] N. C. P. Edirisinghe Index-tracking optimal portfolio selection. Quantitative Finance Letters, vol. 1, 16-20, (2013).
[3] NAG Technical report. Portfolio Optimization using the NAG Library. (2015).
http://www.nag.co.uk/doc/techrep/pdf/tr1_15.pdf[4] Yahoo Finance. Historical stock data. https://finance.yahoo.com

4