optimalPortfolios: Calculates optimal portfolios under prior and posterior...

Description Usage Arguments Details Value Note Author(s) References Examples

Description

These are wrapper functions that calculate optimal portfolios under the prior and posterior return distributions. optimalPortfolios works with a user-supplied optimization function, though simple Markowitz minimum-risk optimization is done with solve.QP from quadprog if none is supplied. optimalPortfolios.fPort is a generic utility function which calculates optimal portfolios using routines from the fPortfolio package.

Usage

1
2
3
optimalPortfolios(result, optimizer = .optimalWeights.simpleMV, ..., doPlot = TRUE, beside = TRUE)
optimalPortfolios.fPort(result, spec = NULL, constraints = "LongOnly", optimizer = "minriskPortfolio", 
    inputData = NULL, numSimulations = BLCOPOptions("numSimulations")) 

Arguments

result

An object of class BLResult

optimizer

For optimalPortfolios, An optimization function. It should take as arguments a vector of means and a variance-covariance matrix, and should return a vector of optimal weights. For optimalPortfolios, the name of a fPortfolio function that performs portfolio optimization

spec

Object of class fPORTFOLIOSPEC. If NULL, will use a basic mean-variance spec for Black-Litterman results, and a basic CVaR spec for COP results

inputData

Time series data (any form that can be coerced into a timeSeries object)

constraints

String of constraints that may be passed into fPortfolio optimization routines

numSimulations

For COP results only - the number of posterior simulations to use in the optimization (large numbers here will likely cause the routine to fail)

...

Additional arguments to the optimization function

doPlot

A logical flag. Should barplots of the optimal portfolio weights be produced?

beside

A logical flag. If a barplot is generated, should the bars appear side-by side? If FALSE, differences of weights will be plotted instead.

Details

By default, optimizer is a simple function that performs Markowitz optimization via solve.QP. In addition to a mean and variance, it takes an optional constraints parameter that if supplied should hold a named list with all of the parameters that solve.QP takes.

Value

optimalPortfolios will return a list with the following items:

priorPFolioWeights

The optimal weights under the prior distribution

postPFolioWeights

The optimal weights under the posterior distribution

optimalPortfolios.fPort will return a similar list with 2 elements of class fPORTFOLIO.

Note

It is expected that optimalPortfolios will be deprecated in future releases in favour of optimalPortfolios.fPort.

Author(s)

Francisco Gochez <fgochez@mango-solutions.com>

References

Wuertz, D., Chalabi, Y., Chen W., Ellis A. (2009); Portfolio Optimization with R/Rmetrics, Rmetrics eBook, Rmetrics Association and Finance Online, Zurich.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
	## Not run: 
	    entries <- c(0.001005,0.001328,-0.000579,-0.000675,0.000121,0.000128,-0.000445,-0.000437 ,
	     0.001328,0.007277,-0.001307,-0.000610,-0.002237,-0.000989,0.001442,-0.001535 ,
	     -0.000579,-0.001307,0.059852,0.027588,0.063497,0.023036,0.032967,0.048039 ,
	    -0.000675,-0.000610,0.027588,0.029609,0.026572,0.021465,0.020697,0.029854 ,
	     0.000121,-0.002237,0.063497,0.026572,0.102488,0.042744,0.039943,0.065994 ,
	     0.000128,-0.000989,0.023036,0.021465,0.042744,0.032056,0.019881,0.032235 ,
	    -0.000445,0.001442,0.032967,0.020697,0.039943,0.019881,0.028355,0.035064 ,
	    -0.000437,-0.001535,0.048039,0.029854,0.065994,0.032235,0.035064,0.079958 )
	    
	    varcov <- matrix(entries, ncol = 8, nrow = 8)
	    mu <- c(0.08, 0.67,6.41, 4.08, 7.43, 3.70, 4.80, 6.60) / 100
	    pick <- matrix(0, ncol = 8, nrow = 3, dimnames = list(NULL, letters[1:8]))
	    pick[1,7] <- 1
	    pick[2,1] <- -1; pick[2,2] <- 1
	    pick[3, 3:6] <- c(0.9, -0.9, .1, -.1)
	    confidences <- 1 / c(0.00709, 0.000141, 0.000866)
	    views <- BLViews(pick, c(0.0525, 0.0025, 0.02), confidences, letters[1:8])
	    posterior <- posteriorEst(views, tau = 0.025, mu, varcov )
	    optimalPortfolios(posterior, doPlot = TRUE)
    
    	optimalPortfolios.fPort(posterior, optimizer = "tangencyPortfolio")
    	
    	# An example based on one found in "Beyond Black-Litterman:Views on Non-normal Markets"
        dispersion <- c(.376,.253,.360,.333,.360,.600,.397,.396,.578,.775) / 1000
        sigma <- BLCOP:::.symmetricMatrix(dispersion, dim = 4)
        caps <- rep(1/4, 4)
        mu <- 2.5 * sigma 
        dim(mu) <- NULL
        marketDistribution <- mvdistribution("mt", mean = mu, S = sigma, df = 5 )
        pick <- matrix(0, ncol = 4, nrow = 1, dimnames = list(NULL, c("SP", "FTSE", "CAC", "DAX")))
        pick[1,4] <- 1
        vdist <- list(distribution("unif", min = -0.02, max = 0))
    
        views <- COPViews(pick, vdist, 0.2, c("SP", "FTSE", "CAC", "DAX"))
        posterior <- COPPosterior(marketDistribution, views)
    
        optimalPortfolios.fPort(myPosterior, spec = NULL, optimizer = "minriskPortfolio", inputData = NULL, 
			numSimulations  = 100	)
	
    
## End(Not run)

BLCOP documentation built on May 2, 2019, 6:15 p.m.