Iranian Journal of Accounting, Auditing and Finance

Iranian Journal of Accounting, Auditing and Finance

Predicting Stock Market Returns Using Temporal Fusion Transformer: A Comprehensive Data-Driven Approach

Document Type : Original Article

Authors
1 School of Industrial Engineering and Management, Shahrood University of Technology, Shahrood, Iran
2 Department of Computer Science, University of Passau, Passau, Germany
3 Department of Computer Engineering, Imam Reza International University, Mashhad, Iran.
10.22067/ijaaf.2026.47513.1562
Abstract
Stock market return prediction remains a highly challenging task due to the complex, dynamic, and noisy nature of financial markets. Although machine learning and deep learning models have been widely explored, many approaches struggle to capture long-term temporal dependencies and provide interpretable feature selection. In tackling these issues, the Temporal Fusion Transformer (TFT) is applied for multi-horizon time series forecasting of daily returns in Tehran Stock Exchange (TSE). Accordingly, the study proposes a new feature selection method called Initial Selected Features–Mutual Information Difference (ISF-MID), which enhances the traditional Minimum Redundancy Maximum Relevance (mRMR) algorithm by demonstrating a superior capability of handling redundancy and focusing on determining important parameters. Dual preprocessing works on ISF-MID, mRMR and PCA that improve the predictive performance, while also allowing for interpretable machine learning by working with a better representation of input. Mean Absolute Error (MAE), Mean Squared Error (MSE) and the coefficient of determination (R²) were used to conduct extensive comparisons with benchmark methods such as, Long Short-Term Memory LSTM, Multi-Layer Perceptron MLP, and Random Forest RF. Thus, the proposed method achieved competitive performance against benchmark architectures (i.e. TFT achieves R², of 98.9%, MAE 0.00043 and MSE 0.000018 on out-of-sample test, as well as high directional accuracy). Overall, the synergy of TFT with the ISF-MID feature selection strategy provides methodological novelty and practical significance, extending a potential framework for evidence-based return prediction and informed risk-central investment decisions.
Keywords
Subjects

  1. Akiba, T., Sano, S., Yanase, T., Ohta, T. and Koyama, M. (2019). Optuna: A next-generation hyperparameter optimization framework. In Proceedings of the 25th ACM SIGKDD international conference on knowledge discovery & data mining (pp. 2623-2631). New York, NY. https://doi.org/10.1145/3292500.3330701
  2. Alam, K., Bhuiyan, M. H., Haque, I. U., Monir, M. F. and Ahmed, T. (2024). Enhancing stock market prediction: A robust LSTM-DNN model analysis on 26 real-life datasets. IEEE Access, 12, pp. 122757-122768. https://doi.org/10.1109/ACCESS.2024.3434524
  3. Awad, A. L., Elkaffas, S. M. and Fakhr, M. W. (2023). Stock market prediction using deep reinforcement learning. Applied System Innovation, 6(6), p. 106. https://doi.org/10.3390/asi6060106
  4. Bao, W., Yue, J. and Rao, Y. (2017). A deep learning framework for financial time series using stacked autoencoders and long-short term memory. PloS One, 12(7), A. e0180944. https://doi.org/10.1371/journal.pone.0180944
  5. Bieganowski, B. and Ślepaczuk, R. (2025). Supervised autoencoder MLP for financial time series forecasting. Journal of Big Data, 12(1), p. 207. https://doi.org/10.1186/s40537-025-01267-7
  6. Costantini, M., Cuaresma, J. C. and Hlouskova, J. (2016). Forecasting errors, directional accuracy and profitability of currency trading: The case of EUR/USD exchange rate. Journal of Forecasting, 35(7), pp. 652-668. https://doi.org/10.1002/for.2398
  7. Dashtaki, S. M., Chagahi, M. H., Bahadori, A., Moshiri, B., Piran, M. J. and Montazeri, A. (2025). HSIF: A transformer-based cross-attention framework for cryptocurrency trend forecasting via multimodal sentiment–market fusion. IEEE Access, 13, pp. 156600-156612. https://doi.org/10.1109/ACCESS.2025.3605522
  8. Davoud Abadi, M. (2025). Forecasting financial market indices using a transformer-based model (Master’s thesis). Allameh Tabataba’i University, Tehran, Iran (In Persian).
  9. Dos Santos, J. P. G., Moutinho, V. M. F., Madaleno, M. and Teixeira, Z. M. D. S. S. (2025). Examining the effect of macroeconomic, institutional, and capital market drivers on infrastructure investment. Economic Analysis and Policy, 86, pp. 165-190. https://doi.org/10.1016/j.eap.2025.02.038
  10. Emami Gohari, H., Dang, X. H., Shah, S. Y. and Zerfos, P. (2024). Modality-aware transformer for financial time series forecasting. In Proceedings of the 5th ACM International Conference on AI in Finance (pp. 677-685). Association for Computing Machinery. https://doi.org/10.1145/3677052.3698654
  11. Gandhudi, M., Alphonse, P. J. A., Velayudham, V., Nagineni, L. and Gangadharan, G. R. (2024). Explainable causal variational autoencoders based equivariant graph neural networks for analyzing the consumer purchase behavior in E-commerce. Engineering Applications of Artificial Intelligence, 136, A. 108988. https://doi.org/10.1016/j.engappai.2024.108988
  12. Guo, Z., Ye, W., Yang, J. and Zeng, Y. (2017). Financial index time series prediction based on bidirectional two-dimensional locality preserving projection. In Proceedings of the 2017 IEEE 2nd International Conference on Big Data Analysis (ICBDA) (pp. 934 –938). IEEE, New York. https://doi.org/10.1109/ICBDA.2017.8078775
  13. Hartanto, S. and Gunawan, A. A. S. (2024). Temporal fusion transformers for enhanced multivariate time series forecasting of Indonesian stock prices. International Journal of Advanced Computer Science and Applications (IJACSA), 15(7), pp. 1-22. https://doi.org/10.14569/IJACSA.2024.0150713
  14. https://arxiv.org/abs/2503.18096
  15. Jaiwang, G. and Jeatrakul, P. (2018). Enhancing support vector machine model for stock trading using optimization techniques. In 2018 International Conference on Digital Arts, Media and Technology (ICDAMT) (pp. 23-28). Phayao, Thailand. https://doi.org/10.1109/ICDAMT.2018.8376489
  16. John, A. and Latha, T. (2023). Stock market prediction based on deep hybrid RNN model and sentiment analysis. Automatika, 64(4), pp. 981-995. https://doi.org/10.1080/00051144.2023.2217602
  17. Kumarappan, J., Rajasekar, E., Vairavasundaram, S., Kotecha, K. and Kulkarni, A. (2024). Federated learning enhanced MLP–LSTM modeling in an integrated deep learning pipeline for stock market prediction. International Journal of Computational Intelligence Systems, 17(1), p. 267. https://doi.org/10.1007/s44196-024-00680-9
  18. Kumbure, M. M., Lohrmann, C., Luukka, P. and Porras, J. (2022). Machine learning techniques and data for stock market forecasting: A literature review. Expert Systems with Applications, 197, A. 116659. https://doi.org/10.1016/j.eswa.2022.116659
  19. Li, Y., Ni, P. and Chang, V. (2020). Application of deep reinforcement learning in stock trading strategies and stock forecasting. Computing, 102(6), pp. 1305-1322. https://doi.org/10.1007/s00607-019-00773-w
  20. Liang, X., Ge, Z., Sun, L., He, M. and Chen, H. (2019). LSTM with wavelet transform based data preprocessing for stock price prediction. Mathematical Problems in Engineering, 2019(1), A. 1340174. https://doi.org/10.1155/2019/1340174
  21. Lim, B., Arık, S. Ö., Loeff, N. and Pfister, T. (2021). Temporal fusion transformers for interpretable multi-horizon time series forecasting. International journal of forecasting, 37(4), pp. 1748-1764. https://doi.org/10.1016/j.ijforecast.2021.03.012
  22. Liwei, T., Li, F., Yu, S. and Yuankai, G. (2021). Forecast of LSTM-XGBoost in Stock Price Based on Bayesian Optimization. Intelligent Automation & Soft Computing, 29(3), pp. 855–868. https://doi.org/10.32604/iasc.2021.016805
  23. Mohebbi Najm Abad, J. and Soleimani, A. (2018). Novel feature selection algorithm for thermal prediction model. IEEE Transactions on Very Large-Scale Integration (VLSI) Systems, 26(10), pp. 1831-1844. https://doi.org/10.1109/TVLSI.2018.2841318
  24. Mohebbi, M. R., Kafash, E. and Döller, M. (2025a). Multi-Agent Trajectory Prediction for Urban Environments with UAV Data Using Enhanced Temporal Kolmogorov-Arnold Networks with Particle Swarm Optimization. In ICAART (2) (pp. 586-597). ScitePress, Setúbal, Portugal. https://doi.org/10.5220/0013243100003890
  25. Mohebbi, M. R., Klinger, J., Abad, J. M. N., Döller, M. and Tavasoli, M. (2025b). Advanced driving behavior analysis through Kolmogorov-Arnold network and UAV traffic data. In International Conference on Machine Learning and Computing (pp. 305-322). Cham: Springer Nature Switzerland, Switzerland. https://doi.org/10.1007/978-3-031-94892-3_23
  26. Mohebbi, M. R., Zada, M. J. H., Rostami-Shahrbabaki, M., Döller, M. and Yamnenko, I. (2024). Network traffic co-movement assessment via oriented basis signal processing and ensemble decision trees. In 2024 IEEE 27th International Conference on Intelligent Transportation Systems (ITSC) (pp. 1948-1955). IEEE, Piscataway, NJ. https://doi.org/10.1109/ITSC58415.2024.10919555
  27. Mohebi, S., Fadaeinejad, M. E., Osoolian, M. and Hamidizadeh, M. R. (2022a). Feature Selection for the Prediction Model of the Tehran Stock Exchange Index by Dimensionality Reduction Techniques. Financial Research Journal, 24(4), pp. 577-601. https://doi.org/10.22059/frj.2021.325675.1007202
  28. Mohebi, S., Fadaeinezhad, M. and Osoolian, M. (2022b). Predicting the Tehran Stock Exchange Index using support vector regression; Based on the dimension reduction technique. Financial Management Strategy, 10(3), pp. 1–26 (In Persian). https://doi.org/10.22051/jfm.2022.35543.2528
  29. Nabipour, M., Nayyeri, P., Jabani, H., Mosavi, A., Salwana, E. and S, S. (2020). Deep learning for stock market prediction. Entropy, 22(8), p. 840. https://doi.org/10.3390/e22080840
  30. Niu, H., Xu, K. and Wang, W. (2020). A hybrid stock price index forecasting model based on variational mode decomposition and LSTM network: A hybrid stock price index forecasting model based on variational mode decomposition and LSTM network. Applied Intelligence, 50(12), pp. 4296-4309. https://doi.org/10.1007/s10489-020-01814-0
  31. Pourroostaei Ardakani, S., Du, N., Lin, C., Yang, J. C., Bi, Z. and Chen, L. (2023). A federated learning-enabled predictive analysis to forecast stock market trends. Journal of Ambient Intelligence and Humanized Computing, 14(4), pp. 4529-4535. https://doi.org/10.1007/s12652-023-04570-4
  32. Sezer, O. B., Gudelek, M. U. and Ozbayoglu, A. M. (2020). Financial time series forecasting with deep learning: A systematic literature review: 2005–2019. Applied Soft Computing, 90(1), A. 106181. https://doi.org/10.1016/j.asoc.2020.106181
  33. Sharma, R. and Mehta, K. (2024). Stock market predictions using deep learning: developments and future research directions. Deep Learning Tools for Predicting Stock Market Movements, 1(1), pp. 89-121. https://doi.org/10.1002/9781394214334.ch4
  34. Sun, Y., Yuan, H. and Xu, F. (2025). Financial sentiment analysis for pre-trained language models incorporating dictionary knowledge and neutral features. Natural Language Processing Journal, 11(1), A. 100148. https://doi.org/10.1016/j.nlp.2025.100148
  35. Tulcanaza Prieto, A. B. and Lee, Y. H. (2019). Determinants of stock market performance: VAR and VECM designs in Korea and Japan. Global Business & Finance Review (GBFR), 24(4), pp. 24-44. https://doi.org/10.17549/gbfr.2019.24.4.24
  36. Wang, C., Chen, Y., Zhang, S. and Zhang, Q. (2022). Stock market index prediction using deep Transformer model. Expert Systems with Applications, 208, A. 118128. https://doi.org/10.1016/j.eswa.2022.118128
  37. Wei, D. (2019). Prediction of stock price based on LSTM neural network. In 2019 International Conference on Artificial Intelligence and Advanced Manufacturing (AIAM) (pp. 544-547). IEEE, New York. https://doi.org/10.1109/AIAM48774.2019.00113
  38. Wei, X., Chen, W. and Li, X. (2021). Exploring the financial indicators to improve the pattern recognition of economic data based on machine learning. Neural Computing and Applications, 33(2), pp. 723-737. https://doi.org/10.1007/s00521-020-05094-0
  39. Wei, Y., Gu, X., Feng, Z., Li, Z. and Sun, M. (2024). Feature extraction and model optimization of deep learning in stock market prediction. Journal of Computer Technology and Software, 3(4), 1-22. https://doi.org/10.5281/zenodo.13622489
  40. Wu, Y. (2023). Comparison between transformer, informer, autoformer and non-stationary transformer in financial market. Applied and Computational Engineering, 29, pp. 68-78. https://doi.org/10.54254/2755-2721/29/20230874
  41. Wu, Y., Fu, Z., Liu, X. and Bing, Y. (2023). A hybrid stock market prediction model based on GNG and reinforcement learning. Expert Systems with Applications, 228, A. 120474. https://doi.org/10.1016/j.eswa.2023.120474
  42. Yang, J., Li, P., Cui, Y., Han, X. and Zhou, M. (2025). Multi-sensor temporal fusion transformer for stock performance prediction: An adaptive Sharpe ratio approach. Sensors, 25(3), p. 976. https://doi.org/10.3390/s25030976
  43. Zhang, J., Cui, S., Xu, Y., Li, Q. and Li, T. (2018). A novel data-driven stock price trend prediction system. Expert Systems with Applications, 97(1), pp. 60-69. https://doi.org/10.1016/j.eswa.2017.12.026
  44. Zheng, H., Wu, J., Song, R. and Guo, L. (2024). Predicting financial enterprise stocks and economic data trends using machine learning time series analysis. Applied and Computational Engineering, 87(1), pp. 26–32. https://doi.org/10.20944/preprints202407.0895.v1
  45. Zhong, X. and Enke, D. (2017). Forecasting daily stock market return using dimensionality reduction. Expert Systems with Applications, 67(2), pp. 126-139. https://doi.org/10.1016/j.eswa.2016.09.027
Send comment about this article
Enter Name.
Enter a valid email address.
Enter a vaid affiliation.
Enter comments (At leaset 10 words)
CAPTCHA Image
Enter Security Code Correctly.