Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# Re: st: Implementing a Momentum Investment Strategy with Stata

 From Richard Herron To statalist@hsphsun2.harvard.edu Subject Re: st: Implementing a Momentum Investment Strategy with Stata Date Sun, 4 Mar 2012 17:40:42 -0500

```I don't think there's a need to use -rolling-. I think there are two
main steps here. Generating the portfolios, then generating the time
series of returns for eash of these portfolios.

I would generate the portfolios using -xtile- from the -egemore- package (SSC).

generate ret6 = s6.price / l6.price
egen portfolio = xtile(ret6), nquantiles(10) by(date_ym)

where -ret6- is your holding period return and -date_ym- is the
year-month date (say 2001m5). Now generate the portfolio holding
period returns using collapse and time series operators.

collapse (mean) f6.ret6, by(date_ym portfolio)

You may also want to use weightings to determine portfolio weights
(although I think Jegadeesh and Titman is all equally weighted). Now
you can use these portfolios to generate returns to your strategy.
HTH.

On Sun, Mar 4, 2012 at 09:20, Robson Glasscock <glasscockrc@vcu.edu> wrote:
> Christopher Baum's "An Introduction to Stata Programming" discusses
> moving-windows in Chapter 8. The -rolling- command is mentioned as
> well as Cox and Baum's -mvsumm- and -mvcorr- programs (available from
> SSC). Looking into these may help you think about a modified approach
> to your problem.
>
> Instead of using matrices, I wonder if it would be better to generate
> two new variables that would help you identify the top 10% of firms in
> each window. First, generate a "window" variable that would take on a
> value of 1 for months 1-6, 2 for months 2-7, 3 for months 3-8, etc.
> Second, generate an "identifier" variable that tags the top 10% of
> firms in each window. You would know exactly which firms were included
> in each window and then it would be possible for you to calculate the
> returns for those firms over the next six months. Or maybe clever use
> of -rolling- is the better approach here. I'm not sure, but I hope
> this is enough to get you started.
>
> best,
> Robson Glasscock
>
>
> On Sun, Mar 4, 2012 at 7:43 AM,  <schmani@gmx.de> wrote:
>> Dear all,
>>
>> I am trying to implement a Momentum Strategy following Jegadeesh/Titman(1993): Returns to Buying Winners and Selling Losers: Implications for Stock Market Efficiency, JoF 48(1), pp. 65-91.
>>
>> I have monthly returns for ~1400 stocks for a total of 385 time periods and now have to proceed in the following way:
>>
>> 1) build cumulated returns over a formation period of 6months (I did that by generating new variables)
>>
>> 2) select the top 10% performing stocks in order to invest. This is done every month in order to generate so-called "overlapping" portfolios.
>>
>> 3) invest in those stocks for a holding period of 6 months
>>
>> 4) determine the average of the returns and adjust for risk
>>
>>
>> For now, my approach was to generate matrices for every month t that consist of the cumulated returns over the previous 6 months.
>> However I can not find an efficient way to sort these matrices while being able to identify which assets to invest in (this is crucial as I need to tell Stata somehow which assets to invest in).
>>
>> I am sure there is a better way to sort the cumulated returns of the previous 6 months in every month t while still being able to somehow "track" the variable name in order to invest in the corresponding stock.
>> I hope I made myself clear, any help would be greatly appreciated!
>>
>> Best,
>> Daniel
>> --
>> NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!
>> Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/statalist/faq
>> *   http://www.ats.ucla.edu/stat/stata/
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```