Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

trackingPortfolio

Compute a Tracking Portfolio


Description

Computes a portfolio similar to a benchmark, e.g. for tracking the benchmark's performance or identifying factors.

Usage

trackingPortfolio(var, wmin = 0, wmax = 1,
                  method = "qp", objective = "variance", R)

Arguments

var

the covariance matrix: a numeric (real), symmetric matrix. The first asset is the benchmark.

R

a matrix of returns: each colums holds the returns of one asset; each rows holds the returns for one observation. The first asset is the benchmark.

wmin

numeric: a lower bound on weights. May also be a vector that holds specific bounds for each asset.

wmax

numeric: an upper bound on weights. May also be a vector that holds specific bounds for each asset.

method

character. Currently, "qp" and "ls" are supported.

objective

character. Currently, "variance" and "sum.of.squares" are supported.

Details

With method "qp", the function uses solve.QP from package quadprog. Because of the algorithm that solve.QP uses, var has to be positive definite (i.e. must be of full rank).

Value

a numeric vector (the portfolio weights)

Author(s)

Enrico Schumann

References

Gilli, M., Maringer, D. and Schumann, E. (2019) Numerical Methods and Optimization in Finance, 2nd edition. Elsevier. https://www.elsevier.com/books/numerical-methods-and-optimization-in-finance/gilli/978-0-12-815065-8

Schumann, E. (2020) Financial Optimisation with R (NMOF Manual). http://enricoschumann.net/NMOF.htm#NMOFmanual

Sharpe, W. F. (1992) Asset Allocation: Management Style and Performance Measurement. Journal of Portfolio Management. 18 (2), 7–19. https://web.stanford.edu/~wfsharpe/art/sa/sa.htm

See Also

Examples

ns <- 120
R <- randomReturns(na = 1 + 20,
                   ns = ns,
                   sd = 0.03,
                   mean = 0.005,
                   rho = 0.7)

var <- cov(R)

sol.qp <- trackingPortfolio(var, wmax = 0.4)
sol.ls <- trackingPortfolio(var = var, R = R, wmax = 0.4, method = "ls")
data.frame(QP = round(100*sol.qp, 1),
           LS = round(100*sol.ls, 1))

sol.qp <- trackingPortfolio(var, R = R, wmax = 0.4,
                            objective = "sum.of.squares")
sol.ls <- trackingPortfolio(var = var, R = R, wmax = 0.4, method = "ls",
                            objective = "sum.of.squares")
data.frame(QP = round(100*sol.qp, 1),
           LS = round(100*sol.ls, 1))

NMOF

Numerical Methods and Optimization in Finance

v2.4-1
GPL-3
Authors
Enrico Schumann [aut, cre] (<https://orcid.org/0000-0001-7601-6576>)
Initial release
2021-04-09

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.