## Optimal portfolio weights

For questions and discussion related to graphs, reports, and other output, including issues related to presenting or publishing results.

### Optimal portfolio weights

Hi

It is easy enough to compute efficient frontiers given a set of return time series. However, I have not been able to find a way to store the optimal portfolio weights for the various points in the efficient frontier. How could this be implemented?

Cheers,
ylijohtaja

Posts: 23
Joined: Fri Nov 13, 2009 7:15 am

### Re: Optimal portfolio weights

In (for instance) PORTFOLIO.RPF, wouldn't a COPY instruction applied to ERETS and the corresponding SRETS and/or SRETSRF series do it?
TomDoan

Posts: 7240
Joined: Wed Nov 01, 2006 5:36 pm

### Re: Optimal portfolio weights

Yes, I did use PRINT(window='name') to get the erets and srets series already (so, I do get the efficient frontier points), but what I would need are the optimal portfolio weights for each asset for each expected return point - I apologize for being unclear in my first message.
ylijohtaja

Posts: 23
Joined: Fri Nov 13, 2009 7:15 am

### Re: Optimal portfolio weights

In PORTFOLIO.RPF, you would need to add the lines in red to save the portfolio weights. This will create a VECT[SERIES] with n elements with each entry in that corresponding to the test value of ERETS. (The LQPROG instruction needs the X parameter to save the weights---the first LQPROG in the example doesn't, this one does, though in the original program, it doesn't actually use it for anything).

dec vect[series] pweights(n)
do i=1,n
set pweights(i) 1 101 = 0.0
end do i
*
do t=1,101
lqprog(noprint,q=omega,a=arf,b=erets(t)-rf,equalities=1) x
compute sretsrf(t)=sqrt(2.0*%funcval)
compute %pt(pweights,t,x)
end do t
TomDoan

Posts: 7240
Joined: Wed Nov 01, 2006 5:36 pm

### Re: Optimal portfolio weights

This works well - many thanks!
ylijohtaja

Posts: 23
Joined: Fri Nov 13, 2009 7:15 am

### Re: Optimal portfolio weights

Hi Tom,

how would you efficiently modify the code so that instead of minimising variance s.t. target expected return, you maximise the Sharpe Ratio and pull out those weights?

Many thanks

TomDoan wrote:In PORTFOLIO.RPF, you would need to add the lines in red to save the portfolio weights. This will create a VECT[SERIES] with n elements with each entry in that corresponding to the test value of ERETS. (The LQPROG instruction needs the X parameter to save the weights---the first LQPROG in the example doesn't, this one does, though in the original program, it doesn't actually use it for anything).

dec vect[series] pweights(n)
do i=1,n
set pweights(i) 1 101 = 0.0
end do i
*
do t=1,101
lqprog(noprint,q=omega,a=arf,b=erets(t)-rf,equalities=1) x
compute sretsrf(t)=sqrt(2.0*%funcval)
compute %pt(pweights,t,x)
end do t
Baroni77

Posts: 8
Joined: Wed Aug 07, 2013 6:50 am

### Re: Optimal portfolio weights

Based upon the second analysis (with the risk-free asset):

lqprog(q=omega,a=arf,b=1.0,equalities=1) y
compute x=y/%sum(y)

which minimizes the variance for a given mean, then renormalizes the weights to sum to 1.
TomDoan

Posts: 7240
Joined: Wed Nov 01, 2006 5:36 pm

Return to Graphics, Reports, and Other Output

### Who is online

Users browsing this forum: No registered users and 2 guests 