Sorting stocks more than once to form portfolios

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

ozgoker
Posts: 4
Joined: Sat Mar 27, 2021 1:02 pm

Sorting stocks more than once to form portfolios

Postby ozgoker » Sat Mar 27, 2021 2:52 pm

Hi Everyone
I have a question on Eviews Program Code on sorting.
I have a list of monthly stock returns (f1 to f200) and 2 loadings (Beta1 to Beta200 and Teta1 to Teta200) and 3 Fama French factors (market:rm, Small minus Big:smb, High minus low:hml).
I need to
1- Sort the stocks in the sample into three portfolios based on Beta loading (Beta 1 to Beta200).
2- Sort each of the above three portfolios into terciles based on Teta loading (Teta 1 to Teta200).
3- Hence, this sequential sorting should result in 9 portfolios each month based on Beta and Teta
4- Run rolling regression for each of the 9 portfolio returns on 3 Fama French factors (market, SMB and HML)
Could anyone help me especially on the Eviews code for sorting the stocks into 9 portfolios (3 by on loading and later 3 by another loading) ?
Thanks in advance for your help.
Kind regards
PS: I have the data available for those interested

startz
Non-normality and collinearity are NOT problems!
Posts: 3775
Joined: Wed Sep 17, 2008 2:25 pm

Re: Sorting stocks more than once to form portfolios

Postby startz » Sat Mar 27, 2021 4:05 pm

From the help file...

Syntax
sort(options) arg1 [arg2 arg3…]
List the name of the series or groups by which you wish to sort the workfile. If you list two or more series, sort uses the values of the second series to resolve ties from the first series, and values of the third series to resolve ties from the second, and so on.

ozgoker
Posts: 4
Joined: Sat Mar 27, 2021 1:02 pm

Re: Sorting stocks more than once to form portfolios

Postby ozgoker » Sun Mar 28, 2021 4:03 am

Hi Startz
Thanks for the explanation.
Can I ask how can I form 9 portfolios from 200 stocks' returns (series f1 to f200) by sorting them first on their Betas (series Beta1 to Beta200) and later on their Tetas (series Teta1 to Teta200)?
Many thanks in advance.
Kind regards

startz
Non-normality and collinearity are NOT problems!
Posts: 3775
Joined: Wed Sep 17, 2008 2:25 pm

Re: Sorting stocks more than once to form portfolios

Postby startz » Sun Mar 28, 2021 6:50 am

If the returns are r1, r2 ,r3...etc. and you want equal weighted portfolios then in a month in which the first stocks are 7,3, 9 etc I guess you could do

series portfolio1return = r7+r3+r9 (etc.)

Not sure how you would automate it.

ozgoker
Posts: 4
Joined: Sat Mar 27, 2021 1:02 pm

Re: Sorting stocks more than once to form portfolios

Postby ozgoker » Sun Mar 28, 2021 10:43 pm

Thanks for your help Startz
Let me ask my question of "Creating Portfolios" under a new post.
Kind regards
Özgür


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 24 guests