# A Machine Learning View on Momentum and Reversal Trading

^{*}

## Abstract

**:**

## 1. Introduction

## 2. Materials and Methods

#### 2.1. Problem Description

#### 2.2. Decision Tree

#### 2.3. Support Vector Machine

#### 2.4. Multilayer Perceptron Neural Network

#### 2.5. Long Short-Term Memory Neural Network

## 3. Experiment Setup

#### 3.1. Data Preparation

#### 3.2. Feature Extraction

#### 3.3. Trading Decisions Process

#### 3.4. Backtesting

## 4. Results

#### 4.1. Performance of the Buy-and-Hold Strategy

#### 4.2. Performance of the Momentum and Reversal Trading Strategies

#### 4.3. Performance of the Decision Tree Model

#### 4.4. Performance of the SVM Model

#### 4.5. Performance of the MLP Model

#### 4.6. Performance of the LSTM Model

#### 4.7. Comparison of the Net Asset Values of the Portfolios

## 5. Discussion

#### 5.1. Examination of Momentum and Reversal Effects

#### 5.2. Analysis of Machine Learning Models

#### 5.3. Analysis of the Net Asset Values of the Portfolios

## 6. Conclusions

## Author Contributions

## Funding

## Conflicts of Interest

## References

- Bondt, W.F.M.; Thaler, R. Does the stock market overreact? J. Financ.
**1985**, 40, 793–805. [Google Scholar] [CrossRef] - Jegadeesh, N.; Titman, S. Returns to buying winners and selling losers: Implications for stock market efficiency. J. Financ.
**1993**, 48, 65–91. [Google Scholar] [CrossRef] - Muga, L.; Santamaría, R. The momentum effect in latin american emerging markets. Emerg. Mark. Financ. Trade
**2007**, 43, 24–45. [Google Scholar] [CrossRef] - Naughton, T.; Truong, C.; Veeraraghavan, M. Momentum strategies and stock returns: Chinese evidence. Pac. Basin Financ. J.
**2008**, 16, 476–492. [Google Scholar] [CrossRef] - Hameed, A.; Ting, S. Trading volume and short-horizon contrarian profits: Evidence from the malaysian market. Pac. Basin Financ. J.
**2000**, 8, 67–84. [Google Scholar] [CrossRef] - Hhhn, H.; Scholz, H. Reversal and momentum patterns in weekly stock returns: European evidence. SSRN Electron. J.
**2017**. [Google Scholar] [CrossRef] - Tang, G.Y.N.; Zhang, H. Stock return reversal and continuance anomaly: New evidence from Hong Kong. Appl. Econ.
**2014**, 46, 1335–1349. [Google Scholar] [CrossRef] - Connolly, R.; Stivers, C. Momentum and reversals in equity-index returns during periods of abnormal turnover and return dispersion. J. Financ.
**2003**, 58, 1521–1556. [Google Scholar] [CrossRef] - Ramiah, V.; Li, D.L.; Carter, J.; Seetanah, B.; Thomas, S. Explaining Contrarian Profits with Finance Fundamentals. 2016. Available online: https://www.researchgate.net/profile/Vikash_Ramiah/publication/265821407_Explaining_Contrarian_Profits_with_Finance_Fundamentals/links/54e40d900cf2dbf60695661a/Explaining-Contrarian-Profits-with-Finance-Fundamentals.pdf (accessed on 25 October 2018).
- Maheshwari, S.; Dhankar, R.S. Market state and investment strategies: Evidence from the indian stock market. IIM Kozhikode Soc. Manag. Rev.
**2018**, 7, 154–170. [Google Scholar] [CrossRef] - Makarov, I.; Rytchkov, O. Forecasting the forecasts of others: Implications for asset pricing. J. Econ. Theory
**2012**, 147, 941–966. [Google Scholar] [CrossRef] [Green Version] - Conrad, J.; Yavuz, M.D. Momentum and reversal: Does what goes up always come down? Rev. Financ.
**2017**, 21, 555–581. [Google Scholar] [CrossRef] - Nasrabadi, N.M. Pattern recognition and machine learning. J. Electron. Imaging
**2007**, 16, 049901. [Google Scholar] - Russell, S.J.; Norvig, P. Artificial Intelligence: A Modern Approach; Pearson Education Limited: London, UK, 2016. [Google Scholar]
- Li, Z.; Tam, V.; Yeung, L. Combining cloud computing, machine learning and heuristic optimization for investment opportunities forecasting. In Proceedings of the 2016 IEEE Congress on Evolutionary Computation (CEC), Vancouver, BC, Canada, 24–29 July 2016; pp. 3469–3476. [Google Scholar]
- Byun, H.; Lee, S.-W. Applications of Support Vector Machines for Pattern Recognition: A survey. In Pattern Recognition with Support Vector Machines; Springer: Berlin/Heidelberg, Germany, 2002; pp. 213–236. [Google Scholar]
- Kim, K.-J. Financial time series forecasting using support vector machines. Neurocomputing
**2003**, 55, 307–319. [Google Scholar] [CrossRef] - Zhang, Y.; Wu, L. Stock market prediction of s&p 500 via combination of improved bco approach and bp neural network. Expert Syst. Appl.
**2009**, 36, 8849–8854. [Google Scholar] - Guenther, N.; Schonlau, M. Support vector machines. Stata J.
**2016**, 16, 917–937. [Google Scholar] - Zheng, B.; Yoon, S.W.; Lam, S.S. Breast cancer diagnosis based on feature extraction using a hybrid of k-means and support vector machine algorithms. Expert Syst. Appl.
**2014**, 41, 1476–1482. [Google Scholar] [CrossRef] - Jung, H.C.; Kim, J.S.; Heo, H. Prediction of building energy consumption using an improved real coded genetic algorithm based least squares support vector machine approach. Energy Build.
**2015**, 90, 76–84. [Google Scholar] [CrossRef] - Li, Z.; Tam, V. A comparative study of a recurrent neural network and support vector machine for predicting price movements of stocks of different volatilites. In Proceedings of the 2017 IEEE Symposium Series on Computational Intelligence (SSCI), Honolulu, HI, USA, 27 November–1 December 2017; pp. 1–8. [Google Scholar]
- Masnadi-Shirazi, H.; Vasconcelos, N. Risk minimization, probability elicitation, and cost-sensitive svms. In Proceedings of the ICML, Haifa, Israel, 21–24 June 2010; pp. 759–766. [Google Scholar]
- Lin, C.-F.; Wang, S.-D. Fuzzy support vector machines. IEEE Trans. Neural Netw.
**2002**, 13, 464–471. [Google Scholar] [PubMed] - Wang, S.; Chen, M.; Li, Y.; Zhang, Y.; Han, L.; Wu, J.; Du, S. Detection of dendritic spines using wavelet-based conditional symmetric analysis and regularized morphological shared-weight neural networks. Comput. Math. Methods Med.
**2015**, 454076. [Google Scholar] [CrossRef] [PubMed] - Wang, S.; Li, G.; Bao, Y. A novel improved fuzzy support vector machine based stock price trend forecast model. arXiv, 2018; arXiv:1801.00681. [Google Scholar]
- Ding, S.; Yu, J.; Qi, B.; Huang, H. An overview on twin support vector machines. Artif. Intell. Rev.
**2014**, 42, 245–252. [Google Scholar] [CrossRef] - Shao, Y.-H.; Zhang, C.-H.; Wang, X.-B.; Deng, N.-Y. Improvements on twin support vector machines. IEEE Trans. Neural Netw.
**2011**, 22, 962–968. [Google Scholar] [CrossRef] [PubMed] - Faghfouri, A.E.; Frish, M.B. Robust discrimination of human footsteps using seismic signals. In Proceedings of the Unattended Ground, Sea, and Air Sensor Technologies and Applications XIII, Orlando, FL, USA, 25–29 April 2011; International Society for Optics and Photonics: Bellingham, WA, USA, 2011; p. 80460D. [Google Scholar]
- Tong, X.; Sun, S. Long Short-Term Memory Network for Wireless Channel Prediction; Springer: Singapore, 2018; pp. 19–26. [Google Scholar]
- Tushare. Available online: http://tushare.org/ (accessed on 24 October 2018).
- Wu, Y. Momentum trading, mean reversal and overreaction in chinese stock market. Rev. Quant. Financ. Account.
**2011**, 37, 301–323. [Google Scholar] [CrossRef]

