IDEAS home Printed from https://ideas.repec.org/a/spr/fininn/v10y2024i1d10.1186_s40854-024-00644-0.html
   My bibliography  Save this article

Forecasting relative returns for S&P 500 stocks using machine learning

Author

Listed:
  • Htet Htet Htun

    (University of Groningen)

  • Michael Biehl

    (University of Groningen)

  • Nicolai Petkov

    (University of Groningen)

Abstract

Forecasting changes in stock prices is extremely challenging given that numerous factors cause these prices to fluctuate. The random walk hypothesis and efficient market hypothesis essentially state that it is not possible to systematically, reliably predict future stock prices or forecast changes in the stock market overall. Nonetheless, machine learning (ML) techniques that use historical data have been applied to make such predictions. Previous studies focused on a small number of stocks and claimed success with limited statistical confidence. In this study, we construct feature vectors composed of multiple previous relative returns and apply the random forest (RF), support vector machine (SVM), and long short-term memory (LSTM) ML methods as classifiers to predict whether a stock can return 2% more than its index in the following 10 days. We apply this approach to all S&P 500 companies for the period 2017–2022. We assess performance using accuracy, precision, and recall and compare our results with a random choice strategy. We observe that the LSTM classifier outperforms RF and SVM, and the data-driven ML methods outperform the random choice classifier (p = 8.46e−17 for accuracy of LSTM). Thus, we demonstrate that the probability that the random walk and efficient market hypotheses hold in the considered context is negligibly small.

