key: cord-0066727-f7d05and authors: Sharma, Dinesh K.; Hota, H. S.; Brown, Kate; Handa, Richa title: Integration of genetic algorithm with artificial neural network for stock market forecasting date: 2021-08-17 journal: Int J Syst Assur Eng Manag DOI: 10.1007/s13198-021-01209-5 sha: af21ea9ccf03413cc5de918c839727437dfaa911 doc_id: 66727 cord_uid: f7d05and Traditional statistical as well as artificial intelligence techniques are widely used for stock market forecasting. Due to the nonlinearity in stock data, a model developed using the traditional or a single intelligent technique may not accurately forecast results. Therefore, there is a need to develop a hybridization of intelligent techniques for an effective predictive model. In this study, we propose an intelligent forecasting method based on a hybrid of an Artificial Neural Network (ANN) and a Genetic Algorithm (GA) and uses two US stock market indices, DOW30 and NASDAQ100, for forecasting. The data were partitioned into training, testing, and validation datasets. The model validation was done on the stock data of the COVID-19 period. The experimental findings obtained using the DOW30 and NASDAQ100 reveal that the accuracy of the GA and ANN hybrid model for the DOW30 and NASDAQ100 is greater than that of the single ANN (BPANN) technique, both in the short and long term. Academics and financial experts are interested in financial forecasting to make stock market pricing predictions. The random behavior of stock markets makes forecasting difficult and new approaches to forecasting models continue to be sought. Traditional statistical techniques such as autoregressive integrated moving average (ARIMA) (Box & Jenkins, 1976) , autoregressive conditional heteroscedasticity (ARCH) (Engle, 1982) , and generalized autoregressive conditional heteroscedasticity (GARCH) (Bollerslev, 1986) were developed early in stock market forecasting. However, these models are generally not effective tools for forecasting due to the non-linearity of data and the occurrence of shocks (Sharma et al. 2016) . Several authors have worked with various artificial intelligence (AI) techniques for financial time series forecasting in the literature. Others have studied stock market data based on various artificial neural network (ANN) techniques. From the study of this literature, ANNs outperform the traditional techniques with regard to forecasting non-linear time-series data (Aiken & Bsat, 1999; Yao, 1999; Sharma & Rababaah, 2014) . Lee (2004) proposed an intelligent model using a hybrid radial basis functional network based on stock market predictions. Several academicians have applied ANN techniques for stock price predictions (Grigoryan, 2015; Guresen et al. 2011; Kazem et al. 2013; Laboissiere et al. 2015; Naeini, et al. 2010; Siew & Nordin, 2012) . Lahmiri (2014) proposed a predictive model using the wavelet transform for signal denoising and backpropagation for time series forecasting. Many authors found deep learning is helpful for the prediction of non-linear time series data. Additionally, numerous authors (Ni et al. 2019; Thakkar & Chaudhari, 2020; Yadav et al. 2020; Lin et al. 2021 ) have proposed a new forecasting method for forecasting foreign exchange and stock market data using deep learning architectures, i.e., recurrent neural network, long short-term memory, and convolutional neural network. Thakkar & Chaudhari (2021) test nine deep neural network (DNN) models for stock market predictions. Various authors (Huang & Wu, 2008; Jang, 1993; Sharma & Rababaah, 2014; Rababaah & Sharma, 2015; Singh et al. 2020 ) have also suggested that sometimes a single technique is not sufficient and does not provide accurate results. Sharma and Rababaah (2014) developed a model that forecasted US stock market trends by combining signal processing and ANN. Rababaah & Sharma (2015) enhanced the model even further by combining two distinct signal-processing techniques with ANN. Weng et al. (2018) proposed an intelligent system composed of two modules: a knowledge base and AI, and they extracted new features to improve the model's performance. Nayak & Misra (2019) combined a chemical reaction optimization module to optimize the weights combined with a neurofuzzy network (CNFN) to predict stock index returns. After reviewing the literature, we found that ANNs are good for learning input-output patterns. However, they may face local minima and network paralysis problems due to rough weights assigned by learning algorithms like backpropagation. On the other side, genetic algorithms are good for optimization but difficult to use to find suitable fitness functions. To overcome these drawbacks, we propose a model combining the strengths of two techniques to develop a hybrid GANN model to get more accurate forecasting results. We use GAs to optimize the weights of ANNs so that the results produced by ANNs will be more accurate and the prediction errors will be minimized. This study has three goals. The first is to design and build a GAAN to forecast stock data. The system is divided into the GA and the ANN modules. The weights of the ANN are optimized using GA, and resulting ANN is used to make predictions. The second is to validate the model with actual stock market data to check the performance of the model. Validation is performed on the model using stock data during COVID-19 from March 1, 2020, to October 8, 2020. The third is to use GANN to predict the Dow30 and NASDAQ100 indices closing prices for the next day. The results and patterns of actual and predicted values for the proposed model are compared to the same data evaluated by a BPANN. The remainder of the paper is laid out as follows: Sect. 2 provides a brief review of previous studies. The proposed framework methodology is discussed in Sect. 3. The data and experimental work to be used for stock market forecasting are described in Sect. 4. The findings and discussion are presented in Sect. 5. Finally, Sect. 6 provides closing remarks. In the literature review, many authors (Branke, 1995; Yao, 1999; Mandziuk & Jaruszewicz, 2011; Sermpinis et al. 2015; Alhnaity & Abbod, 2020) have worked with ANNs and GAs for stock market predictions with weight optimization. Pan et al. (2005) demonstrated the efficiency of the proposed method using a mutation-only GA. Mandziuk & Jaruszewicz (2011) proposed a neuro-genetic system for stock market predictions. Many authors (Cai et al. 2013; Kuo et al. 2001 ) have done financial data forecasting using ANNs, Fuzzy Logic, and GAs. Majhi et al. (2014) and Sermpinis et al. (2015) have also proposed models for forecasting various time series data using several machine learning techniques and GAs and found that the GAs outperformed the machine learning techniques. Alhnaity & Abbod (2020) proposed a novel hybrid intelligent model for time series prediction using ANNs, support vector regression (SVR), feature extraction, with GAs to optimize weights. Prado et al. (2020) proposed a novel ensemble methodology for forecasting aggregated long-term energy demand that included an ARIMA, ANN, fuzzy inference system model, adaptive neuro-fuzzy inference system, SVR, extreme ML, and GA. Huang et al. (2021) presented a GA-based model for financial data forecasting using VMD and LSTM. Recently, Peng et al. (2021) studied feature selection in the context of DNN models that use technical analysis indicators to predict stock price direction. A literature survey found that a few papers were focused on the impact of expected or unexpected events that affect the trends of time series data using intelligent techniques. Goodell & Vähämaa (2013) and Sharma et al. (2017) focus on the US presidential election in time series data. Mo et al. (2016) did forecasts for the financial cross-correlation relationship using an Exponent Back-Propagation ANN, while Hota et al. (2018) analyzed the impact of demonetization in the Indian stock market and foreign exchange rates. Kumar & Kumara (2020) utilized pre and post COVID-19 effects in market capitalization. Ballı (2020) also proposed data analysis of the pandemic using machine learning techniques like learning regression, support vector machine (SVM), multilayer perceptron, and random forecast. In this section, we present a framework of the proposed methodology, which includes a brief overview of ANN and GA concepts, and comprehensive descriptions of Genetically tuned Artificial Neural Network (GANN) system development. An artificial neural network (Zurada et al. 1994; Rajashekhran & Pai, 1996) is inspired by the human nervous system, such as the brain. Due to fluctuating behavior of financial time series data ANN is used to develop forecasting models that produce results more accurately than statistical models. ANN has a three-layer architecture: Input layer, Hidden layer, and Output layer, which is sufficient to solve a complex nonlinear problem like time series forecasting. An ANN architecture with three layers is shown in Fig. 1 . ANN consists of two Phases: Feedforward Neural Network and Feedback Neural Network. An ANN with a single hidden layer feedforward with one output node is commonly used to develop forecasting applications. A genetic algorithm (Zurada et al. 1994 ) is a general-purpose, population-based search algorithm that begins with the population of ''genes'', which represent the possible solutions to the considered problem. Strings of values representing a solution to the problem are joined together and referred to as a ''Chromosome.'' A fitness value is assigned to each string called ''fitness value,'' which identifies how good a solution it is. The basic cycle of the genetic algorithm is shown in Fig. 2 . First, we initialize the population size. Second, the fitness values are calculated using equation number 2. Finally, we use these fitness values to create new generations using three genetic operators: selection, crossover, and mutation. Local minima and network paralysis are some drawbacks of ANN. The network cannot adjust the weights towards local minima, and the network becomes paralyzed, which affects the system's accuracy. On the other hand, sometimes we cannot get optimal solutions from the genetic algorithm alone. To overcome these problems, the hybridization of ANN with GA is required to develop a new forecasting model. Figure 3 depicts the process flow diagram and overall scheme of GANN for stock data forecasting. Each of the components of this figure is described as below: We have collected two stock datasets: DOW30 and NAS-DAQ100, from www.yahoofinance.com as summarized in Table 1 . After data collection, normalization was used by scaling the data in the range of [0 1] to simplify the learning process (Nawi et al., 2013; Sola & Sevilla, 1997) and to improve the accuracy of predictive model as shown in Eq. 1: where x is observed value of the time series data, X max is highest value of observation of a particular feature while X new is the calculated normalized observation. The sample size of partitioned data must be optimum because the result of ANN based system depends on the training and testing step and the accuracy of the model may vary based on this data partition. To choose the best sample size for a particular model and particular data, the index data is divided into two different partitions (90%-10% and 80%-20%). In this proposed work we have downloaded DOW30 and NASDAQ100 data sets from March 01, 2017 to Oct 08, 2020. The data is divided into three parts: training, testing and validation. Each partition of data is tuned with GANN to get the forecasting result. The validation data set consist of data from March 01, 2020 to October 08, 2020, i.e. the period of COVID-19 (155 samples). During the pandemic, stock data became volatile and uncertainty about many of the foundations of the economy increased. We tested the value of the model by seeing how accurately it performed while working with the COVID-19 dataset. The initial population is required to work with the GA. Potential solutions to the problem called genes are joined together to form a string of values referred to as chromosomes. The fitness function is used to calculate the fitness value by assigning merits to each individual in population as shown in Eq. 2. where E is the root mean square of the error as shown below in Eq. 3. The selection of the best parents, which mate and recombine to create offspring for the next generation is a crucial task to do in GA. Chromosomes selected from the population to be parents will produce offspring. In this study, selection of superior parents was done with a Roulette wheel selection operator. In Roulette wheel selection, the circular wheel is divided by the available chromosomes and a fixed point on the wheel is set. Whichever area of the wheel comes in front of this fixed point is chosen as a parent, and the same process is repeated for the other parent. In crossover, two parents are selected to produce one or more offspring along with genetic characteristics of the parents. In this proposed work, multi point crossover is used, where alternate segments are swapped to get new offspring as shown in Fig. 4 . This is an optional operator in which a small change in chromosomes has been allowed to get something new to the individual with very low mutation probability. We have applied a two-point mutation operator in the evolution process to optimize the weights of the ANN. In this method, the worst fit chromosome is replaced with best fit chromosome to get better set for next generation. Weights must extracted from each of the chromosome to calculate the fitness value. Let x 1 , x 2, …x d , …., x L represent a chromosome and x kd?1 , x kd?2 …, x (k ? 1)d represent the k th gene (k [ = 0) in the chromosome. Then the weight extraction formula is given by following equation: 3.3.9.1 Evaluation criteria Various error metrics have been used to assess the efficiency of models. We assume Mean Absolute Percentage Error (MAPE), Mean Square Error (MSE), and Root Mean Square Error (RMSE) in this proposed study. The following are the formulas for these measures: Mean Absolute Percentage Error (MAPE): Mean Square Error (MSE): W k¼ þ X kdþ2 10 dÀ2 þ X kdþ3 10 dÀ3 þ À À À þ X ðkþ1Þd 10 dÀ2 if 5 X kdþ1 9 À X kdþ2 10 dÀ2 þ X kdþ3 10 dÀ3 þ À À À þ X ðkþ1Þd 10 dÀ2 if 0 X kdþ1 5 Root Mean Square Error (RMSE): where AV i is actual value for for ith sample and PV i is predicted value for ith sample and N is the total number of samples. In this section, we present the data description of two US stock indices and the experimental work for stock market forecasting with the GANN compared to a backpropagating ANN (BPANN). To develop the predictive model we have used two stock indices i.e. DOW30 and NASDAQ100, collected from www.yahoofinance.com. We have collected data from March 01, 2017 to October 08, 2020 that covers three years of data with these features: Open, High, Low and Close; and Next Day Close is used as the output data. The data we have used in this proposed work depicted in Table 1 . Trends of historical data of the DOW30 and NAS-DAQ100 are shown in Fig. 5 (a) and (b) which show that the stock data we have collected is non-linear in nature. Based on the literature, statistical techniques may not be able to develop effective predictive models for data with fluctuating behavior. In this work, we have proposed a Genetically tuned ANN model to develop a forecasting model for this data. The experimental work is done with the model developed and discussed above using MATLAB (MathWorks, 2018). The experimental work and the results are explained in the following five subsections; experiment with DOW30 data set, experiment with NASDAQ100 data set, error measures, model selection, and N-Days ahead forecasting. The study investigated the GANN's performance compared to BPANN using all three partitions of both data sets. The system training took place using each partition with the GA to optimize the weights and independently by the BPANN. After training, the model was tested for prediction, model validation was done to check the performance of the model, and predictions were made for the next day's closing prices. Both the models were trained and then tested with both partitions one by one. Comparative graphs showing the actual and predicted closing price by GANN at the testing stage for both partitions are shown in Fig. 6 (a) and (b) . A similar experiment was also carried out for the NAS-DAQ100 data set for both partitions, and the actual value and predicted value for these partitions are shown with the graphs in Fig. 7 (a) and (b) . It can be clearly observed from these graphs that the predicted value is very near to the (a) (b) Fig. 5 Graphical Trend of a DOW30 and b NASDAQ100 Data actual value. Hence, we can say that GANN is performing well for the index data set. Three different error measures: MAPE, MSE, and RMSE, are calculated using Eqs. 5, 6, and 7 respectively after simulations of BPANN and GANN with both the partitions of the DOW30 data set, and the results are tabulated in Tables 2, 3, and 4 for the training, testing and validation datasets for MAPE, MSE and RMSE respectively. We can observe from these tables that we get consistent MAPE values in the context of partition size and the model we have used. Training error is less than testing error for all the partitions, while validation error is higher. In the case of the NASDAQ100 data set, the same pattern can be observed in Tables 5, 6, and 7 A comparative result based on testing data set for all the three error measures: MAPE, MSE, and RMSE for both the indices is depicted in Fig. 8 (a)-(f), which clearly show the higher performance of GANN for stock index forecasting. Although the range of error in case of GANN is very close to that of BPANN, it is lower for both the partitions and for both the indices, which confirms that hybrid techniques can produce better results by avoiding the weakness of individual techniques. The best model we have selected based on the error measures shown in Eqs. 5, 6, and 7 is GANN. Partition 2 (80-20) of DOW30 resulted in the most precise prediction for the next day's close prices; hence, a model trained with partition 2 was selected to make N days ahead predictions. A similar experiment took place for the NASDAQ100 data sets, and partition 2(80-20) yielded the best prediction for the next day's close price compared to other partitions. Therefore, this partition was selected to make N days ahead predictions. ANN is trained with partition 2 of DOW30 data set and NASDAQ100 data set with the help of GA, and finally, weights are optimized as shown in Tables 8 and 9 respectively for DOW30 and NASDAQ100 data sets. After performing various iterations, ANN has converged towards the global optimum due to the chromosomes' final set for the DOW30 and NASDAQ100 data sets. We can observe from these tables that all the chromosomes in the final population have the same genetic material (genes), which shows the GANN's ability and that ANN can optimize the weights through GA. Weights obtained for different input to hidden layer and from hidden to the output layer along with the bias weights are tabulated in Table 8 in the case of partition 2 for the DOW30 data set and in Table 9 for the NASDAQ100 data set. These weights are extracted from the final population's chromosomes using Eq. 4 for the DOW30 and NASDAQ100 data sets. To demonstrate and validate the GANN model, a mathematical calculation was performed at the testing stage, which explains the process of N-days ahead forecasting by performed better than the BPANN even when tested on the pandemic period data. In this study, we proposed an intelligent hybrid framework for stock forecasting. Back Propagation Neural Network (BPANN) and a combination of ANN and GA were used as intelligent techniques to construct forecasting models using the DOW30 and NASDAQ100 datasets. To test the model's efficacy, the data sets were partitioned into three separate partitions: training, testing, and validation. The model was validated using market data during COVID-19, which ran from March 1, 2020 to October 8, 2020, to see how accurately the model performs in the face of any unexpected event, when the stock market was highly volatile. It was discovered that GANN offered more reliable predictive results than the BPANN model for almost all of the data partitions. The performance of both models was tested using a variety of error tests, including MAPE, MSE, and RMSE. When using the principle of global optimization, GANN performed well, but BPANN failed to optimize the weights This demonstrates that GANN can capture the fluctuating behavior of stock data more intelligently than the BPANN alone. Even though data was collected before and during COVID-19, the accuracy of the GANN model for 5-Days ahead forecasting was 97.75 percent for the DOW30 dataset and 97.16 percent for the NASDAQ100 dataset. Moving from short to long term forecasting reduces performance for both models, but the GANN consistently produces smaller errors. The future scope of our proposed work can be carried out using some new hybrid techniques that incorporate wavelet transform, feature extraction, feature selection, Adaptive Neuro Fuzzy Inference, or wavelet techniques with Genetic Algorithm. To improve the accuracy of the results, various tuning parameters such as learning rate, momentum, and so on can be combined with GANN. Funding We have not received funding for this research. Human and animal rights The authors declared that this article contains no studies involving human subjects or animals. Forecasting market trends with neural networks A new hybrid financial time series prediction model Data analysis of Covid-19 pandemic and short-term cumulative case forecasting using machine learning time series models Generalized autoregressive conditional heteroskedasticity Time series analysis: forecasting and control. Holden-Day, San Francisco Branke J (1995) Evolutionary algorithms for neural network design and training A novel stock forecasting model based on fuzzy time series and genetic algorithm Autoregressive conditional heteroskedasticity with estimates of the variance of United Kingdom inflation US presidential elections and implied volatility: the role of political uncertainty Stock market prediction using artificial neural networks case study of TAL1T, nasdaq OMX baltic stock Using artificial neural network models in stock market index prediction Neural network techniques to develop a robust financial time series forecasting system Integrating GA-based time-scale feature extractions with SVMs for stock index forecasting A new financial data forecasting model using genetic algorithm and long short-term memory network ANFIS: adaptive-network-based fuzzy inference system Support vector regression with chaos-based firefly algorithm for stock market price forecasting Market capitalization: pre and post COVID-19 analysis An intelligent stock trading decision support system through integration of genetic algorithm based fuzzy neural network and artificial neural network Maximum and minimum stock price forecasting of Brazilian power distribution companies based on artificial neural networks Wavelet low-and high-frequency components as features for predicting stock prices with backpropagation neural networks IJADE stock advisor: an intelligent agent based stock prediction system using hybrid RBF recurrent network Forecasting stock index price using the CEEMDAN-LSTM model On the development and performance evaluation of a multiobjective GA-based RBF adaptive model for the prediction of stock indices Neuro-genetic system for stock index prediction Exponent back propagation neural network forecasting for financial cross-correlation relationship International conference on computer information systems and industrial management applications The effect of data preprocessing on optimized training of artificial neural networks A chemical-reaction-optimization-based neuro-fuzzy hybrid network for stock closing price prediction Forecasting of forex time series data based on deep learning Application of mutation only genetic algorithm for the extraction of investment strategy in financial time series Feature selection and deep neural networks for stock price direction forecasting using technical analysis indicators Forecasting based on an ensemble autoregressive moving average-adaptive neurofuzzy inference system-neural network-genetic algorithm framework Integration of two different signal processing techniques with artificial neural network for stock market forecasting Genetic algorithm based weight determination for backpropogation network Modeling, forecasting and trading the EUR exchange rates with hybrid rolling genetic algorithms-support vector regression forecast combinations Stock market predictive model based on integration of signal processing and artificial neural network A hybrid neuro-fuzzy model for foreign exchange rate prediction Analysis of US stock market post presidential election performance using ANN techniques Regression techniques for the prediction of stock price trend Development of new hybrid model of discrete wavelet decomposition and autoregressive integrated moving average (ARIMA) models in application to one month forecast the casualties cases of COVID-19 Importance of input data normalization for the application of neural networks to complex industrial problems CREST: cross-reference to exchange-based stock trend prediction using long short-term memory A comprehensive survey on deep neural networks for stock market: the need, challenges and future directions Predicting short-term stock prices using ensemble methods and online data sources Optimizing LSTM for time series prediction in Indian stock market Evolving artificial neural networks Publisher's Note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations