Learn R Programming

NMOF (version 2.2-2)

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.

Value

a numeric vector (the portfolio weights)

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).

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

minvar

Examples

Run this code
# NOT RUN {
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))
# }

Run the code above in your browser using DataLab