IDEAS home Printed from https://ideas.repec.org/p/arx/papers/2401.06139.html
   My bibliography  Save this paper

StockFormer: A Swing Trading Strategy Based on STL Decomposition and Self-Attention Networks

Author

Listed:
  • Bohan Ma
  • Yiheng Wang
  • Yuchao Lu
  • Tianzixuan Hu
  • Jinling Xu
  • Patrick Houlihan

Abstract

Amidst ongoing market recalibration and increasing investor optimism, the U.S. stock market is experiencing a resurgence, prompting the need for sophisticated tools to protect and grow portfolios. Addressing this, we introduce "Stockformer," a cutting-edge deep learning framework optimized for swing trading, featuring the TopKDropout method for enhanced stock selection. By integrating STL decomposition and self-attention networks, Stockformer utilizes the S&P 500's complex data to refine stock return predictions. Our methodology entailed segmenting data for training and validation (January 2021 to January 2023) and testing (February to June 2023). During testing, Stockformer's predictions outperformed ten industry models, achieving superior precision in key predictive accuracy indicators (MAE, RMSE, MAPE), with a remarkable accuracy rate of 62.39% in detecting market trends. In our backtests, Stockformer's swing trading strategy yielded a cumulative return of 13.19% and an annualized return of 30.80%, significantly surpassing current state-of-the-art models. Stockformer has emerged as a beacon of innovation in these volatile times, offering investors a potent tool for market forecasting. To advance the field and foster community collaboration, we have open-sourced Stockformer, available at https://github.com/Eric991005/Stockformer.

