Performance Comparison of RNNs and CNNs Models in Forecasting Moroccan stock market indicator

Introduction:: Financial stock-market forecasting is of great importance to institutions, investors, and researchers, particularly as markets become increasingly interdependent and influenced by diverse economic and political factors. This study focuses on forecasting the FTSE CSE index returns using advanced deep learning models. materials and methods: 2.1. Data Preparation In our study, we deploy RNN models-LSTM and GRU-and CNN models to predict the future move ments of the FTSE CSE Morocco (table1). These models process daily closing prices of the FTSE, treating them as a time series. To assess the LSTM, GRU and CNN predictability, the data available has been split into two parts: the first 80% of the dataset will be utilized in training the model, while the remaining 20% shall constitute the test set. This provides a very fair idea of the efficiency of the model. Moreover, to analyze crit ically the performance of the model for efficiency and effectiveness. This approach not only tests the model’s adaptability to different market conditions but also gives a broader understanding of its predictive power. Fur thermore, we also introduced some metrics, such as MAE and RMSE in both our training and testing analysis. These are important in providing a quantified look into the model’s precision and stability for the prediction of trends within MASI, thus enabling clear insight into the overall performance of LSTM, GRU, and CNN models. 2.1.1. Data Sourcing and Cleaning Below is the first step in the study: downloading historical stock market data from Investing.com in CSV format. Table 1 presents this, which may be a basic building block that can provide the foundation for Predictive modeling with many data analysis tools. This dataset is first organized into discrete columns for concentrated analysis of separate variables; each column has been standardized for value consistency and comparability and has been cleaned of invalid values such as ’NaN’ entries, which could easily bias the result. Method:: Three deep learning architectures, 1D CNN, LSTM, and GRU, were evaluated. Historical closing prices were transformed into normalized returns and divided into 80% training and 20% testing sets. The models were trained using identical hyperparameters: Adam optimizer (learning rate = 0.001, = 0.9, = 0.999), batch size = 1, validation split = 20%, early stopping with a patience of 10 epochs, and a maximum of 100 epochs. Results:: On the test dataset, the GRU model achieved the best performance with RMSE = 77.83 and MAE = 53.68, outperforming LSTM (RMSE = 84.37, MAE = 62.36) and 1D-CNN (RMSE = 100.62, MAE = 76.56). discussion: The figure 3 for learning curves provides that: The learning curves for all the models are effectively learned, with very few cases of overfitting. This is well evidenced in the LSTM model, where the training loss decreases steeply while the validation loss remains stable, with only slight fluctuations throughout, a good indication of learning. The losses are very close; hence, the generalization performance of the model is quite good. On the other hand, the CNN model stabilizes a bit faster and with hardly any gap between training and validation loss. Where the training loss in the GRU model is showing a consistent decline and stabilizing, the validation loss also follows closely. hence reflecting that effective learning and generalization are taking place with no significant overfitting The figure 4 presents the Prediction Error Distributions: Error distributions are quite clear from the models. Most of the errors of the LSTM model centre around zero with a slight skew to the positive, meaning that the predictions are quite near the actual values with a few outliers. The CNN model errors are zero-centered as well, but the range is bigger, with more extreme outliers, which could indicate more variability and specific problems in fitting some of the patterns in the data. The GRU model errors are more spread compared to LSTM but less compared to CNN; slightly positively biased, to indicate a tendency to over-predict, though outliers are less frequent compared to CNN Discussion:: All models demonstrated the ability to capture the overall trends of the FTSE CSE index returns. However, the GRU model provided more accurate and stable predictions, likely due to its efficient handling of temporal dependencies in financial time-series data. conclusion: This study extensively examined the predictive capabilities of three widely used neural network mod els GRU, 1D-CNN, and LSTM on financial time series data. Through an exhaustive performance metric com parison and careful visual inspection, we thoroughly realized the strengths and limitations of each model to predict the FTSE CSE Morocco Index. TheGRUmodelshowedexcellentgeneralizationperformancewiththelowesterror rates whenapplied to the test set. Its ability to successfully model sequential dependencies without overfiting it too much makes it a dependable choice for operations in financial forecasting. Conversely, the 1D-CNN model, which was originally designed to handle spatial data, fared poorly when utilized in modeling sequential financial data. Though it did have a degree of accuracy, its performance indicates that it may not be the best tool to employ in modeling long-term dependencies of stock market trends. The LSTM model worked most effectively in learning complex long-term dependencies and had the lowest training RMSE among all models. However, its slightly larger test RMSE shows potential overfitting risk, which was prevented by applying early stopping to allow better generalization. This underlines the im portance of suitable model parameter tuning and the implementation of regularization techniques in financial forecasting based on deep learning. In addition to comparing model performance, this research highlights the importance of matching model choice with the nature of financial data and the target of the forecasting problem. The results indicate that although RNN-based models (GRU and LSTM) are better for financial time series prediction, proper attention should be devoted to training protocols and overfitting avoidance techniques. Future research can explore hybrid architectures that leverage the strengths of both CNNs and RNNs, add external macroeconomic factors, or use attention mechanisms to further enhance predictive accuracy. By extending the application of deep learning to financial forecasting, this research contributes to the growing liter ature of AI-driven stock market studies, offering valuable insights for both research investigation and practical implementation Conclusion:: GRU outperformed both LSTM and 1D-CNN in forecasting Moroccan stock market returns, making it a promising model for emerging-market return prediction and similar financial forecasting tasks.

