<jupyter_start><jupyter_text>1 The Momentum Product(1) What is novel about the AQR Momentum product under construction compared to the variousmomentum investment products already offered?**Solution:** The new product is a momentum mutual fund, and thus it will be available to retail investors rather than just those able to invest in hedge-funds.To satisfy regulatory requirements, this implementation of momentum will be restricted to longonlyand to large stocks.      (2) Name three reasons the momentum investment product will not exactly track the momentumindex, (i.e. why the strategy will have tracking error.)**Solution:** There are many ways in which the fund might introduce tracking error as they try to minimize trading costs. Examples include,  -  rebalancing at longer frequencies. (ie. quarterly vs monthly.) -  keeping stocks which technically no longer rank as momentum stocks but are deemed close enough.  -  executing trades slowly so as to reduce price-impact and illiquidity.  -  considering tax implications of the trades suggested by the momentum ranking and altering the portfolio construction accordingly.    (3) When constructing the momentum portfolio, AQR ranks stocks on their returns from month$t-12$ through $t-2$. Why don't they include the $t-1$ return in this ranking?   **Solution:** Market microstructure and liquidity issues cause prices reversion (not momentum!) in one-month returns. See footnote 2.   2 Investigating Momentum***1. Is momentum still profitable?***The excess returns of lucrative trading strategies often disappear once the strategy is well-known.The first widely-cited paper on momentum was published in 1993. Have momentum returns orrisk changed since then? The AQR case takes place at the end of 2008. Have momentum returnschanged in 2009-2020?Investigate by filling out the summary statistics below for the full-sample and three sub-samples.(a) Using the data provided, fill in Table 1 with the appropriate stats for $\tilde{r}^{rmom:FF}$.(b) Has momentum changed much over time, as seen through these subsample statistics?(c) Does this data support AQR's argument that momentum is an important piece of the idealportfolio? What if mean returns to momentum are in actuality near zero due to transactioncosts - would there still be evidence here that momentum is valuable?<jupyter_code>path = 'momentum_data-2.xlsx'
df_mom_size = pd.read_excel(path, sheet_name=4).set_index('Date')
df_factors = pd.read_excel(path, sheet_name=1).set_index('Date')
df_mom_size = df_mom_size.join(df_factors)

rf = pd.read_excel(path, sheet_name=5).set_index('Date')
df_mom_size = df_mom_size.join(rf)

df_momentum = pd.read_excel(path, sheet_name=3).set_index('Date')
df_momentum = df_momentum.join(rf)
#1 
df_mom_size['rx_mom_FF'] = (1/2 *(df_mom_size['BIG HiPRIOR'] + df_mom_size['SMALL HiPRIOR']) -
  1/2 * (df_mom_size['BIG LoPRIOR'] + df_mom_size['SMALL LoPRIOR'])) # same as UMD
df_mom_size['rx_mom_FF']
def table_row(df, portfolio, annualize_factor=12):
    mean = df[portfolio].mean() * annualize_factor
    vol = df[portfolio].std() * np.sqrt(annualize_factor)
    sharpe_ratio = mean/vol
    skew = df[portfolio].skew() #unscaled
    corr = df[[portfolio, 'MKT', 'HML']].corr()
    corr_to_mkt = corr.loc[portfolio, 'MKT']
    corr_to_value = corr.loc[portfolio, 'HML']
    return [mean, vol, sharpe_ratio, skew, corr_to_mkt, corr_to_value]


table1 = pd.DataFrame(index=['1927-2021', '1927-1993', '1994-2008', '2009-2021'],
    columns=['mean ', 'vol ', 'sharpe_ratio ', 'skew ', 'corr_to_mkt ', 'corr_to_value', ])

