Journal of Soft Computing and Information Technology

Journal of Soft Computing and Information Technology

Using Machine Learning Methods to Predict Stock Returns Considering the Impact of Price Fluctuation Range Changes

Document Type : Persian Original Article

Authors
Department of Industrial Engineering, NT.C., Islamic Azad University, Tehran, Iran.
Abstract
This study investigates stock price prediction in the Iran Farabourse using machine learning methods, specifically Random Forest and Support Vector Regression. The primary objective is to improve prediction accuracy and examine the effect of changes in the price fluctuation range on model performance. To this end, data from four selected industrial stocks listed on the first tier of the Iran Farabourse were collected over two distinct time periods: 2015–2019 (for model evaluation under a stable fluctuation regime) and 2020–2022 (to assess the impact of fluctuation range changes). The input features include open price, Simple Moving Average (SMA), and Relative Strength Index (RSI), while the output is the closing price. After preprocessing and normalization, models were trained using the specified algorithms. The models’ performance was evaluated using standard metrics, including Mean Squared Error (MSE), Root Mean Squared Error (RMSE), Mean Absolute Error (MAE), Mean Absolute Percentage Error (MAPE), and the coefficient of determination (R²). In the first period, the Random Forest model demonstrated superior performance with an MSE of 162,217.18, MAE of 156.01, and R² of 1.00, compared to the Support Vector Regression model with an MSE of 355,674,554.14 and R² of 0.62. In the second period, although prediction errors increased in both models, Random Forest maintained better performance (MSE: 901,875.77; MAPE: 1.98%) than Support Vector Regression (MSE: 82,930,332.00; MAPE: 16.60%). A slight decrease in the R² value of Random Forest from 1.00 to 0.99 was also observed. These findings indicate that Random Forest consistently outperforms Support Vector Regression in both time frames and that changes in the price fluctuation range negatively affect prediction accuracy in both models. Overall, machine learning approaches can serve as effective tools for analyzing capital market dynamics, reducing investment risk, and supporting investors in making more informed financial decisions.
Keywords

