Overview

Stocks that did badly last month tend to do better next month (short-term reversal). The raw return mixes factor-driven moves and stock-specific moves, so this project ranks stocks on the standardized residual of a 36-month Fama-French 3 factor regression (residual reversal).

  • Universe: the 100 largest common stocks by market cap in each formation month (financial firms included)
  • Estimation: rolling 36-month window (first window 2018/01 - 2020/12); a stock needs at least 30 valid monthly returns in its window, including month t
  • Timing (no look-ahead): at the end of formation month t only data up to t is used; the portfolio is held in month t+1
  • Formation months: 2020/12 - 2025/11 (60). Holding months: 2021/01 - 2025/12 (60)
  • Quintiles: Q1 = lowest z (biggest residual losers), Q5 = highest z. LS = Q1 - Q5 (zero-investment)
  • Units: returns and factors are decimals inside the code (0.01 = 1%); the tables show percentages where the column name says _pct

R1. Data and universe

Stock and factor files (same as hw7)

## Return source: TEJ ROI_Month (adjusted)
## Duplicate stock-month rows removed: 0
## Stocks: 1087 | Months: 98 | 2017-11-01 to 2025-12-01
## Factor months: 98 | 2017-11-01 to 2025-12-01

0050 (embedded) and TAIEX_TR (downloaded from TWSE)

  • 0050: monthly adjusted closing price from TEJ (table TSE/OTC Adjusted_Price(Monthly)-Ex_R+D), same file as Part 2, embedded below.
  • TAIEX_TR: the TAIEX total return index (發行量加權股價報酬指數) is published by the Taiwan Stock Exchange (TWSE). If there is no file with “taiex” in its name in data_dir, the code downloads the daily index from the TWSE website, keeps the last trading day of each month (month-end level, 2020/12 - 2025/12) and saves it as taiex_tr_monthly.csv (layout: id, month, level), so the download happens only once. If you already have your own file (TEJ export or the instructor’s taiex_tr_monthly.txt), put it in data_dir and it is used instead.
## TAIEX_TR from file: taiex_tr_monthly.csv
## TAIEX_TR months: 61 | 2020-12-01 to 2025-12-01
##        month    level
## 1 2020-12-01 28441.36
## 2 2021-01-01 29224.82
## 3 2021-02-01 30799.13
##         month    level
## 59 2025-10-01 64150.19
## 60 2025-11-01 62771.46
## 61 2025-12-01 65905.98

Quick look at the first and last rows above: the level should be a total return index (it grows over time, no jumps).

Formation months and universe (100 largest by market cap)

## Formation months: 60 | stocks per month: min 100 max 100 | duplicate stock-month rows: 0

R2. Residual signal

For each formation month t and each universe stock, the regression uses the 36 months ending in t:

(r - rf) = alpha + b_mkt * MKT + b_smb * SMB + b_hml * HML + e

The residual of month t is e, the standardized residual is z = e / sigma_hat, where sigma_hat = sqrt(sum of squared residuals / (n - 4)) (this is sigma() of the lm). A stock needs at least 30 valid monthly returns in its window, and a valid return in month t.

How many stocks have a valid signal each year, and how many were dropped:

year stock-months valid signal dropped (too few obs or no return in month t) of which fewer than 30 obs
2020 100 99 1 1
2021 1200 1169 31 31
2022 1200 1162 38 38
2023 1200 1183 17 17
2024 1200 1189 11 11
2025 1100 1077 23 23

Regression example and check by hand

One stock and one month: the largest stock at the end of 2023/12.

## Stock: 2330 TSMC | formation month: 2023-12 | window: 2021-01 to 2023-12 | n = 36
## 
## Call:
## lm(formula = ex_ret ~ mkt + smb + hml, data = ex_d)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.05152 -0.01162  0.00007  0.01549  0.03762 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.002541   0.003676   0.691    0.494    
## mkt          1.225340   0.072108  16.993  < 2e-16 ***
## smb         -0.571248   0.123608  -4.621 5.95e-05 ***
## hml         -0.555386   0.084293  -6.589 2.00e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.02108 on 32 degrees of freedom
## Multiple R-squared:  0.9368, Adjusted R-squared:  0.9309 
## F-statistic: 158.1 on 3 and 32 DF,  p-value: < 2.2e-16
residual e (hand) sigma (hand) z = e/sigma (hand) z in signals table
-0.01263 0.02108 -0.59893 -0.59893
## z by hand equals z in the table: TRUE
## Largest window length: 36 months (must be at most 36); window ends in month t by construction

R3. Quintile holdings

  • Quintiles by z within each formation month (Q1 = lowest z).
  • Equal weights: 1/n of the stocks in the quintile.
  • Value weights: market cap at the end of the formation month / sum for the quintile.
  • If a stock has no return in the holding month (e.g. delisted), it is dropped and the weights of the others are rescaled.
