Optimization of Traditional Stock Market Strategies Using the LSTM Hybrid Approach
Abstract
:1. Introduction
2. Theoretical Background
2.1. LSTM Neural Networks
LSTM in Time Series Analysis
2.2. Traditional Trading Strategies
2.2.1. Basics of Technical Analysis
2.2.2. Technical Indicators
2.2.3. Trading Strategies
- Buy, if MACDt crosses over Signalt;
- Sell, if MACDt crosses below Signalt.
- Buy if EMAmt is higher than EMAnt and if EMAmt is higher than EMApt;
- Sell if EMAmt is lower than EMAnt and if EMAmt is lower than EMApt.
- Buy, if Pt is higher than Pt−n+1;
- Sell, if Pt is lower than Pt−n+1.
- Buy if Pt is higher than MAt(n);
- Sell if Pt is lower than MAt(n).
2.2.4. Challenges of the Traditional Approach
3. Empirical Literature Overview
4. Materials and Methods
4.1. LSTM Network Architecture and Operation
4.2. Data Selection and Processing
4.3. LSTM Model Specification
4.4. Integrating LSTM into Trading Strategies
4.5. Simulation Process and Evaluation Criteria
5. Research Results
5.1. Overview of LSTM Prediction Model Results
5.2. Comparison of Performance of Different Strategies
5.3. Interpretation and Discussion of the Results
6. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
References
- Dash, R.; Dash, P.K. A hybrid stock trading framework integrating technical analysis with machine learning techniques. J. Financ. Data Sci. 2016, 2, 42–57. [Google Scholar] [CrossRef]
- Peša, A.R.; Wrońska-Bukalska, E.; Bosna, J. ARDL panel estimation of stock market indices and macroeconomic environment of CEE and SEE countries in the last decade of transition. Port. Econ. J. 2017, 16, 205–221. [Google Scholar] [CrossRef]
- Jansen, S. Machine Learning for Algorithmic Trading: Predictive Models to Extract Signals from Market and Alternative Data for Systematic Trading Strategies with Python. 2020. Available online: https://www.amazon.com/Machine-Learning-Algorithmic-Trading-alternative/dp/1839217715 (accessed on 1 January 2024).
- Ghahramani, M.; Najafabadi, H.E. Compatible Deep Neural Network Framework with Financial Time Series Data, Including Data Preprocessor, Neural Network Model and Trading Strategy. 2022. Available online: http://arxiv.org/abs/2205.08382 (accessed on 1 January 2024).
- Shah, D.; Isah, H.; Zulkernine, F. Stock market analysis: A review and taxonomy of prediction techniques. Int. J. Financ. Stud. 2019, 7, 26. [Google Scholar] [CrossRef]
- Jiang, W. Applications of deep learning in stock market prediction: Recent progress. Expert Syst. Appl. 2021, 184, 115537. [Google Scholar] [CrossRef]
- Dunis, C.; Von Mettenheim, H.-J.; Mcgroarty, F. New Developments in Quantitative Trading and Investment Series Editors. 2017. Available online: http://www.springer.com/series/14750 (accessed on 1 January 2024).
- Clenow, A.F. Trading Evolved: Anyone Can Build Killer Trading Strategies in Python. 2019. Available online: https://dokumen.pub/trading-evolved-anyone-can-build-killer-trading-strategies-in-python-1-independently-published.html (accessed on 1 January 2024).
- Inglese, L. Python for Finance and Algorithmic Trading; Independently Published: Zurich, Switzerland, 2022. [Google Scholar]
- Chalvatzis, C.; Hristu-Varsakelis, D. High-performance stock index trading via neural networks and trees. Appl. Soft Comput. J. 2020, 96, 106567. [Google Scholar] [CrossRef]
- Hochreiter, S.; Schmidhuber, J. Long-Short Term Memory. Neural Comput. 1997, 9, 1735–1780. [Google Scholar] [CrossRef] [PubMed]
- Maria Bianchi, F.C.; Maiorino, E.; Kampffmeyer, M.; Rizzi, A.; Jenssen, R. Recurrent Neural Networks for Short-Term Load Forecasting an Overview and Comparative Analysis. 2017. Available online: http://www.springer.com/series/10028 (accessed on 1 January 2024).
- Bernico, M. Deep Learning Quick Reference: Useful Hacks for Training and Optimizing Deep Neural Networks with TensorFlow and Keras; Packt Publishing Ltd.: Birmingham, UK, 2018. [Google Scholar]
- Alkhatib, K.; Khazaleh, H.; Alkhazaleh, H.A.; Alsoud, A.R.; Abualigah, L. A new stock price forecasting method using active deep learning approach. J. Open Innov. Technol. Mark. Complex. 2022, 8, 96. [Google Scholar] [CrossRef]
- Mishev, K.; Gjorgjevikj, A.; Vodenska, I.; Chitkushev, L.T.; Trajanov, D. Evaluation of sentiment analysis in finance: From lexicons to transformers. IEEE Access 2020, 8, 131662–131682. [Google Scholar] [CrossRef]
- Ma, Q. Comparison of ARIMA, ANN and LSTM for Stock Price Prediction. In E3S Web of Conferences; EDP Sciences: Les Ulis, France, 2020. [Google Scholar] [CrossRef]
- Tilakaratne, C.D.; Morris, S.A.; Mammadov, M.A.; Hurst, C.P. Predicting Stock Market Index Trading Signals Using Neural Networks. In Proceedings of the Australasian Joint Conference on Artificial Intelligence, Auckland, New Zealand, 1–5 December 2008. [Google Scholar]
- Murphy, J. Technical Analysis of the Futures Markets. 1999. Available online: www.Fxborssa.com (accessed on 1 January 2024).
- Romeu, R.; Serajuddin, U. Technical Analysis for Direct Access Trading; McGraw-Hill: New York, NY, USA, 2001. [Google Scholar]
- Person, J.L. A Complete Guide to Technical Trading Tactics How to Profit Using Pivot Points, Candlesticks & Other Indicators; John Wiley & Sons: Hoboken, NJ, USA, 2004. [Google Scholar]
- Ayala, J.; García-Torres, M.; Noguera, J.L.V.; Gómez-Vela, F.; Divina, F. Technical analysis strategy optimization using a machine learning approach in stock market indices. Knowl.-Based Syst. 2021, 225, 107119. [Google Scholar] [CrossRef]
- Zakamulin, V. Market Timing with Moving Averages. 2017. Available online: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2585056 (accessed on 1 January 2024).
- Fischer, T.; Krauss, C. Deep learning with long short-term memory networks for financial market predictions. Eur. J. Oper. Res. 2018, 270, 654–669. [Google Scholar] [CrossRef]
- Baek, Y.; Kim, H.Y. ModAugNet: A new forecasting framework for stock market index value with an overfitting prevention LSTM module and a prediction LSTM module. Expert. Syst. Appl. 2018, 113, 457–480. [Google Scholar] [CrossRef]
- Fjellström, C. Long Short-Term Memory Neural Network for Financial Time Series. 2022. Available online: http://arxiv.org/abs/2201.08218 (accessed on 1 January 2024).
- Vaswani, A. Attention Is All You Need. 2017. Available online: http://arxiv.org/abs/1706.03762 (accessed on 1 January 2024).
- Lezmi, E.; Xu, J. Time Series Forecasting with Transformer Models and Application to Asset Management. Amundi Institute Publications. 2023. Working Paper 139. Available online: https://www.researchgate.net/publication/368922825_Time_Series_Forecasting_with_Transformer_Models_and_Application_to_Asset_Management (accessed on 1 January 2024).
- Ta, V.D.; Liu, C.M.; Tadesse, D.A. Portfolio optimization-based stock prediction using long-short term memory network in quantitative trading. Appl. Sci. 2020, 10, 437. [Google Scholar] [CrossRef]
- Chalvatzis, C.; Hristu-Varsakelis, D. High-performance stock index trading: Making effective use of a deep LSTM neural network. arXiv 2019, arXiv:1902.03125. [Google Scholar]
- Aldhyani, T.H.H.; Alzahrani, A. Framework for Predicting and Modeling Stock Market Prices Based on Deep Learning Algorithms. Electronics 2022, 11, 3149. [Google Scholar] [CrossRef]
- Jafar, S.H.; Shakeb, A.; El-Chaarani, H.; Alam Khan, P.; Binsaddig, R. Forecasting of NIFTY 50 Index Price by Using Backward Elimination with an LSTM Model. J. Risk Financ. Manag. 2023, 16, 423. [Google Scholar] [CrossRef]
- Ku, C.S.; Xiong, J.; Chen, Y.-L.; Cheah, S.D.; Soong, H.C.; Por, L.Y. Improving Stock Market Predictions: An Equity Forecasting Scanner Using Long Short-Term Memory Method with Dynamic Indicators for Malaysia Stock Market. Mathematics 2023, 11, 2470. [Google Scholar] [CrossRef]
- Letteri, I.; Della Penna, G.; De Gasperis, G.; Dyoub, A. DNN-ForwardTesting: A New Trading Strategy Validation using Statistical Timeseries Analysis and Deep Neural Networks. 2022. Available online: http://arxiv.org/abs/2210.11532 (accessed on 1 January 2024).
- Yu, S.; Yang, S.-B.; Yoon, S.-H. The Design of an Intelligent Lightweight Stock Trading System Using Deep Learning Models: Employing Technical Analysis Methods. Systems 2023, 11, 470. [Google Scholar] [CrossRef]
- Goodfellow, I.; Bengio, Y.; Courville, A. Deep Learning. 2015. Available online: https://www.deeplearningbook.org/ (accessed on 1 January 2024).
- Olah, C. Understanding LSTM Networks. Available online: http://colah.github.io/posts/2015-08-Understanding-LSTMs/ (accessed on 16 September 2023).
- Pak, A.; Adegboye, O.A.; Adekunle, A.I.; Rahman, K.M.; McBryde, E.S.; Eisen, D.P. Economic Consequences of the COVID-19 Outbreak: The Need for Epidemic Preparedness. Front. Public Health 2020, 8, 241. [Google Scholar] [CrossRef]
- Botunac, I.; Panjkota, A.; Matetic, M. The effect of feature selection on the performance of long short-term memory neural network in stock market predictions. In Proceedings of the Annals of DAAAM and Proceedings of the International DAAAM Symposium, DAAAM International Vienna, Vienna, Austria, 21–24 October 2020; pp. 592–598. [Google Scholar] [CrossRef]
- Awad, A.L.; Elkaffas, S.M.; Fakhr, M.W. Stock Market Prediction Using Deep Reinforcement Learning. Appl. Syst. Innov. 2023, 6, 106. [Google Scholar] [CrossRef]
- Michanków, J.; Sakowski, P.; Slepaczuk, R. LSTM in Algorithmic Investment Strategies on BTC and S&P500 Index. Sensors 2022, 22, 917. [Google Scholar] [CrossRef]
- Ganie, I.R.; Wani, T.A.; Yadav, M.P. Impact of COVID-19 Outbreak on the Stock Market: An Evidence from Select Economies. Bus. Perspect. Res. 2022, 1, 1–15. [Google Scholar] [CrossRef]
- Liu, X.Y.; Yang, H.; Chen, Q.; Zhang, R.; Yang, L.; Xiao, B.; Wang, C.D. FinRL: A deep reinforcement learning library for automated stock trading in quantitative finance. arXiv 2022, arXiv:2011.09607. [Google Scholar]
- Yang, H.; Liu, X.Y.; Wang, C.D. FinGPT: Open-Source Financial Large Language Models. arXiv 2023, arXiv:2306.06031. [Google Scholar] [CrossRef]
Name of Technical Indicator | Formula |
---|---|
Simple 10-day moving average | |
Weighted 10-day moving average |
Hyper Parameters | Value |
---|---|
First layer (LSTM cell) | 512 |
First dropout | 0.1 |
Second layer (LSTM cell) | 512 |
Second Dropout | 0.1 |
Third layer (dense celse (Relu)) | 64 |
Fourth layer (dense celse (Relu)) | 1 |
Adam | 0.1 |
Bach | 128 |
Epoche | 300 |
Simbol | Mean Square Error (MSE) | Mean Absolute Error (MAE) |
---|---|---|
SPY | 0.00040 | 0.01432 |
DIA | 0.00035 | 0.01355 |
AAPL | 0.00030 | 0.01293 |
MSFT | 0.00031 | 0.01371 |
TSLA | 0.00139 | 0.02608 |
BRK-B | 0.00044 | 0.1653 |
NVDA | 0.00034 | 0.01446 |
JPM | 0.00041 | 0.01547 |
XOM | 0.00168 | 0.03267 |
Symbol | Trading Strategy | ||||||||
---|---|---|---|---|---|---|---|---|---|
MACD | TEMA | MOM | P-MA | B/H | |||||
STAND. | LSTM | STAND. | LSTM | STAND. | LSTM | STAND. | LSTM | STAND. | |
SPY | 31.74% | 31.71% | 20.63% | 24.36% | 26.94% | 43.70% | −4.40% | 45.52% | 31.90% |
DIA | 15.69% | 11.59% | −1.89% | 8.00% | 24.64% | 33.03% | −7.13% | 9.03% | 16.87% |
AAPL | 135.84% | 107.26% | 150.72% | 98.26% | 25.25% | 87.24% | 23.26% | 86.53% | 128.91% |
MSFT | −4.21% | 46.27% | 18.63% | 19.13% | −6.46% | 91.59% | 28.84% | 15.49% | 97.61% |
TSLA | 312.74% | 461.99% | 574.81% | 546.44% | 128.63% | 284.08% | 874.81% | 408.64% | 746.49% |
BRK-B | 53.59% | 30.57% | 46.27% | 42.08% | −0.51% | 36.99% | 60.07% | 67.51% | 53.58% |
NVDA | 183.22% | 166.06% | 286.00% | 421.89% | 36.03% | 319.80% | 185.26% | 375.02% | 624.52% |
JPM | −22.24% | −20.13% | −27.72% | −28.72% | −26.44% | 0.76% | −24.24% | −2.36% | 5.26% |
XOM | 85.27% | 110.77% | 41.39% | 47.28% | 25.16% | 19.94% | 64.67% | 77.35% | 67.11% |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2024 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 (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Botunac, I.; Bosna, J.; Matetić, M. Optimization of Traditional Stock Market Strategies Using the LSTM Hybrid Approach. Information 2024, 15, 136. https://doi.org/10.3390/info15030136
Botunac I, Bosna J, Matetić M. Optimization of Traditional Stock Market Strategies Using the LSTM Hybrid Approach. Information. 2024; 15(3):136. https://doi.org/10.3390/info15030136
Chicago/Turabian StyleBotunac, Ive, Jurica Bosna, and Maja Matetić. 2024. "Optimization of Traditional Stock Market Strategies Using the LSTM Hybrid Approach" Information 15, no. 3: 136. https://doi.org/10.3390/info15030136
APA StyleBotunac, I., Bosna, J., & Matetić, M. (2024). Optimization of Traditional Stock Market Strategies Using the LSTM Hybrid Approach. Information, 15(3), 136. https://doi.org/10.3390/info15030136