table1.loc['1927-2021', :] = table_row(df_mom_size.loc['1927':'2020',:], portfolio='rx_mom_FF')
table1.loc['1927-1993', :] = table_row(df_mom_size.loc['1927':'1993',:], portfolio='rx_mom_FF')
table1.loc['1994-2008', :] = table_row(df_mom_size.loc['1994':'2008',:], portfolio='rx_mom_FF')
table1.loc['2009-2021', :] = table_row(df_mom_size.loc['2009':'2020',:], portfolio='rx_mom_FF')
table1.style.set_caption('Solution Table 1: Momentum performance over time.')<jupyter_output><empty_output><jupyter_text>**Solution:** (a) See Solution Table 1, which gives stats of the monthly returns. (All but skewness are annualized.)  (b) Momentum's performance has been fairly consistent over the entire sampleexcept that in the past 12 years the mean return has been very poor. This is driven mostly by the year 2009. Note that even in the final subsample the correlations to the market and value are close to their usual values, and the overall volatility is close to the usual. It's also noticeable that in the subperiod 1994-2008, the momentum has the best performance. The sharpe ratio is the highest, and the sknewness is only slightly negative. The correlations to the market and the value factor are the lowest. And this is exactly the period that momentum was published and well-practiced.  (c) The persistent performance over time (except for the 2009 crash which causes low mean return in 2009-2020) seems to support the idea that momentum is not just astatistical anomaly. Even in the final subsample, it gives negative correlation to the marketand value to the point it is valuable to a mean-variance investor even with a mean returnnear zero. ***2. The case is about whether a long-only implementation of momentum is valuable.***Construct your own long-only implementation:,$$ \tilde{r}^{momU:FF} = \frac{1}{2} \left( r^{momBU} + r^{momSU} \right) - r^f $$Note that this is following the FF approach of treating big and small stocks separately. Thiswould be very similar to a scaled version of,$$ \tilde{r}^{momU} = \frac{1}{3} \left( r^{mom(8)} + r^{mom(9)} + r^{mom(10)} \right) - r^f $$For the question below, use the FF-style, $\tilde{r}^{momU:FF}_t$.(a) Fill out Table 2 for the data in the period 1994-2021.(b) Is long-only momentum as attractive as long-short momentum with respect to mean, volatility,and Sharpe Ratio?(c) Is long-only momentum as diversifying as long-short momentum with respect to marketand value premia?(d) Show a plot of the cumulative product of $1 + \tilde{r}^{mom:FF}$ and $1 + \tilde{r}^{momU:FF}$ over the 2006-2021 subsample.<jupyter_code>#2 
df_mom_size['rx_mom_U_FF'] = (1/2 * (df_mom_size['BIG HiPRIOR'] + df_mom_size['SMALL HiPRIOR']) -
    df_mom_size['RF'])

table2 = pd.DataFrame(index=['long_short', 'long_only'],
    columns=['mean ', 'vol ', 'sharpe_ratio ', 'skew ', 'corr_to_mkt ', 'corr_to_value', ])

table2.loc['long_short', :] = table_row(df_mom_size['1994':], portfolio='rx_mom_FF')
table2.loc['long_only', :] = table_row(df_mom_size['1994':], portfolio='rx_mom_U_FF')
table2.style.set_caption('Solution Table 2: Long-only momentum performance.')
sns.set_style("whitegrid")
(df_mom_size.loc['1994':'2021', 'rx_mom_FF'] + 1).cumprod().plot(figsize=(16,4))
(df_mom_size.loc['1994':'2021', 'rx_mom_U_FF'] + 1).cumprod().plot(figsize=(16,4))
plt.title('Figure 1: Cumulative excess return on baseline momentum and long-only momentum strategies.')
plt.legend();<jupyter_output><empty_output><jupyter_text>**Solution:** (a) See Solution Table 2, which gives stats of the monthly returns. (All but skewness are annualized.)      (b) During the period of 1994-2021, the mean, and Sharpe ratio are much higher in the long-only strategy, while the vol is about the same. It also has much less skewness. On these measures, it looks even more attractive.      (c) The long-only strategy is extremely correlated with the market and thus should not be promoted based on its diversification to the market. The long-short strategy hasalmost no market correlation and substantially negative correlation to value.      (d) See Figure 1. From 1994 to 2021, the long-and-short momentum stratery only out-performed the long-only strategy in 2003 and 2009. There one sees that the long-and-short momentum strategy suffered massive losses in 2009, (roughly -80% return,) while the long-only strategy was down about 50%in 2008 and up in 2009. This is a good illustration of the long-only strategy having less skewness. After 2009, the performance of long-and-short stratery was quite stable, and it has never returned to the previous level. On the other hand, the long-only strategy has recovered and soared after 2009.  ***3. Is momentum just data mining, or is it a robust strategy?***Assess how sensitive the threshold for the “winners” and “losers” is in the results. Specifically, we compare three constructions: - long the top 1 decile and short the bottom 1 deciles $$ \tilde{r}^{momD1} = r^{mom(10)} - r^{mom(1)} $$ - long the top 3 deciles and short the bottom 3 deciles $$ \tilde{r}^{momD3} = \frac{1}{3}\sum_{k=8}^{10} r^{mom(k)} - \frac{1}{3}\sum_{k=1}^{3} r^{mom(k)}$$ - long the top 5 deciles and short the bottom 5 deciles $$ \tilde{r}^{momD5} = \frac{1}{5}\sum_{k=6}^{10} r^{mom(k)} - \frac{1}{5}\sum_{k=1}^{5} r^{mom(k)}$$(a) Compare all three constructions, (in the full-sample period,) by filling out the stats in thetable below for the period 1994-2021.(b) Do the tradeoffs between the 1-decile, 3-decile, and 5-decile constructions line up with the theoretical tradeoffs we discussed in the lecture?(c) Should AQR’s retail product consider using a 1-decile or 5-decile construction?(d) Does $\tilde{r}^{momD3}$ have similar stats to the Fama-French construction in (1). Recall that con- struction is also a 3-decile, long-short construction, but it is segmented for small and large stocks. Compare the middle row of Table 3 with the top row of Table 2.<jupyter_code>#3