## Holdings rows: 5879 (at most 6000 )

How often is the holding-month return missing (stock dropped and weights rescaled)?

Quintile stock-months no holding-month return share (%)
Q1 1200 0 0
Q2 1196 0 0
Q3 1176 0 0
Q4 1163 0 0
Q5 1144 0 0
All 5879 0 0

R4. Portfolio returns

12 series (Q1-Q5 and LS, equal- and value-weighted) plus 4 benchmarks: 0050 (from its adjusted price), TAIEX_TR (from the total return index), EW universe and VW universe (all 100 stocks of the formation month, equal- and cap-weighted).

## Series with missing months: none
## portfolio_returns rows: 960 (expected 16 x 60 = 960)

Average monthly return by series (%):

portfolio avg monthly return (%)
Q1_EW 0.651
Q2_EW 1.221
Q3_EW 1.490
Q4_EW 1.565
Q5_EW 1.645
LS_EW -0.994
Q1_VW 1.128
Q2_VW 0.916
Q3_VW 1.451
Q4_VW 1.889
Q5_VW 1.787
LS_VW -0.659
0050 1.686
TAIEX_TR 1.529
EW_universe 1.316
VW_universe 1.651

R5. Performance table

  • Cumulative and annualized return (compounded), annualized volatility
  • Sharpe ratio (annualized, excess returns over rf; for LS the return itself, because it needs no cash investment)
  • Maximum drawdown and worst month
  • FF3 alpha (monthly) and factor loadings with t-statistics (excess return on the 3 factors; LS: the return itself)
  • Average monthly turnover for the quintile and LS portfolios: old weights drift with the holding-month returns, are compared with the new weights, and turnover = half the sum of absolute differences. For LS, the turnover of the Q1 leg and the Q5 leg are averaged. The first month (building the portfolio) is not counted.

Return and risk:

portfolio cum_return_pct ann_return_pct ann_vol_pct sharpe max_drawdown_pct worst_month_pct
Q1_EW 36.24 6.38 18.14 0.36 -26.62 -12.57
Q2_EW 93.61 14.13 16.80 0.79 -20.63 -10.12
Q3_EW 130.10 18.14 14.99 1.10 -18.55 -9.96
Q4_EW 138.52 18.99 15.99 1.09 -27.10 -13.62
Q5_EW 141.06 19.24 20.64 0.89 -21.07 -10.24
LS_EW -49.65 -12.82 18.22 -0.65 -54.69 -20.11
Q1_VW 79.68 12.43 19.15 0.63 -24.16 -12.00
Q2_VW 61.02 10.00 17.07 0.56 -29.38 -10.30
Q3_VW 123.21 17.42 16.05 1.00 -15.06 -9.99
Q4_VW 182.37 23.07 18.69 1.14 -29.62 -14.99
Q5_VW 153.85 20.48 23.75 0.85 -29.00 -16.72
LS_VW -40.78 -9.95 22.00 -0.36 -49.04 -24.74
0050 148.74 19.99 19.64 0.96 -29.31 -12.02
TAIEX_TR 131.73 18.30 17.02 1.00 -25.63 -10.84
EW_universe 107.35 15.70 15.14 0.95 -21.20 -9.39
VW_universe 146.49 19.77 18.31 1.01 -26.98 -11.39

FF3 alpha, loadings and turnover:

portfolio alpha_pct_month t_alpha b_mkt t_mkt b_smb t_smb b_hml t_hml avg_turnover_pct
Q1_EW -0.84 -2.42 1.02 13.69 0.35 3.29 0.15 1.69 79.48
Q2_EW -0.24 -0.68 0.92 12.22 0.20 1.81 0.32 3.70 78.38
Q3_EW 0.30 0.92 0.81 11.80 0.38 3.81 0.13 1.60 78.18
Q4_EW 0.30 1.00 0.87 13.49 0.22 2.39 -0.03 -0.42 80.31
Q5_EW 0.21 0.36 0.96 7.77 0.35 1.96 0.22 1.57 79.43
LS_EW -1.05 -1.44 0.06 0.39 0.00 0.02 -0.08 -0.43 79.46
Q1_VW -0.41 -0.96 0.97 10.72 -0.01 -0.04 0.13 1.19 86.31
Q2_VW -0.39 -1.13 0.84 11.56 -0.05 -0.49 -0.07 -0.80 82.49
Q3_VW 0.22 0.57 0.74 9.00 -0.15 -1.28 0.06 0.67 83.89
Q4_VW 0.40 1.17 0.98 13.28 0.02 0.15 -0.03 -0.36 83.47
Q5_VW 0.15 0.23 1.08 7.47 0.29 1.40 0.25 1.49 79.59
LS_VW -0.56 -0.64 -0.11 -0.57 -0.30 -1.10 -0.12 -0.57 82.95
0050 0.10 0.90 1.01 40.94 -0.29 -8.21 -0.17 -5.86
TAIEX_TR -0.01 -1.06 1.00 782.63 0.00 2.42 -0.01 -5.03
EW_universe -0.07 -0.44 0.93 25.94 0.31 5.94 0.16 3.76
VW_universe 0.07 1.53 1.02 109.96 -0.16 -12.08 -0.07 -6.46