**Figure 1.**Structure of a Multilayer Perceptron Neural Network from [29].

**Figure 3.**Structure of the Long Short-Term Memory Neural Network (LSTM) unit from [30].

Training Data | Testing Data |
---|---|

2007-01-04 to 2011-12-31 | 2012-01-06 to 2016-02-05 |

Feature Sets | ||||
---|---|---|---|---|

amplitude | market_cap | mom_ps | rev_amplitude | rev_roc |

amplitude_std | market_cap_std | mom_ps_std | rev_amplitude_std | rev_roc_std |

cci | mom_amplitude | mom_roc | rev_cir_cap | rev_turnover |

change | mom_amplitude_std | mom_roc_std | rev_cir_cap_std | rev_turnover_std |

cir_cap | mom_cir_cap | mom_turnover | rev_current_rtn | rev_yield_dispersion |

cir_cap_std | mom_cir_cap_std | mom_turnover_std | rev_current_rtn_std | rev_yield_dispersion_std |

close | mom_current_rtn | mom_yield_dispersion | rev_lb | roc |

current_rtn | mom_current_rtn_std | mom_yield_dispersion_std | rev_lb_std | roc_std |

current_rtn_std | mom_lb | obv | rev_market_cap | rsi |

ema | mom_lb_std | open | rev_market_cap_std | sar |

