Optimal portfolio weights

For questions and discussion related to graphs, reports, and other output, including issues related to presenting or publishing results.
ylijohtaja
Posts: 23
Joined: Fri Nov 13, 2009 6:15 am

Optimal portfolio weights

Unread post by ylijohtaja »

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,
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Optimal portfolio weights

Unread post by TomDoan »

In (for instance) PORTFOLIO.RPF, wouldn't a COPY instruction applied to ERETS and the corresponding SRETS and/or SRETSRF series do it?
ylijohtaja
Posts: 23
Joined: Fri Nov 13, 2009 6:15 am

Re: Optimal portfolio weights

Unread post by ylijohtaja »

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.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Optimal portfolio weights

Unread post by TomDoan »

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
ylijohtaja
Posts: 23
Joined: Fri Nov 13, 2009 6:15 am

Re: Optimal portfolio weights

Unread post by ylijohtaja »

This works well - many thanks!
Baroni77
Posts: 8
Joined: Wed Aug 07, 2013 6:50 am

Re: Optimal portfolio weights

Unread post by Baroni77 »

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
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Optimal portfolio weights

Unread post by TomDoan »

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.
Post Reply