R6. Comparison and charts

Growth of NT$100

Average monthly return of Q1 to Q5

## Equal-weighted pattern monotonic: TRUE | value-weighted pattern monotonic: FALSE

Comparison table

Portfolio Ann. return (%) Ann. vol (%) Sharpe Max drawdown (%) FF3 alpha (%/mo) t(alpha) Market beta
LS_EW -12.82 18.22 -0.65 -54.69 -1.05 -1.44 0.06
LS_VW -9.95 22.00 -0.36 -49.04 -0.56 -0.64 -0.11
Q1_EW 6.38 18.14 0.36 -26.62 -0.84 -2.42 1.02
0050 19.99 19.64 0.96 -29.31 0.10 0.90 1.01
TAIEX_TR 18.30 17.02 1.00 -25.63 -0.01 -1.06 1.00

R7. Discussion

(Draft written from the numbers above. Read it against your tables and put it in your own words before you hand it in.)

Is there a reversal effect? The equal-weighted quintiles earn average monthly returns of 0.65%, 1.22%, 1.49%, 1.56%, 1.65% for Q1 to Q5, a Q1 - Q5 spread of -0.99% per month. The pattern across quintiles is monotonic. The FF3 alpha of the equal-weighted LS portfolio is -1.05% per month (t = -1.44), which is not statistically significant (|t| below 2), and the value-weighted LS alpha is -0.56% (t = -0.64), which is not statistically significant (|t| below 2). Using the alpha and its t-statistic rather than the raw return, so this sample does not show a residual reversal effect, because the LS alpha is not positive.

Factor loadings. The LS (EW) portfolio has a market beta of 0.06 (t = 0.39), SMB loading 0.00 and HML loading -0.08. The market beta is much smaller than the Q1 and 0050 betas, as expected, because the long and short legs offset each other (Q1 EW: 1.02; 0050: 1.01). Because the factor part was removed before ranking, what is left in LS is mainly the residual part of the strategy, and the alpha measures it.

Comparison with 0050 and TAIEX_TR. Q1 (EW) earned 6.38% a year with a Sharpe ratio of 0.36, against 19.99% (Sharpe 0.96) for 0050 and 18.30% (Sharpe 1.00) for TAIEX_TR. LS (EW) earned -12.82% a year with a Sharpe ratio of -0.65. The comparison of LS with the two benchmarks is not like-for-like: LS is a zero-investment, market-neutral portfolio that needs short selling, and its Sharpe ratio uses the return itself, while 0050 and TAIEX_TR are fully invested long-only and their Sharpe ratios use excess returns.

Why this is hard to earn in practice. (1) Turnover and costs: the average monthly turnover of the LS (EW) legs is 79.46%. Selling that much each month at the 0.3% securities transaction tax alone costs about 0.24% of the portfolio per month on each leg, before commissions and bid-ask spreads, compared with an average LS return of -0.99% per month. (2) Short-selling constraints: in Taiwan it is not always possible to borrow the Q5 stocks, and borrowing costs and margin rules reduce the short-leg profit. (3) Short sample and noisy residuals: only 60 holding months are used, and the residuals come from 36-month regressions with large estimation error, so even a t-statistic of -1.44 could easily change in another period. The daily price limit of 10% also makes the extreme losers hard to trade.

Checks

Check Result
60 formation months TRUE
100 stocks in each formation month TRUE
no duplicate stock-month rows TRUE
regression windows have at most 36 months TRUE
5 quintiles differ in size by at most one stock TRUE
equal weights add up to 1 in every quintile-month TRUE
value weights add up to 1 in every quintile-month TRUE
60 holding months, every one of the 16 series has 60 returns TRUE
0050 has no jump of about -75% (4-for-1 split in 2025/06) TRUE
## 
## Worst 0050 monthly return: -14.1%

Save outputs

The three tables to submit, saved as csv in data_dir: holdings (key form_ym, ticker), portfolio_returns (key portfolio, hold_ym) and performance (key portfolio). Months are written as YYYYMM.

## holdings: 5879 rows | portfolio_returns: 960 rows | performance: 16 rows