high | mom_market_cap | pb | rev_pb | sma |

hurst | mom_market_cap_std | pb_std | rev_pb_std | turnover |

kdj_slow_d | mom_pb | pcf | rev_pcf | turnover_std |

kdj_slow_k | mom_pb_std | pcf_std | rev_pcf_std | vol_change |

lb | mom_pcf | pe | rev_pe | volume |

lb_std | mom_pcf_std | pe_std | rev_pe_std | willr |

low | mom_pe | ps | rev_ps | yield_dispersion |

macd | mom_pe_std | ps_std | rev_ps_std | yield_dispersion_std |

Brokerage Commission | Tax | Risk-Free Rate |
---|---|---|

0.03% of the transaction per trade | 0.1% of the transaction when selling stocks | 3.00% |

Buy-and-Hold Strategy Return | Buy-and-Hold Strategy Sharpe Ratio |
---|---|

30.27% | 0.37 |

J | K | Momentum Strategy Return | Momentum Strategy Sharpe Ratio | Reversal Strategy Return | Reversal Strategy Sharpe Ratio |
---|---|---|---|---|---|

5 | 5 | −2.89% | 0.12 | 75.21% | 0.62 |

10 | 0.22% | 0.16 | 21.09% | 0.31 | |

15 | −16.00% | 0.00 | 124.32% | 0.85 | |

20 | 86.15% | 0.68 | 60.81% | 0.56 | |

10 | 5 | −28.93% | −0.12 | 38.00% | 0.42 |

10 | 13.25% | 0.26 | 12.78% | 0.24 | |

15 | 1.26% | 0.16 | 109.25% | 0.79 | |

20 | 107.73% | 0.76 | 36.83% | 0.42 | |

15 | 5 | −8.25% | 0.10 | 34.50% | 0.40 |

10 | 49.16% | 0.49 | 16.86% | 0.28 | |

15 | −1.48% | 0.14 | 63.16% | 0.57 | |

20 | 116.55% | 0.79 | 75.22% | 0.64 | |

20 | 5 | −33.78% | −0.15 | −0.87% | 0.14 |

10 | 18.96% | 0.30 | 10.20% | 0.23 | |

15 | −28.35% | −0.12 | 88.61% | 0.70 | |

20 | 74.01% | 0.62 | 65.24% | 0.58 |

J | K | DT Model Return | DT Model Sharpe Ratio |
---|---|---|---|

5 | 5 | 22.62% | 0.32 |