df_momentum['rx_mom_D1'] = df_momentum['Hi PRIOR'] - df_momentum['Lo PRIOR']
table3 = pd.DataFrame(columns=['mean ', 'vol ', 'sharpe_ratio ', 'skew ', 'corr_to_mkt ', 'corr_to_value', ])

df = df_mom_size.join(df_momentum, rsuffix='momentum_')
df['rx_mom_D3'] = (1/3 * (df['PRIOR 8'] + df['PRIOR 9'] + df['Hi PRIOR']) -\
                1/3 * (df['Lo PRIOR'] + df['PRIOR 2'] + df['PRIOR 3']))
df['rx_mom_D5'] = (1/5 * (df['PRIOR 6'] + df['PRIOR 7'] + df['PRIOR 8'] + df['PRIOR 9'] + df['Hi PRIOR']) -\
                1/5 * (df['Lo PRIOR'] + df['PRIOR 2'] + df['PRIOR 3'] + df['PRIOR 4'] + df['PRIOR 5']))
table3.loc['rx_mom_D1', :] = table_row(df['1994':], portfolio='rx_mom_D1')
table3.loc['rx_mom_D3', :] = table_row(df['1994':], portfolio='rx_mom_D3')
table3.loc['rx_mom_D5', :] = table_row(df['1994':], portfolio='rx_mom_D5')

table3.style.set_caption('Table 3: Robustness of momentum construction.')
table2.style.set_caption('Solution Table 2: Long-only momentum performance.')<jupyter_output><empty_output><jupyter_text>**Solution:** (a) See Table 3, which gives stats of the monthly returns. (All but skewness are annualized.)      (b) The lecture implies that the more extreme the cutoff for the "winners", the higher the mean return of the momentum portfolio. The downside is that we would expect higher volatility.This is consistent with what we see here.  (c) If AQR can accept a higher volality and take on high concentrations in individual stocks, it can consider the 1-decile contruction as a retail product as the performance of the 1-decile construction is stronger. If AQR chooses the 5-decile construction, it means that it will hold all securities on the market, the trading costs from the rebalancing would be huge and the premium would be smaller too, but it has a smaller volality and a very diversified portfolio. I don't think AQR will choose either option.      (d) The Fama-French construction has a larger mean, a smaller vol, and thus a higher sharpe ratio. Other measures are on the same scale as those of the 3-decile construction. This shows that segment by size actually gives a better performance.  ***4. Does implementing momentum require trading lots of small stocks—thus causing even larger trading costs?***For regulatory and liquidity reasons, AQR is particularly interested in using larger stocks for their momentum baskets. (Though they will launch one product that focuses on medium-sized stocks.)Use the data provided on both small-stock “winners”, $r^{momSU}$, and small-stock “losers”, $r^{momSD}$, to construct a small-stock momentum portfolio, $$ \tilde{r}^{momS} = r^{momSU} - r^{momSD} $$ Similarly, use the data provided to construct a big-stock momentum portfolio, $$ \tilde{r}^{momB} = r^{momBU} - r^{momBD} $$(a) Fill out Table 4 over the sample 1994-2021.(b) Is the attractiveness of the momentum strategy mostly driven by the small stocks? That is, does a momentum strategy in large stocks still deliver excess returns at comparable risk?<jupyter_code>#4
df['rx_mom_S'] = df['SMALL HiPRIOR'] - df['SMALL LoPRIOR']
df['rx_mom_B'] = df['BIG HiPRIOR'] - df['BIG LoPRIOR']
table4 = pd.DataFrame(columns=['mean ', 'vol ', 'sharpe_ratio ', 'skew ', 'corr_to_mkt ','corr_to_v'])
table4.loc['rx_mom_FF', :] = table_row(df['1994':], portfolio='rx_mom_FF')
table4.loc['rx_mom_S', :] = table_row(df['1994':], portfolio='rx_mom_S')
table4.loc['rx_mom_B', :] = table_row(df['1994':], portfolio='rx_mom_B')
table4.style.set_caption('Table 4: Small stock momentum performance.')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11667689475299171, 'fraction_numerical': 0.032371893218778765, 'mean_word_length': 5.23481587757054, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '397506', 'license': 'MIT', 'n_tokens_mistral': 4359, 'n_tokens_neox': 3886, 'n_words': 1543, 'path': 'solutions/Solution_HW6_2021_YS.ipynb', 'repo_name': 'ychendm/finm-portfolio-2021', 'size': '13036'}