[R-SIG-Finance] Portfolio Optimization

Whit Armstrong armstrong.whit at gmail.com
Thu Mar 11 21:10:53 CET 2010


well, solve.QP is going to do this optim:

max[   x'E(R) - lambda * x' VCV x ]

Where x is your wgts vector.

You need to set lambda to reflect the amt of risk you want to take.

you can use Grinold and Kahn to decide what lambda should be:

target.lambda <- function(residual.risk, expected.IR, freq) {
    ## Grinold & Kahn page 122
    expected.IR/(2 * residual.risk * sqrt(freq))
}


On Thu, Mar 11, 2010 at 2:48 PM, Heiko Mayer <Heiko-Mayer at gmx.de> wrote:
> Whit,
>
> Thank your for your comment. I have attached the current code that uses a
> target return. As mentioned before, I would like to set a target risk
> instead and solve for the maximum return. Could you please give me a sample
> according to your suggestion below?
>
> library(quadprog)
> # Input
> eReturn=c(0.04,0.05,0.045,0.055) #expected return
> Duration=c(6,7,6.5,7.5) #current duration
> Treturn=0.01 #Target return
> TDuration=2 #Target duration
> # Solver data
> CovMat=cov(matrix(rnorm(400,mean=0,sd=0.05),nrow=100,ncol=4))
> VM=c(rep(0,4))
> A1=cbind(eReturn,Duration)
> CV=c(Treturn,TDuration)
> meq=2
> # Solver
> Res=solve.QP(Dmat=CovMat,dvec=VM,Amat=A1,bvec=CV,meq=meq)
> # Solution summary
> print(Res)
> cat("Duration in years: ",sum(as.matrix(Res$solution) *
> as.matrix(Duration)),"\n")
> cat("Volatility: ",sqrt(Res$value*2),"\n")
> cat("exp. return: ",sum(Res$solution*eReturn),"\n")
> cat("Sum of weights: ",round(sum(Res$solution),digits=2),"\n")
>
> Thank you,
> Heiko
>
> -------- Original-Nachricht --------
> Datum: Tue, 9 Mar 2010 16:19:20 -0500
> Von: Whit Armstrong <armstrong.whit at gmail.com>
> An: Heiko Mayer <Heiko-Mayer at gmx.de>
> CC: r-sig-finance at stat.math.ethz.ch
> Betreff: Re: [R-SIG-Finance] Portfolio Optimization
>
> You can do this w/ solve.QP.
>
> use something like this:
>
> solve.QP(lambda*2*vcv,fcst,Amat,bvec)
>
> and set up Amat and bvec to be the appropriate duration constraints.
>
> -Whit
>
>
> On Tue, Mar 9, 2010 at 3:35 PM, Heiko Mayer <Heiko-Mayer at gmx.de> wrote:
>> Dear all,
>>
>> I am looking for a smart way of portfolio optimization. Currently, I am
>> using solve.QP from quadprog package which is quite useful for MV
>> optimization. However, I would like to create a bond portfolio with
>> duration constraints. It would be possible to use solve.QP as well, but
>> instead of setting a target return and getting the optimal MV portfolio
>> given the duration constraints, I would like to set a target risk,
>> expected
>> returns and the covariance matrix to maximize the portfolio return.
>> So far, I was unlucky finding something the SIG archive and I am afraid
>> solve.QP is not applicable for this task.
>> Any ideas are highly appreciated.
>>
>> Thanks,
>> Heiko
>> --
>>
>> http://portal.gmx.net/de/go/dsl02
>>
>>        [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-SIG-Finance at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> -- Subscriber-posting only. If you want to post, subscribe first.
>> -- Also note that this is not the r-help list where general R questions
>> should go.
>>
>
>
>
> --
> GMX DSL: Internet, Telefon und Entertainment für nur 19,99 EUR/mtl.!
> http://portal.gmx.net/de/go/dsl02



More information about the R-SIG-Finance mailing list