Suggested Citation

  • Htet Htet Htun & Michael Biehl & Nicolai Petkov, 2024. "Forecasting relative returns for S&P 500 stocks using machine learning," Financial Innovation, Springer;Southwestern University of Finance and Economics, vol. 10(1), pages 1-16, December.
  • Handle: RePEc:spr:fininn:v:10:y:2024:i:1:d:10.1186_s40854-024-00644-0
    DOI: 10.1186/s40854-024-00644-0
    as

    Download full text from publisher

    File URL: http://link.springer.com/10.1186/s40854-024-00644-0
    File Function: Abstract
    Download Restriction: no

    File URL: https://libkey.io/10.1186/s40854-024-00644-0?utm_source=ideas
    LibKey link: if access is restricted and if your library uses this service, LibKey will redirect you to where you can use your library subscription to access this item
    ---><---

    References listed on IDEAS

    as
    1. Krauss, Christopher & Do, Xuan Anh & Huck, Nicolas, 2017. "Deep neural networks, gradient-boosted trees, random forests: Statistical arbitrage on the S&P 500," European Journal of Operational Research, Elsevier, vol. 259(2), pages 689-702.
    2. Farias Nazário, Rodolfo Toríbio & e Silva, Jéssica Lima & Sobreiro, Vinicius Amorim & Kimura, Herbert, 2017. "A literature review of technical analysis on stock markets," The Quarterly Review of Economics and Finance, Elsevier, vol. 66(C), pages 115-126.
    3. Dai, Zhifeng & Dong, Xiaodi & Kang, Jie & Hong, Lianying, 2020. "Forecasting stock market returns: New technical indicators and two-step economic constraint method," The North American Journal of Economics and Finance, Elsevier, vol. 53(C).
    4. Jaideep Singh & Matloob Khushi, 2021. "Feature Learning for Stock Price Prediction Shows a Significant Role of Analyst Rating," Papers 2103.09106, arXiv.org.
    5. Chia-Cheng Chen & Chun-Hung Chen & Ting-Yin Liu, 2020. "Investment Performance of Machine Learning: Analysis of S&P 500 Index," International Journal of Economics and Financial Issues, Econjournals, vol. 10(1), pages 59-66.
    6. Basak, Suryoday & Kar, Saibal & Saha, Snehanshu & Khaidem, Luckyson & Dey, Sudeepa Roy, 2019. "Predicting the direction of stock market prices using tree-based classifiers," The North American Journal of Economics and Finance, Elsevier, vol. 47(C), pages 552-567.
    7. Srivinay & B. C. Manujakshi & Mohan Govindsa Kabadi & Nagaraj Naik, 2022. "A Hybrid Stock Price Prediction Model Based on PRE and Deep Neural Network," Data, MDPI, vol. 7(5), pages 1-11, April.
    8. Lin, Qi, 2018. "Technical analysis and stock return predictability: An aligned approach," Journal of Financial Markets, Elsevier, vol. 38(C), pages 103-123.
    9. Jeffrey E. Jarrett & Janne Schilling, 2008. "Daily variation and predicting stock market returns for the frankfurter börse (stock market)," Journal of Business Economics and Management, Taylor & Francis Journals, vol. 9(3), pages 189-198, March.
    10. Fischer, Thomas & Krauss, Christopher, 2018. "Deep learning with long short-term memory networks for financial market predictions," European Journal of Operational Research, Elsevier, vol. 270(2), pages 654-669.
    11. Xu, Yong & Kou, Gang & Peng, Yi & Ding, Kexing & Ergu, Daji & Alotaibi, Fahd S., 2024. "Profit- and risk-driven credit scoring under parameter uncertainty: A multiobjective approach," Omega, Elsevier, vol. 125(C).
    12. Dev Shah & Haruna Isah & Farhana Zulkernine, 2019. "Stock Market Analysis: A Review and Taxonomy of Prediction Techniques," IJFS, MDPI, vol. 7(2), pages 1-22, May.
    Full references (including those not matched with items on IDEAS)

    Most related items

    These are the items that most often cite the same works as this one and are cited by the same works as this one.
    1. Htet Htet Htun & Michael Biehl & Nicolai Petkov, 2023. "Survey of feature selection and extraction techniques for stock market prediction," Financial Innovation, Springer;Southwestern University of Finance and Economics, vol. 9(1), pages 1-25, December.
    2. Kamaladdin Fataliyev & Aneesh Chivukula & Mukesh Prasad & Wei Liu, 2021. "Stock Market Analysis with Text Data: A Review," Papers 2106.12985, arXiv.org, revised Jul 2021.
    3. Ghosh, Pushpendu & Neufeld, Ariel & Sahoo, Jajati Keshari, 2022. "Forecasting directional movements of stock prices for intraday trading using LSTM and random forests," Finance Research Letters, Elsevier, vol. 46(PA).
    4. Kentaro Imajo & Kentaro Minami & Katsuya Ito & Kei Nakagawa, 2020. "Deep Portfolio Optimization via Distributional Prediction of Residual Factors," Papers 2012.07245, arXiv.org.
    5. Zhou, Hao & Kalev, Petko S., 2019. "Algorithmic and high frequency trading in Asia-Pacific, now and the future," Pacific-Basin Finance Journal, Elsevier, vol. 53(C), pages 186-207.
    6. Bartosz Bieganowski & Robert Ślepaczuk, 2024. "Supervised Autoencoder MLP for Financial Time Series Forecasting," Working Papers 2024-03, Faculty of Economic Sciences, University of Warsaw.
    7. Daniel Cunha Oliveira & Yutong Lu & Xi Lin & Mihai Cucuringu & Andre Fujita, 2024. "Causality-Inspired Models for Financial Time Series Forecasting," Papers 2408.09960, arXiv.org.
    8. Alexander Jakob Dautel & Wolfgang Karl Härdle & Stefan Lessmann & Hsin-Vonn Seow, 2020. "Forex exchange rate forecasting using deep recurrent neural networks," Digital Finance, Springer, vol. 2(1), pages 69-96, September.
    9. Kriebel, Johannes & Stitz, Lennart, 2022. "Credit default prediction from user-generated text in peer-to-peer lending using deep learning," European Journal of Operational Research, Elsevier, vol. 302(1), pages 309-323.
    10. Mercadier, Mathieu & Lardy, Jean-Pierre, 2019. "Credit spread approximation and improvement using random forest regression," European Journal of Operational Research, Elsevier, vol. 277(1), pages 351-365.
    11. Jian Ni & Yue Xu, 2023. "Forecasting the Dynamic Correlation of Stock Indices Based on Deep Learning Method," Computational Economics, Springer;Society for Computational Economics, vol. 61(1), pages 35-55, January.
    12. Tony Guida & Guillaume Coqueret, 2019. "Ensemble Learning Applied to Quant Equity: Gradient Boosting in a Multifactor Framework," Post-Print hal-02311104, HAL.
    13. Pushpendu Ghosh & Ariel Neufeld & Jajati Keshari Sahoo, 2020. "Forecasting directional movements of stock prices for intraday trading using LSTM and random forests," Papers 2004.10178, arXiv.org, revised Jun 2021.
    14. Elizabeth Fons & Paula Dawson & Xiao-jun Zeng & John Keane & Alexandros Iosifidis, 2020. "Evaluating data augmentation for financial time series classification," Papers 2010.15111, arXiv.org.
    15. Fabian Waldow & Matthias Schnaubelt & Christopher Krauss & Thomas Günter Fischer, 2021. "Machine Learning in Futures Markets," JRFM, MDPI, vol. 14(3), pages 1-14, March.
    16. L.J. Basson & Sune Ferreira-Schenk & Zandri Dickason-Koekemoer, 2022. "Fractal Dimension Option Hedging Strategy Implementation During Turbulent Market Conditions in Developing and Developed Countries," International Journal of Economics and Financial Issues, Econjournals, vol. 12(2), pages 84-95, March.
    17. Rabeh Khalfaoui & Sami Ben Jabeur & Shawkat Hammoudeh & Wissal Ben Arfi, 2025. "The role of political risk, uncertainty, and crude oil in predicting stock markets: evidence from the UAE economy," Annals of Operations Research, Springer, vol. 345(2), pages 1105-1135, February.
    18. Omer Berat Sezer & Mehmet Ugur Gudelek & Ahmet Murat Ozbayoglu, 2019. "Financial Time Series Forecasting with Deep Learning : A Systematic Literature Review: 2005-2019," Papers 1911.13288, arXiv.org.
    19. Werner Kristjanpoller & Kevin Michell & Cristian Llanos & Marcel C. Minutolo, 2025. "Incorporating causal notions to forecasting time series: a case study," Financial Innovation, Springer;Southwestern University of Finance and Economics, vol. 11(1), pages 1-22, December.
    20. Cao, Yi & Liu, Xiaoquan & Zhai, Jia, 2021. "Option valuation under no-arbitrage constraints with neural networks," European Journal of Operational Research, Elsevier, vol. 293(1), pages 361-374.

    Corrections

    All material on this site has been provided by the respective publishers and authors. You can help correct errors and omissions. When requesting a correction, please mention this item's handle: RePEc:spr:fininn:v:10:y:2024:i:1:d:10.1186_s40854-024-00644-0. See general information about how to correct material in RePEc.

    If you have authored this item and are not yet registered with RePEc, we encourage you to do it here. This allows to link your profile to this item. It also allows you to accept potential citations to this item that we are uncertain about.

    If CitEc recognized a bibliographic reference but did not link an item in RePEc to it, you can help with this form .

    If you know of missing items citing this one, you can help us creating those links by adding the relevant references in the same way as above, for each refering item. If you are a registered author of this item, you may also want to check the "citations" tab in your RePEc Author Service profile, as there may be some citations waiting for confirmation.

    For technical questions regarding this item, or to correct its authors, title, abstract, bibliographic or download information, contact: Sonal Shukla or Springer Nature Abstracting and Indexing (email available below). General contact details of provider: http://www.springer.com .

    Please note that corrections may take a couple of weeks to filter through the various RePEc services.

    IDEAS is a RePEc service. RePEc uses bibliographic data supplied by the respective publishers.