12
$\begingroup$

The optimal re-balancing strategy takes account of factors including i) objective function, ii) current portfolio weights, iii) expected return vector containing updated views/alpha forecasts, iv) uncertainty in the alpha forecasts, v) transaction costs, vi) risk aversion, and vii) constraints (long-only, turnover, etc.).

Question - Are there any libraries in R that return the optimal weight vector as a function of these inputs and related reporting? Or should I select one of the many optimizers in R and build out all the wonderful optimization reporting (risk budgeting, contribution to risk, etc.) that the rmetrics team has already done?

Below I describe why the rmetrics package does not solve the problem:

The challenge is that the rmetrics optimization procedure identifies the optimal portfolio without reference to current vector of portfolio weights, updated alpha forecasts, and transactions costs. The correct procedure performed periodically would be to specify the path of the portfolio along a line where the marginal transaction cost is just offset by the marginal expected return (or marginal risk reduction) in the utility function. The marginal return would be the output of a forecasting model as opposed to using the mean return. The fPortfolioBacktest anticipates this issue and attempts to smooth the change in weights from period to period. But we can do better by having the optimizer confront the trade-off directly.

$\endgroup$

2 Answers 2

8
$\begingroup$

The PortfolioAnalytics package will create weights without reference to current weights, if that's what you want. It should also have much of the reporting that you like from Rmetrics fPortfolio.

There is a longer seminar presentation on Portfolioanalytics from 2010's R/Finance conference here: Complex Portfolio Optimization with Generalized Business Objectives

$\endgroup$
3
  • $\begingroup$ The links and example in powerful is great - thanks! Your choice of optimizer seems general enough to solve the optimization problem while also referencing current weights. I believe I can pass an additional penalty to the objective function that measures the distance from the current weight vector to the weight vector the optimizer is solving for time a constant (e.g. transactions costs). Since your optimizer can take expected return as an input I expect it could take a current weight vector as well. This would enable me to optimize in the presence of transaction costs. $\endgroup$ Commented Jul 27, 2011 at 17:37
  • $\begingroup$ Brian, 1) Can the PortfolioAnalytics function handle custom constraints (example: sector-neutral weights)? The constraint class looks pre-specified. 2) Also, I see that the optimize.portfolio function can accept a matrix of returns. I have a posterior distribution of expected market returns (i.e. K possible realizations of market returns for N assets resulting from MCMC). Can this function identify the optimal weight vector with respect to the sampling from the posterior? Of course, I would continue to use covariance of historical returns (de-noised) for calculation of ES. Thanks! $\endgroup$ Commented Aug 3, 2011 at 0:11
  • 2
    $\begingroup$ All the components of the objective are arbitrary R functions. The package takes care of the 'wrapper' around all of that, basic box constraints and full investment constraint, dealing with the optimization engines, etc. The objective is layered (and separately multiplied/penalized) by each arbitrary function you define. There was a discussion on R-SIG-Finance this week here showing a custom objective that isn't in the 'standard' model of using returns the way a modified Markowitz approach does. $\endgroup$ Commented Aug 5, 2011 at 14:29
7
$\begingroup$

This is the website to the R/Finance conference this year. Tons of great links.

http://www.rinfinance.com/agenda/

Brian Peterson's slide (Building and Testing Quantitative Strategy Models in R) mentions Portfolio-Analytics (which I think is based on R/Metrics).

And here is a paper based on Portfolio-Analytics.

http://cran.r-project.org/web/packages/portfolio/vignettes/portfolio.pdf

I am a Python guy (not R) so I can't say if my response exactly answers your question but it may be a good starting place.

$\endgroup$
2
  • 1
    $\begingroup$ Good suggestions... but I'll help out since you're not an R guy. :) The Portfolio-Analytics Brian mentions isn't related to R-metrics; he's referring to the PortfolioAnalytics package on R-forge. $\endgroup$ Commented Jul 25, 2011 at 11:09
  • $\begingroup$ Thanks all. I looked at the vignette attached. This package takes as input a portfolio with a set of weights. I am looking for an optimizer to discover the optimal set of weights given the objective funcion and constraints above. So this module would be used downstream after the optimizer. The R-Finance content is a goldmine - thank you for sharing that - but doesn't seem to have anything on portfolio construction and optimization $\endgroup$ Commented Jul 25, 2011 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.