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,

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

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:**7236**Joined:**Wed Nov 01, 2006 5:36 pm

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

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

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:**7236**Joined:**Wed Nov 01, 2006 5:36 pm

This works well - many thanks!

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

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

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

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.

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:**7236**Joined:**Wed Nov 01, 2006 5:36 pm

7 posts
• Page **1** of **1**

Return to Graphics, Reports, and Other Output

Users browsing this forum: No registered users and 1 guest