10 | 9.42% | 0.18 | |

15 | 42.93% | 0.49 | |

20 | 47.92% | 0.50 | |

10 | 5 | −9.00% | 0.05 |

10 | 68.40% | 0.64 | |

15 | 24.47% | 0.32 | |

20 | 52.81% | 0.60 | |

15 | 5 | 175.90% | 1.52 |

10 | 207.17% | 1.34 | |

15 | 50.59% | 0.60 | |

20 | 100.33% | 0.92 | |

20 | 5 | 13.65% | 0.21 |

10 | 36.24% | 0.41 | |

15 | 27.14% | 0.35 | |

20 | 21.07% | 0.29 |

J | K | SVM Model Return | SVM Model Sharpe Ratio |
---|---|---|---|

5 | 5 | 67.38% | 0.62 |

10 | 60.15% | 0.62 | |

15 | 15.00% | 0.22 | |

20 | 128.55% | 1.12 | |

10 | 5 | 96.70% | 0.90 |

10 | 58.06% | 0.60 | |

15 | 0.74% | 0.00 | |

20 | 60.29% | 0.66 | |

15 | 5 | 89.33% | 0.90 |

10 | 239.43% | 1.68 | |

15 | 5.40% | 0.09 | |

20 | 179.36% | 1.39 | |

20 | 5 | 42.44% | 0.52 |

10 | 120.19% | 1.06 | |

15 | −37.43% | −0.60 | |

20 | 114.08% | 1.00 |

J | K | MLP Model Return | MLP Model Sharpe Ratio |
---|---|---|---|

5 | 5 | 23.75% | 0.32 |

10 | 47.53% | 0.49 | |

15 | 49.57% | 0.51 | |

20 | 74.50% | 0.71 | |

10 | 5 | 139.37% | 0.97 |

10 | 56.23% | 0.57 | |

15 | 28.62% | 0.36 | |

20 | 34.17% | 0.40 | |

15 | 5 | 105.95% | 0.92 |

10 | 215.26% | 1.41 | |

15 | −24.52% | −0.22 | |

20 | 70.21% | 0.69 | |

20 | 5 | 33.01% | 0.39 |

10 | 70.40% | 0.66 | |

15 | 29.60% | 0.36 | |

20 | 29.26% | 0.36 |

J | K | LSTM Model Return | LSTM Model Sharpe Ratio |
---|---|---|---|

5 | 5 | 10.75% | 0.21 |

10 | 129.96% | 1.06 | |

15 | −20.85% | −0.19 | |

20 | 201.30% | 1.25 | |

10 | 5 | −17.63% | −0.14 |

10 | 51.07% | 0.54 | |

15 | 2.30% | 0.10 | |

20 | 92.83% | 0.74 | |

15 | 5 | −4.23% | 0.03 |

10 | 106.98% | 0.98 | |

15 | 112.93% | 0.85 | |

20 | 42.05% | 0.53 | |

20 | 5 | 12.46% | 0.24 |

10 | 8.16% | 0.19 | |

15 | −32.40% | −0.31 | |

20 | 38.60% | 0.43 |

Model/Strategy | Momentum | Reversal | DT | SVM | MLP | LSTM |
---|---|---|---|---|---|---|

Average Return | 21.73% | 51.95% | 55.73% | 77.48% | 61.43% | 45.89% |

Average Sharpe Ratio | 0.26 | 0.48 | 0.55 | 0.67 | 0.56 | 0.41 |

© 2018 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Li, Z.; Tam, V.
A Machine Learning View on Momentum and Reversal Trading. *Algorithms* **2018**, *11*, 170.
https://doi.org/10.3390/a11110170

**AMA Style**

Li Z, Tam V.
A Machine Learning View on Momentum and Reversal Trading. *Algorithms*. 2018; 11(11):170.
https://doi.org/10.3390/a11110170

**Chicago/Turabian Style**

Li, Zhixi, and Vincent Tam.
2018. "A Machine Learning View on Momentum and Reversal Trading" *Algorithms* 11, no. 11: 170.
https://doi.org/10.3390/a11110170