Skip to content

Newbie Question: Portfolio Optimization with MV, LPM and CVaR constraints

3 messages · Jonathan Ling, Brian G. Peterson, julien cuisinier

#
Hi there,

I'd start of by apologizing if the following has been answered in previous
discussions or materials, so far my searches haven't been resourceful.

I have a project on portfolio optimization to track performances of
portfolios created under different constraints (mean-variance, LPM, VaR and
CVaR). I've used monthly data (for 12 years) for a couple of shares, and I
stumbled on fPortfolio which I've been trying out for the last 2 weeks.

I'm having trouble figuring out a couple of things.

1. Is it possible for fPortfolio to optimize a portfolio constrained by the
VaR?

2. Would it be possible to use the first 10 years of my data to optimize the
portfolios and track performances at 6 months, 1 year and 2 years after
that?

3. I'm having some trouble with the LPM method of optimization. It's
spitting out the error below, but only on monthly data, it works fine with
weekly data.

Here's my codes:

dataset <-read.table("Portfolio1.csv",header=T,sep=",")        
data <- timeSeries(dataset)
data <- returns(data, type = "continuous")

mvspec = portfolioSpec()

lpmspec = portfolioSpec()
setEstimator(lpmspec) <- "lpmEstimator"
setType(lpmspec) <- "QLPM"
lpmspec at model$param$a <- 2
lpmspec at model$param$tau <- "colMeans"

cvarspec = portfolioSpec()
setType(cvarspec) = "CVaR"
setAlpha(cvarspec) = 0.05
setSolver(cvarspec) = "solveRsymphony"

tangencyPortfolio(data, mvspec)

tangencyPortfolio(data, cvarspec)

tangencyPortfolio(data, lpmspec)

which is spitting out the following error:

Execution stopped:
  The maximum ratio portfolio could not be computed.
Possible Reason:
  Your portfolio constraints may be too restrictive.
Status Information:
  status=2 from solver solveRquadprog.
Error: 
  returned from Rmetrics
In addition: There were 15 warnings (use warnings() to see them)

However, it works on weekly data..?

dataset2 <-read.table("weeklydata.csv",header=T,sep=",")
weeklydata <- timeSeries(dataset2)

tangencyPortfolio(weeklydata, lpmspec)


Data
Monthly:  http://www.nabble.com/file/p25398920/Portfolio1.csv Portfolio1.csv 
Weekly:  http://www.nabble.com/file/p25398920/weeklydata.csv weeklydata.csv 


If anyone is able to point me in the right direction, I'd be extremely
grateful! Thanks~
#
Jonathan Ling wrote:
No. 

VaR optimization does not have an analytical solution, as VaR is not a 
coherent measure that can be transformed into a linear programming or 
other similar method.  I've previously used a combination of grid search 
and library("Rdonlp2") to do VaR optimization.  fPortfolio development 
code has some support for these methods, but it isn't complete or 
released, to the best of my knowledge.

With only 2 instruments, you can easily do grid search and solve the VaR 
optimization problem via brute force. (with 200 this would obviously be 
computationally infeasible)
Yes, in general, you'd set your weights and then float.

Please be aware that the code in fPortfolio used to assume continuous 
rebalancing to maintain your weights.  You'll need to assess whether 
this is still the case.  If the fPortfolio code still uses continuous 
rebalancing, to allow your weights to "float" after the initial 
allocation, the calculation is a little more complicated.  We have some 
code that we haven't quite finished documenting and testing for release 
yet that does this, and I'd be happy to test it on your data and 
allocation weights and share it with you.
I've never done LPM optimization, so perhaps another fPortfolio user or 
Diethelm or Yohan can help you out with that part of your query.

Regards,

  - Brian