# Design of Portfolio of Stocks to Track an Index

Computation of sparse portfolios for financial index tracking, i.e., joint selection of a subset of the assets that compose the index and computation of their relative weights (capital allocation). The level of sparsity of the portfolios, i.e., the number of selected assets, is controlled through a regularization parameter. Different tracking measures are available, namely, the empirical tracking error (ETE), downside risk (DR), Huber empirical tracking error (HETE), and Huber downside risk (HDR). See vignette for a detailed documentation and comparison, with several illustrative examples. The package is based on the paper: K. Benidis, Y. Feng, and D. P. Palomar, "Sparse Portfolios for High-Dimensional Financial Index Tracking," IEEE Trans. on Signal Processing, vol. 66, no. 1, pp. 155-170, Jan. 2018. .

## output: html_document: variant: markdown_github keep_md: true md_document: variant: markdown_github

Computation of sparse portfolios for financial index tracking, i.e., joint selection of a subset of the assets that compose the index and computation of their relative weights (capital allocation). The level of sparsity of the portfolios, i.e., the number of selected assets, is controlled through a regularization parameter. Different tracking measures are available, namely, the empirical tracking error (ETE), downside risk (DR), Huber empirical tracking error (HETE), and Huber downside risk (HDR). See vignette for a detailed documentation and comparison, with several illustrative examples.

The package is based on the paper:

K. Benidis, Y. Feng, and D. P. Palomar, "Sparse Portfolios for High-Dimensional Financial Index Tracking," IEEE Trans. on Signal Processing, vol. 66, no. 1, pp. 155-170, Jan. 2018. (https://doi.org/10.1109/TSP.2017.2762286)

## Vignette

For more detailed information, please check the vignette: GitHub-html-vignette and GitHub-pdf-vignette.

## Usage of spIndexTrack()

We start by loading the package and real data of the index S&P 500 and its underlying assets:

The data INDEX_2010 contains a list with two xts objects: 2. SP500: A $T\times 1$ xts with the daily linear returns of the index S&P 500 during the same period.

Note that we use xts objects just for illustration purposes. The function spIndexTracking() can also be invoked passing simple data arrays or dataframes.

Based on the above quantities we create a training window, which we will use to create our portfolios, and a testing window, which will be used to assess the performance of the designed portfolios. For simplicity, here we consider the first six (trading) months of the dataset (~126 days) as the training window, and the subsequent six months as the testing window:

Now, we use the four modes (four available tracking errors) of the spIndexTracking() algorithm to design our portfolios:

Finally, we plot the actual value of the index in the testing window in comparison with the values of the designed portfolios: