IDEAS home Printed from https://ideas.repec.org/p/war/wpaper/2022-21.html
   My bibliography  Save this paper

A comparison of LSTM and GRU architectures with novel walk-forward approach to algorithmic investment strategy

Author

Listed:
  • Illia Baranochnikov

    (University of Warsaw, Faculty of Economic Sciences; Quantitative Finance Research Group)

  • Robert Ślepaczuk

    (University of Warsaw, Faculty of Economic Sciences, Department of Quantitative Finance; Quantitative Finance Research Group)

Abstract

The aim of this work is to build a profitable algorithmic investment strategy on various types of assets. The algorithm is built using recurrent neural networks (LSTM and GRU) as the primary source of signals to buy/sell financial instruments. LSTM and GRU architectures are compared in terms of obtaining the best results and beating the market. The algorithm is tested for four financial instruments (Bitcoin, Tesla, Brent Oil and Gold) on daily and hourly data frequencies. The out-of-sample period is from 1 January 2021 to 1 April 2022. A walk-forward process is responsible for training models and selecting the best model to forecast asset prices in the future. Ten model architectures with various hyperparameters are trained during each step of the walk-forward process. The model architecture with the highest Information Ratio (IR*) in the validation period is used for forecasting in the out-of-sample period. For each strategy, the performance metrics are calculated based on which the profitability of the algorithm is evaluated. At the end, a detailed sensitivity analysis with regards to the main hyperparameters is conducted. The results reveal that LSTM outperforms GRU in most of the cases and that investment strategy built based on LSTM/GRU architecture is able to beat the market only on 50% of tested cases.