Authors

Institutions

Publication Details

Journal
Recent Advances in Computer Science and Communications
Published
2026-03-16
DOI
https://doi.org/10.2174/0126662558409918251202144840
Primary Topic
Stock Market Forecasting Methods
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Performance Comparison of RNNs and CNNs Models in Forecasting Moroccan stock market indicator

Amine El Hossi, Abdelali Elmoufidi, Ayman Mazzouz
Recent Advances in Computer Science and Communications
Stock Market Forecasting Methods
article

Performance Comparison of RNNs and CNNs Models in Forecasting Moroccan stock market indicator

Amine El Hossi, Abdelali Elmoufidi, Ayman Mazzouz
article en

Abstract

Introduction:: Financial stock-market forecasting is of great importance to institutions, investors, and researchers, particularly as markets become increasingly interdependent and influenced by diverse economic and political factors. This study focuses on forecasting the FTSE CSE index returns using advanced deep learning models. materials and methods: 2.1. Data Preparation In our study, we deploy RNN models-LSTM and GRU-and CNN models to predict the future move ments of the FTSE CSE Morocco (table1). These models process daily closing prices of the FTSE, treating them as a time series. To assess the LSTM, GRU and CNN predictability, the data available has been split into two parts: the first 80% of the dataset will be utilized in training the model, while the remaining 20% shall constitute the test set. This provides a very fair idea of the efficiency of the model. Moreover, to analyze crit ically the performance of the model for efficiency and effectiveness. This approach not only tests the model’s adaptability to different market conditions but also gives a broader understanding of its predictive power. Fur thermore, we also introduced some metrics, such as MAE and RMSE in both our training and testing analysis. These are important in providing a quantified look into the model’s precision and stability for the prediction of trends within MASI, thus enabling clear insight into the overall performance of LSTM, GRU, and CNN models. 2.1.1. Data Sourcing and Cleaning Below is the first step in the study: downloading historical stock market data from Investing.com in CSV format. Table 1 presents this, which may be a basic building block that can provide the foundation for Predictive modeling with many data analysis tools. This dataset is first organized into discrete columns for concentrated analysis of separate variables; each column has been standardized for value consistency and comparability and has been cleaned of invalid values such as ’NaN’ entries, which could easily bias the result. Method:: Three deep learning architectures, 1D CNN, LSTM, and GRU, were evaluated. Historical closing prices were transformed into normalized returns and divided into 80% training and 20% testing sets. The models were trained using identical hyperparameters: Adam optimizer (learning rate = 0.001, = 0.9, = 0.999), batch size = 1, validation split = 20%, early stopping with a patience of 10 epochs, and a maximum of 100 epochs. Results:: On the test dataset, the GRU model achieved the best performance with RMSE = 77.83 and MAE = 53.68, outperforming LSTM (RMSE = 84.37, MAE = 62.36) and 1D-CNN (RMSE = 100.62, MAE = 76.56). discussion: The figure 3 for learning curves provides that: The learning curves for all the models are effectively learned, with very few cases of overfitting. This is well evidenced in the LSTM model, where the training loss decreases steeply while the validation loss remains stable, with only slight fluctuations throughout, a good indication of learning. The losses are very close; hence, the generalization performance of the model is quite good. On the other hand, the CNN model stabilizes a bit faster and with hardly any gap between training and validation loss. Where the training loss in the GRU model is showing a consistent decline and stabilizing, the validation loss also follows closely. hence reflecting that effective learning and generalization are taking place with no significant overfitting The figure 4 presents the Prediction Error Distributions: Error distributions are quite clear from the models. Most of the errors of the LSTM model centre around zero with a slight skew to the positive, meaning that the predictions are quite near the actual values with a few outliers. The CNN model errors are zero-centered as well, but the range is bigger, with more extreme outliers, which could indicate more variability and specific problems in fitting some of the patterns in the data. The GRU model errors are more spread compared to LSTM but less compared to CNN; slightly positively biased, to indicate a tendency to over-predict, though outliers are less frequent compared to CNN Discussion:: All models demonstrated the ability to capture the overall trends of the FTSE CSE index returns. However, the GRU model provided more accurate and stable predictions, likely due to its efficient handling of temporal dependencies in financial time-series data. conclusion: This study extensively examined the predictive capabilities of three widely used neural network mod els GRU, 1D-CNN, and LSTM on financial time series data. Through an exhaustive performance metric com parison and careful visual inspection, we thoroughly realized the strengths and limitations of each model to predict the FTSE CSE Morocco Index. TheGRUmodelshowedexcellentgeneralizationperformancewiththelowesterror rates whenapplied to the test set. Its ability to successfully model sequential dependencies without overfiting it too much makes it a dependable choice for operations in financial forecasting. Conversely, the 1D-CNN model, which was originally designed to handle spatial data, fared poorly when utilized in modeling sequential financial data. Though it did have a degree of accuracy, its performance indicates that it may not be the best tool to employ in modeling long-term dependencies of stock market trends. The LSTM model worked most effectively in learning complex long-term dependencies and had the lowest training RMSE among all models. However, its slightly larger test RMSE shows potential overfitting risk, which was prevented by applying early stopping to allow better generalization. This underlines the im portance of suitable model parameter tuning and the implementation of regularization techniques in financial forecasting based on deep learning. In addition to comparing model performance, this research highlights the importance of matching model choice with the nature of financial data and the target of the forecasting problem. The results indicate that although RNN-based models (GRU and LSTM) are better for financial time series prediction, proper attention should be devoted to training protocols and overfitting avoidance techniques. Future research can explore hybrid architectures that leverage the strengths of both CNNs and RNNs, add external macroeconomic factors, or use attention mechanisms to further enhance predictive accuracy. By extending the application of deep learning to financial forecasting, this research contributes to the growing liter ature of AI-driven stock market studies, offering valuable insights for both research investigation and practical implementation Conclusion:: GRU outperformed both LSTM and 1D-CNN in forecasting Moroccan stock market returns, making it a promising model for emerging-market return prediction and similar financial forecasting tasks.

Recent Advances in Computer Science and CommunicationsVol. 19
Université Sultan Moulay Slimane (MA), University of Hassan II Casablanca (MA)
Openalex Percentile: Top 17%
Stock Market Forecasting Methods
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.