Suggested Citation

  • Bohan Ma & Yiheng Wang & Yuchao Lu & Tianzixuan Hu & Jinling Xu & Patrick Houlihan, 2023. "StockFormer: A Swing Trading Strategy Based on STL Decomposition and Self-Attention Networks," Papers 2401.06139, arXiv.org.
  • Handle: RePEc:arx:papers:2401.06139
    as

    Download full text from publisher

    File URL: http://arxiv.org/pdf/2401.06139
    File Function: Latest version
    Download Restriction: no
    ---><---

    References listed on IDEAS

    as
    1. Fama, Eugene F & French, Kenneth R, 1992. "The Cross-Section of Expected Stock Returns," Journal of Finance, American Finance Association, vol. 47(2), pages 427-465, June.
    2. 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.
    3. Ross, Stephen A, 1977. "The Capital Asset Pricing Model (CAPM), Short-Sale Restrictions and Related Issues," Journal of Finance, American Finance Association, vol. 32(1), pages 177-183, March.
    4. Fama, Eugene F. & French, Kenneth R., 2015. "A five-factor asset pricing model," Journal of Financial Economics, Elsevier, vol. 116(1), pages 1-22.
    5. Fung, William & Hsieh, David A, 1997. "Empirical Characteristics of Dynamic Trading Strategies: The Case of Hedge Funds," The Review of Financial Studies, Society for Financial Studies, vol. 10(2), pages 275-302.
    6. Jeremiah Green & John R. M. Hand & X. Frank Zhang, 2017. "The Characteristics that Provide Independent Information about Average U.S. Monthly Stock Returns," The Review of Financial Studies, Society for Financial Studies, vol. 30(12), pages 4389-4436.
    7. Jujie Wang & Zhenzhen Zhuang & Liu Feng, 2022. "Intelligent Optimization Based Multi-Factor Deep Learning Stock Selection Model and Quantitative Trading Strategy," Mathematics, MDPI, vol. 10(4), pages 1-19, February.
    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. Rungmaitree, Pattamon & Boateng, Agyenim & Ahiabor, Frederick & Lu, Qinye, 2022. "Political risk, hedge fund strategies, and returns: Evidence from G7 countries," Journal of International Financial Markets, Institutions and Money, Elsevier, vol. 81(C).
    2. François-Éric Racicot & Raymond Théoret, 2022. "Tracking market and non-traditional sources of risks in procyclical and countercyclical hedge fund strategies under extreme scenarios: a nonlinear VAR approach," Financial Innovation, Springer;Southwestern University of Finance and Economics, vol. 8(1), pages 1-56, December.
    3. Kentaro Imajo & Kentaro Minami & Katsuya Ito & Kei Nakagawa, 2020. "Deep Portfolio Optimization via Distributional Prediction of Residual Factors," Papers 2012.07245, arXiv.org.
    4. Vitor Azevedo & Christopher Hoegner, 2023. "Enhancing stock market anomalies with machine learning," Review of Quantitative Finance and Accounting, Springer, vol. 60(1), pages 195-230, January.
    5. Andrew Y. Chen & Jack McCoy, 2022. "Missing Values Handling for Machine Learning Portfolios," Papers 2207.13071, arXiv.org, revised Jan 2024.
    6. Guillaume Coqueret & Tony Guida, 2020. "Training trees on tails with applications to portfolio choice," Post-Print hal-04144665, HAL.
    7. Guillaume Chevalier & Guillaume Coqueret & Thomas Raffinot, 2022. "Supervised portfolios," Post-Print hal-04144588, HAL.
    8. Pawel Dlotko & Wanling Qiu & Simon Rudkin, 2019. "Financial ratios and stock returns reappraised through a topological data analysis lens," Papers 1911.10297, arXiv.org.
    9. Pedro M. Mirete-Ferrer & Alberto Garcia-Garcia & Juan Samuel Baixauli-Soler & Maria A. Prats, 2022. "A Review on Machine Learning for Asset Management," Risks, MDPI, vol. 10(4), pages 1-46, April.
    10. Uddin, Ajim & Yu, Dantong, 2020. "Latent factor model for asset pricing," Journal of Behavioral and Experimental Finance, Elsevier, vol. 27(C).
    11. Tobek, Ondrej & Hronec, Martin, 2021. "Does it pay to follow anomalies research? Machine learning approach with international evidence," Journal of Financial Markets, Elsevier, vol. 56(C).
    12. Ali, Sara & Badshah, Ihsan & Demirer, Riza, 2022. "Value-at-risk and the cross section of emerging market hedge fund returns," Global Finance Journal, Elsevier, vol. 52(C).
    13. Ma, Tian & Leong, Wen Jun & Jiang, Fuwei, 2023. "A latent factor model for the Chinese stock market," International Review of Financial Analysis, Elsevier, vol. 87(C).
    14. Guillaume Coqueret & Tony Guida, 2020. "Training trees on tails with applications to portfolio choice," Annals of Operations Research, Springer, vol. 288(1), pages 181-221, May.
    15. Joachim Freyberger & Andreas Neuhierl & Michael Weber, 2020. "Dissecting Characteristics Nonparametrically," The Review of Financial Studies, Society for Financial Studies, vol. 33(5), pages 2326-2377.
    16. Vitor Azevedo & Georg Sebastian Kaiser & Sebastian Mueller, 2023. "Stock market anomalies and machine learning across the globe," Journal of Asset Management, Palgrave Macmillan, vol. 24(5), pages 419-441, September.
    17. Cho, Thummim, 2018. "Turning alphas into betas: arbitrage and the cross-section of risk," LSE Research Online Documents on Economics 118915, London School of Economics and Political Science, LSE Library.
    18. Matthew Clegg & Christopher Krauss, 2018. "Pairs trading with partial cointegration," Quantitative Finance, Taylor & Francis Journals, vol. 18(1), pages 121-138, January.
    19. Han, Xing & Li, Kai & Li, Youwei, 2020. "Investor overconfidence and the security market line: New evidence from China," Journal of Economic Dynamics and Control, Elsevier, vol. 117(C).
    20. Greppmair, Stefan & Jank, Stephan & Smajlbegovic, Esad, 2023. "On the importance of fiscal space: Evidence from short sellers during the COVID-19 pandemic," Journal of Banking & Finance, Elsevier, vol. 147(C).

    More about this item

    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:arx:papers:2401.06139. 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: arXiv administrators (email available below). General contact details of provider: http://arxiv.org/ .

    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.