Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • momentum portfolio

    Dear,
    I am constructing a 2 month momentum strategy, which means buy the top 10% stocks at t0 with the highest average return at t-1 and t-2 and sell the bottom 10% stocks with the lowest average return at t-1 and t-2. I want to form portfolios consisting of the top 10% stocks with the highest 2 months prior return, hold them for 2 months and then sell them and again pick at t3 the stocks with the highest 2 months prios returns and so on. Being able to test if this strategy is lucrative I need for every portfolio the monthly average weighted returns.

    So I need at the and someting like this:
    Monthly average weighted returns
    portfolio:1 2 3
    top 10% middle 80% bottom 10%
    10-6-2012: 4% 3% 1%
    11-6-2012: 4.5% 4% 2%
    ......

    I have managed to calculate the 2 months lagged returns for every stock at every date for the sample period 2012-2017. Here is a dataex:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int(date stock) double(MV P) float(month return_pct L2return_pct retL2return_pct bucket)
    19333 1           96780.31              25.89 635   -4.461182           .          . .
    19364 1           99930.44 26.490000000000002 636   2.2650056   .57311887  2.9520695 .
    19395 1           95818.56 25.400000000000002 637  -4.2913384   -4.461182 -.03807145 .
    19423 1            96233.5              25.51 638   .43120345   2.2650056  -.8096237 .
    19454 1           93259.13             24.555 639   -3.889228  -4.2913384 -.09370273 .
    19484 1           99734.69              26.26 640    6.492764   .43120345   14.05731 .
    19515 1           94227.63 24.810000000000002 641   -5.844418   -3.889228  .50271904 .
    19545 1           93495.56             24.465 642   -1.410178    6.492764  -1.217192 .
    19576 1            92597.5              24.23 643   -.9698721   -5.844418  -.8340515 .
    19607 1           94317.19              24.68 644   1.8233387   -1.410178  -2.292985 .
    19637 1           92887.81 24.060000000000002 645   -2.576891   -.9698721  1.6569393 .
    19668 1           95841.19 24.825000000000003 646    3.081571   1.8233387   .6900706 .
    19698 1           95281.38              24.68 647  -.58752024   -2.576891  -.7720042 .
    19729 1           100607.6 25.810000000000002 648    4.378148    3.081571   .4207519 .
    19760 1           98463.63              25.26 649  -2.1773555  -.58752024  2.7060094 .
    19788 1           102264.2 26.235000000000003 650   3.7164094    4.378148  -.1511458 .
    19819 1           105660.8 26.845000000000002 651    2.272304  -2.1773555 -2.0436072 .
    19849 1           112489.7 28.580000000000002 652    6.070679   3.7164094   .6334795 .
    19880 1           114153.5             29.045 653    1.600964    2.272304  -.2954446 .
    19910 1           120510.2 30.485000000000003 654   4.7236347    6.070679 -.22189347 .
    19941 1 120755.90000000001             30.585 655    .3269577    1.600964  -.7957745 .
    19972 1 121534.90000000001 30.825000000000003 656    .7785888   4.7236347  -.8351716 .
    20002 1           114538.5              29.16 657   -5.709877    .3269577 -18.463657 .
    20033 1           108842.8 27.830000000000002 658   -4.779016    .7785888  -7.138048 .
    20063 1 106488.90000000001 27.235000000000003 659  -2.1846888   -5.709877  -.6173843 .
    20094 1           103551.6             26.515 660   -2.715444   -4.779016  -.4317984 .
    20125 1           113759.5 29.205000000000002 661    9.210752  -2.1846888  -5.216047 .
    20153 1 110060.90000000001              28.26 662   -3.343949   -2.715444   .2314557 .
    20184 1           107763.1              27.67 663  -2.1322732    9.210752 -1.2314982 .
    20214 1           109574.1             28.135 664   1.6527457   -3.343949 -1.4942497 .
    20245 1           101960.1              26.18 665   -7.467533  -2.1322732   2.502146 .
    20275 1              98251             25.335 666   -3.335307   1.6527457   -3.01804 .
    20306 1           103641.5             26.725 667    5.201123   -7.467533  -1.696498 .
    20337 1           86940.69              22.19 668  -20.437134   -3.335307   5.127512 .
    20367 1           93304.25              23.67 669     6.25264    5.201123  .20217125 .
    20398 1           95373.75             24.195 670     2.16987  -20.437134 -1.1061729 .
    20428 1           87549.13              22.21 671   -8.937415     6.25264 -2.4293826 .
    20459 1           82013.38              20.55 672   -8.077859     2.16987 -4.7227387 .
    20490 1           80297.19              20.12 673   -2.137177   -8.937415   -.760873 .
    20519 1           91496.69             21.735 674    7.430412   -8.077859  -1.919849 .
    20550 1           88606.63             20.725 675   -4.873342   -2.137177  1.2802705 .
    20580 1           95489.94             22.335 676    7.208417    7.430412 -.02987646 .
    20611 1           93843.88              21.95 677  -1.7539864   -4.873342  -.6400855 .
    20641 1           105508.6              24.39 678     10.0041    7.208417   .3878358 .
    20672 1           97505.69 22.540000000000003 679   -8.207631  -1.7539864   3.679416 .
    20703 1           96575.63 22.325000000000003 680   -.9630459     10.0041 -1.0962651 .
    20733 1           100268.6             22.945 681    2.702114   -8.207631 -1.3292197 .
    20764 1           99285.31 22.720000000000002 682   -.9903169   -.9630459  .02831748 .
    20794 1           106299.1 24.325000000000003 683     6.59815    2.702114  1.4418476 .
    20825 1           117033.7             26.425 684     7.94702   -.9903169  -9.024724 .
    20856 1           111918.3              25.27 685   -4.570637     6.59815  -1.692715 .
    20884 1             109881 24.810000000000002 686   -1.854091     7.94702 -1.2333064 .
    20915 1           111469.6 24.900000000000002 687    .3614458   -4.570637   -1.07908 .
    20945 1 109589.40000000001              24.48 688  -1.7156863   -1.854091  -.0746483 .
    20976 1 107194.40000000001             23.945 689   -2.234287    .3614458  -7.181528 .
    21006 1           105480.6             23.385 690  -2.3946974  -1.7156863   .3957665 .
    21037 1           109472.6              24.27 691    3.646477   -2.234287  -2.632054 .
    21068 1             105819              23.46 692   -3.452685  -2.3946974   .4418044 .
    21098 1           116700.5              25.68 693     8.64486    3.646477   1.370743 .
    19272 2           43519.51              28.09 633           .           .          . .
    19303 2           44526.55 28.740000000000002 634   2.2616563           .          . .
    19333 2           45308.97             29.245 635    1.726791           .          . .
    19364 2           45749.66 29.395000000000003 636   .51029086   2.2616563  -.7743729 .
    19395 2           45290.54               29.1 637  -1.0137457    1.726791  -1.587069 .
    19423 2           47656.22              30.62 638    4.964076   .51029086   8.727934 .
    19454 2           48667.85 31.270000000000003 639   2.0786695  -1.0137457  -3.050484 .
    19484 2           50792.32 32.635000000000005 640   4.1826262    4.964076  -.1574209 .
    19515 2           47508.36 30.525000000000002 641   -6.912367   2.0786695 -4.3253803 .
    19545 2           47850.78             30.745 642    .7155635   4.1826262  -.8289201 .
    19576 2           47181.54             30.315 643  -1.4184397   -6.912367  -.7947968 .
    19607 2           44644.64 28.685000000000002 644   -5.682413    .7155635  -8.941172 .
    19637 2            43282.8 27.810000000000002 645    -3.14635  -1.4184397   1.218177 .
    19668 2           44979.28 28.900000000000002 646    3.771626   -5.682413 -1.6637368 .
    19698 2           44963.71              28.89 647 -.034614053    -3.14635  -.9889987 .
    19729 2 45078.450000000004 28.865000000000002 648  -.08661008    3.771626 -1.0229636 .
    19760 2           42946.75               27.5 649   -4.963636 -.034614053  142.39946 .
    19788 2           44469.37             28.475 650    3.424056  -.08661008  -40.53416 .
    19819 2           46538.63               29.8 651   4.4463086   -4.963636 -1.8957765 .
    19849 2 47327.270000000004             30.305 652   1.6663917    3.424056  -.5133282 .
    19880 2           49326.24             31.585 653   4.0525565   4.4463086 -.08855708 .
    19910 2           50388.21             32.265 654   2.1075468   1.6663917   .2647367 .
    19941 2           47374.13             30.335 655   -6.362288   4.0525565 -2.5699444 .
    19972 2           50747.43 32.495000000000005 656    6.647176   2.1075468  2.1539874 .
    20002 2           48092.53             30.795 657   -5.520377   -6.362288 -.13232839 .
    20033 2           48514.21             31.065 658    .8691453    6.647176  -.8692459 .
    20063 2           52301.33              33.49 659    7.240967   -5.520377 -2.3116798 .
    20094 2           49263.82             31.545 660   -6.165795    .8691453 -8.0940895 .
    20125 2           57892.21              37.07 661   14.904235    7.240967   1.058321 .
    20153 2           61866.72             39.615 662    6.424334   -6.165795 -2.0419312 .
    20184 2           61491.93             39.375 663   -.6095238   14.904235  -1.040896 .
    20214 2           59110.32              37.85 664  -4.0290623    6.424334 -1.6271564 .
    20245 2           58251.39 37.300000000000004 665  -1.4745308   -.6095238   1.419152 .
    20275 2 57782.880000000005                 37 666   -.8108108  -4.0290623  -.7987594 .
    20306 2           66083.25 42.315000000000005 667   12.560557  -1.4745308  -9.518342 .
    20337 2 54597.020000000004              34.96 668   -21.03833   -.8108108  24.947273 .
    20367 2            58446.6 37.425000000000004 669    6.586506   12.560557  -.4756199 .
    20398 2           64427.91             41.255 670    9.283723   -21.03833 -1.4412766 .
    20428 2           61937.01 39.660000000000004 671   -4.021684    6.586506 -1.6105944 .
    end
    format %tdnn/dd/CCYY date
    format %tm month

    Here stock stands for the stock id, MV=market value, P=price, retL2return_pct= 2mont lagged return. The total data consits of arround 300 stocks for the period 10-6-2012 - 10-6-2017

    Maybe anyone could assist me with the furhter commands to construct the 10% top portfolios and 10% bottom portfolios construing each month
    .

    Kind regards
    Last edited by Pieter Jan Max; 10 Oct 2017, 08:18.

  • #2
    There have been numerous discussions on Statalist about making portfolios based on returns. Once you have portfolios and their returns, you probably want to collapse the data by month to get rid of all the duplicates. Once you have monthly data, then leads and lags will take care of the rest.

    Comment

    Working...
    X