[1] R. D. Singh, H. Chouhan, and M. Neema, "Predicting stock prices using machine learning: A comparative study," International Journal of Advances in Engineering and Management, vol. 5, no. 4, pp. 1812–1821, 2023.
[2] P. L. Sagar, C. Maheshbabu, G. V. S. Teja, and C. Vishnu, "An evaluation of stock market prediction using supervised machine learning techniques," in Proc. 2023 Int. Conf. Inventive Computation Technol. (ICICT), 2023, pp. 255–263, doi: 10.1109/ICICT57646.2023.10133970.
[3] A. Muratov, R. Szabo, and R. Varadi, "The impact of adverse selection on the quotation strategy of stock market specialists: A Monte Carlo simulation approach," Journal of Economic Dynamics & Control, vol. 106, pp. 249–261, 2019, doi: 10.1016/j.jedc.2019.05.002.
[4] M. Sohrabi, S. M. Mir Barzegar, and E. Chirani, "Comparison of different machine learning models in stock market index prediction," Financial Engineering and Securities Management Quarterly, vol. 14, no. 56, pp. 19–36, 2023.
[5] A. Eghtesad and M. Mohammadi, "Portfolio optimization by return prediction using LSTM, random forest, and ARIMA," Financial Management Perspective, vol. 13, no. 43, pp. 9–28, 2023, doi: 10.48308/jfmp.2024.104191.
[6] D. Riahi and A. Mazighi, "The effect of fluctuation limit changes on actual price volatility in the Tehran Stock Exchange," M.S. thesis, University of Tehran, Tehran, Iran, 2022.
[7] M. Dehghani, M. Ghasemzadeh, and H. Ansari-Samani, "Machine learning algorithms for time series in financial markets," Soft Computing and Information Technology Journal, vol. 8, no. 3, pp. 60–67, 2019.
[8] N. Kuhestani, I. Dadashi, H. Gholamnia Roshan, and K. Azinfar, "Day features and stock market performance," Financial Management Perspective, vol. 13, no. 44, pp. 33–58, 2024, doi: 10.48308/jfmp.2024.104307.
[9] N. Gholami and N. Shams Gharni, "An optimized CNN-LSTM model for stock price prediction in the Tehran Stock Exchange," Financial Management Perspective, vol. 14, no. 45, pp. 123–147, 2024, doi: 10.48308/jfmp.2024.104892.
[10] M. Nourahmadi and H. Sadeghi, "Machine learning based on the hierarchical risk parity approach (Case study: Stock portfolio of the top 30 companies listed on the Tehran Stock Exchange)," Financial Research Journal, vol. 24, no. 2, pp. 236–256, 2022.
[11] A. Chakravorty and N. Elsayed, "A Comparative Study of Machine Learning Algorithms for Stock Price Prediction Using Insider Trading Data," arXiv, Feb. 12, 2025.
[12] A. Dezhkam, M. T. Manzuri, A. Aghapour, A. Karimi, A. Rabiee, and S. M. Shalmani, "A Bayesian-based classification framework for financial time series trend prediction," The Journal of Supercomputing, vol. 79, pp. 4622–4659, 2023, doi: 10.1007/s11227-022-04746-8.
[13] S. V. Shashikala and H. S. Harshitha, "Stock Market Analysis and Prediction using Machine Learning Algorithm," International Journal for Research in Applied Science and Engineering Technology (IJRASET), vol. 11, no. 7, pp. 1092–1097, 2023, doi: 10.22214/ijraset.2023.54812.
[14] C. L. de Souza, "Previsão de Preços de Ações com Aprendizado de Máquina," ResearchGate, May 2024.
[15] M. Sui, C. Zhang, L. Zhou, S. Liao, and C. Wei, "An Ensemble Approach to Stock Price Prediction Using Deep Learning and Time Series Models," Preprints, vol. 2024, no. 09, p. 2077, 2024, doi: 10.20944/preprints202409.2077.v1.
[16] R. He, Z. Zhang, S. Zhang, and Q. Song, "Evaluating Regression and Ensemble Models for Financial Forecasting: The Case of Apple Stock," ResearchGate, Nov. 2023.
[17] A. Chakravorty and N. Elsayed, "A Comparative Study of Machine Learning Algorithms for Stock Price Prediction Using Insider Trading Data," arXiv, Feb. 12, 2025.
[18] C. L. de Souza, "Previsão de Preços de Ações com Aprendizado de Máquina," ResearchGate, May 2024.
[19] K. Ł. Szydłowski and J. A. Chudziak, "Hidformer: Transformer-Style Neural Network in Stock Price Forecasting," in USB Proceedings of the 21st International Conference on Modeling Decisions for Artificial Intelligence (MDAI 2024), Tokyo, Japan, Aug. 2024.
[20] R. Kumar et al., "The Effectiveness of Technical Indicators in Stock Price Prediction," International Journal of Financial Analysis, vol. 8, pp. 120–135, 2021.
[21] A. Muratov, R. Szabo, and R. Varadi, "The impact of adverse selection on the quotation strategy of stock market specialists: A Monte Carlo simulation approach," J. Econ. Dyn. Control, vol. 106, pp. 249–261, 2019.
[22] P. L. Sagar, C. Maheshbabu, G. V. S. Teja, and C. Vishnu, "An Evaluation of Stock Market Prediction using Supervised Machine Learning Techniques," in Proc. 2023 Int. Conf. Inventive Comput. Technol. (ICICT), Apr. 2023, doi: 10.1109/ICICT57646.2023.10133970.
[23] N. Kuhestani, I. Dadashi, H. Gholamnia Roshan, and K. Azinfar, "Daily features and stock market performance," Financial Management Perspective, vol. 13, no. 44, pp. 33–58, 2024, doi: 10.48308/jfmp.2024.104307.
[24] M. Hassannejad, M. Davalu, and F. Shabani, "The effects of price limit changes on intraday volatility in the Iranian stock market using realized variance (RV) and discrete Fourier transform (DFT)," Asset Management and Financial Engineering, vol. 11, no. 2, pp. 19–34, 2023, doi: 10.22108/amf.2023.134778.1755.
[25] S. Behrampour and K. Kiani, "Stock market trend prediction using data mining in big data," M.S. thesis, Semnan University, Electrical Engineering, 2015.
[26] I. Davoudi Kasbi, I. Dadashi, and K. Azinfar, "Stock price analysis using machine learning methods," Financial Advances and Mathematical Applications, vol. 6, no. 2, pp. 285–301, 2021.
[27] Sh. Bagheri and H. Izadbaksh, "Stock market prediction using machine learning, deep learning, and econometric methods: A comparative study," M.S. thesis, Shahid Beheshti University, 2021.
[28] A. Li, Q. Wei, Y. Shi, and Z. Liu, "Research on stock price prediction from a data fusion perspective," Data Science in Finance and Economics, vol. 3, no. 3, pp. 230–250, 2023, doi: 10.3934/DSFE.2023014.
[29] Md. S. Ansary, "Machine learning for predicting the stock price direction with trading indicators," ENP Engineering Science Journal, vol. 3, no. 2, pp. 34–40, 2023, doi: 10.53907/enpesj.v3i2.178.
[30] W. Bao, Y. Cao, Y. Yang, H. Che, J. Huang, and S. Wen, "Data-driven stock forecasting models based on neural networks: A review," Information Fusion, vol. 102, art. 102616, 2024, doi: 10.1016/j.inffus.2024.102616.
[31] S. Pashankar, J. Shendage, and J. Pawar, "Machine learning techniques for stock price prediction: A comparative analysis of linear regression, random forest, and support vector regression," Journal of Advanced Zoology, vol. 45, no. S4, pp. 118–127, 2024, doi: 10.53555/jaz.v45iS4.4164.
[32] T. Li, F. Ma, X. Zhang, and Y. Zhang, "Economic policy uncertainty and the Chinese stock market volatility: Novel evidence," Economic Modelling, vol. 87, pp. 24–33, 2020, doi: 10.1016/j.econmod.2019.07.002.
[33] P. Gao, R. Zhang, and X. Yang, "The application of stock index price prediction with neural network," Mathematics and Computers in Applications, vol. 25, no. 3, art. 53, 2020, doi: 10.3390/mca25030053.
[34] I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning. Cambridge, MA, USA: MIT Press, 2016.
[35] M. Kantardzic, Data Mining: Concepts, Models, Methods, and Algorithms, 2nd ed. Hoboken, NJ, USA: Wiley, 2011, doi: 10.1002/9781118029145.
[36] J. Patel, S. Shah, P. Thakkar, and K. Kotecha, "Predicting stock market index using fusion of machine learning techniques," Expert Systems with Applications, vol. 42, no. 4, pp. 1–9, 2014, doi: 10.1016/j.eswa.2014.10.031.