Suggested Citation

  • Illia Baranochnikov & Robert Ślepaczuk, 2022. "A comparison of LSTM and GRU architectures with novel walk-forward approach to algorithmic investment strategy," Working Papers 2022-21, Faculty of Economic Sciences, University of Warsaw.
  • Handle: RePEc:war:wpaper:2022-21
    as

    Download full text from publisher

    File URL: https://www.wne.uw.edu.pl/download_file/1910/0
    File Function: First version, 2022
    Download Restriction: no
    ---><---

    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. Tej Bahadur Shahi & Ashish Shrestha & Arjun Neupane & William Guo, 2020. "Stock Price Forecasting with Deep Learning: A Comparative Study," Mathematics, MDPI, vol. 8(9), pages 1-15, August.
    3. Ryś Przemysław & Ślepaczuk Robert, 2018. "Machine Learning Methods in Algorithmic Trading Strategy Optimization – Design and Time Efficiency," Central European Economic Journal, Sciendo, vol. 5(52), pages 206-229, January.
    4. Christopher Krauss & Anh Do & Nicolas Huck, 2017. "Deep neural networks, gradient-boosted trees, random forests: Statistical arbitrage on the S&P 500," Post-Print hal-01768895, HAL.
    5. 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).
    6. 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.
    7. 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.
    8. Fama, Eugene F, 1970. "Efficient Capital Markets: A Review of Theory and Empirical Work," Journal of Finance, American Finance Association, vol. 25(2), pages 383-417, May.
    Full references (including those not matched with items on IDEAS)

    Citations

    Citations are extracted by the CitEc Project, subscribe to its RSS feed for this item.
    as


    Cited by:

    1. Jin Shang & Shigeyuki Hamori, 2023. "Do Large Datasets or Hybrid Integrated Models Outperform Simple Ones in Predicting Commodity Prices and Foreign Exchange Rates?," JRFM, MDPI, vol. 16(6), pages 1-25, June.
    2. Katarzyna Kryńska & Robert Ślepaczuk, 2022. "Daily and intraday application of various architectures of the LSTM model in algorithmic investment strategies on Bitcoin and the S&P 500 Index," Working Papers 2022-25, Faculty of Economic Sciences, University of Warsaw.

    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. Kentaro Imajo & Kentaro Minami & Katsuya Ito & Kei Nakagawa, 2020. "Deep Portfolio Optimization via Distributional Prediction of Residual Factors," Papers 2012.07245, arXiv.org.
    2. 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.
    3. Flori, Andrea & Regoli, Daniele, 2021. "Revealing Pairs-trading opportunities with long short-term memory networks," European Journal of Operational Research, Elsevier, vol. 295(2), pages 772-791.
    4. 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.
    5. Keer Yang & Guanqun Zhang & Chuan Bi & Qiang Guan & Hailu Xu & Shuai Xu, 2023. "Improving CNN-base Stock Trading By Considering Data Heterogeneity and Burst," Papers 2303.09407, arXiv.org.
    6. Schnaubelt, Matthias & Fischer, Thomas G. & Krauss, Christopher, 2018. "Separating the signal from the noise - financial machine learning for Twitter," FAU Discussion Papers in Economics 14/2018, Friedrich-Alexander University Erlangen-Nuremberg, Institute for Economics.
    7. Ariel Neufeld & Julian Sester & Daiying Yin, 2022. "Detecting data-driven robust statistical arbitrage strategies with deep neural networks," Papers 2203.03179, arXiv.org, revised Feb 2024.
    8. Schnaubelt, Matthias & Fischer, Thomas G. & Krauss, Christopher, 2020. "Separating the signal from the noise – Financial machine learning for Twitter," Journal of Economic Dynamics and Control, Elsevier, vol. 114(C).
    9. Jinho Lee & Raehyun Kim & Yookyung Koh & Jaewoo Kang, 2019. "Global Stock Market Prediction Based on Stock Chart Images Using Deep Q-Network," Papers 1902.10948, arXiv.org.
    10. Thomas Günter Fischer & Christopher Krauss & Alexander Deinert, 2019. "Statistical Arbitrage in Cryptocurrency Markets," JRFM, MDPI, vol. 12(1), pages 1-15, February.
    11. Baoqiang Zhan & Shu Zhang & Helen S. Du & Xiaoguang Yang, 2022. "Exploring Statistical Arbitrage Opportunities Using Machine Learning Strategy," Computational Economics, Springer;Society for Computational Economics, vol. 60(3), pages 861-882, October.
    12. 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.
    13. Moews, Ben & Ibikunle, Gbenga, 2020. "Predictive intraday correlations in stable and volatile market environments: Evidence from deep learning," Physica A: Statistical Mechanics and its Applications, Elsevier, vol. 547(C).
    14. 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.
    15. Fischer, Thomas & Krauss, Christopher, 2017. "Deep learning with long short-term memory networks for financial market predictions," FAU Discussion Papers in Economics 11/2017, Friedrich-Alexander University Erlangen-Nuremberg, Institute for Economics.
    16. 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.
    17. 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.
    18. Tony Guida & Guillaume Coqueret, 2019. "Ensemble Learning Applied to Quant Equity: Gradient Boosting in a Multifactor Framework," Post-Print hal-02311104, HAL.
    19. Rubesam, Alexandre, 2022. "Machine learning portfolios with equal risk contributions: Evidence from the Brazilian market," Emerging Markets Review, Elsevier, vol. 51(PB).
    20. 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.

    More about this item

    Keywords

    deep learning; recurrent neural networks; algorithm; trading strategy; LSTM; GRU; walk-forward process;
    All these keywords.

    JEL classification:

    • C4 - Mathematical and Quantitative Methods - - Econometric and Statistical Methods: Special Topics
    • C14 - Mathematical and Quantitative Methods - - Econometric and Statistical Methods and Methodology: General - - - Semiparametric and Nonparametric Methods: General
    • C45 - Mathematical and Quantitative Methods - - Econometric and Statistical Methods: Special Topics - - - Neural Networks and Related Topics
    • C53 - Mathematical and Quantitative Methods - - Econometric Modeling - - - Forecasting and Prediction Models; Simulation Methods
    • C58 - Mathematical and Quantitative Methods - - Econometric Modeling - - - Financial Econometrics
    • G13 - Financial Economics - - General Financial Markets - - - Contingent Pricing; Futures Pricing

    NEP fields

    This paper has been announced in the following NEP Reports:

    Statistics

    Access and download statistics

    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:war:wpaper:2022-21. 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: Marcin Bąba (email available below). General contact details of provider: https://edirc.repec.org/data/fesuwpl.html .

    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.