# Genetic Algorithm-Optimized Long Short-Term Memory Network for Stock Market Prediction

^{*}

## Abstract

**:**

## 1. Introduction

## 2. Related Works

#### 2.1. Stock Market Prediction

#### 2.2. RNN for Time Series Prediction

## 3. Methodology

#### 3.1. Long Short-Term Memory (LSTM) Network

#### 3.2. Genetic Algorithm (GA)

#### 3.3. A Hybrid Approach to Optimization in LSTM Network with GA

## 4. Research Data and Experiment

#### 4.1. Data Description

#### 4.2. Feature Selection

## 5. Result and Analysis

## 6. Conclusions

## Author Contributions

## Funding

## Acknowledgments

## Conflicts of Interest

## References

- Cavalcante, R.C.; Brasileiro, R.C.; Souza, V.L.; Nobrega, J.P.; Oliveira, A.L. Computational intelligence and financial markets: A survey and future directions. Expert Syst. Appl.
**2016**, 55, 194–211. [Google Scholar] [CrossRef] - Abu-Mostafa, Y.S.; Atiya, A.F. Introduction to financial forecasting. Appl. Intell.
**1996**, 6, 205–213. [Google Scholar] [CrossRef] - Atsalakis, G.S.; Valavanis, K.P. Surveying stock market forecasting techniques–Part II: Soft computing methods. Expert Syst. Appl.
**2009**, 36, 5932–5941. [Google Scholar] [CrossRef] - Tay, F.E.; Cao, L. Application of support vector machines in financial time series forecasting. Omega
**2001**, 29, 309–317. [Google Scholar] [CrossRef] - Kim, H.J.; Shin, K.S. A hybrid approach based on neural networks and genetic algorithms for detecting temporal patterns in stock markets. Appl. Soft Comput.
**2007**, 7, 569–576. [Google Scholar] [CrossRef] - Lin, X.; Yang, Z.; Song, Y. Short-term stock price prediction based on echo state networks. Expert Syst. Appl.
**2009**, 36, 7313–7317. [Google Scholar] [CrossRef] - Adebiyi, A.A.; Adewumi, A.O.; Ayo, C.K. Comparison of ARIMA and artificial neural networks models for stock price prediction. J. Appl. Math.
**2014**, 2, 1–7. [Google Scholar] [CrossRef] - Yoshihara, A.; Fujikawa, K.; Seki, K.; Uehara, K. Predicting stock market trends by recurrent deep neural networks. In Proceedings of the Pacific Rim International Conference on Artificial Intelligence, Gold Coast, Australia, 1–5 December 2014; Springer: Berlin/Heidelberg, Germany, 2014; pp. 759–769. [Google Scholar]
- Saad, E.W.; Prokhorov, D.V.; Wunsch, D.C. Comparative study of stock trend prediction using time delay, recurrent and probabilistic neural networks. IEEE Trans. Neural Netw.
**1998**, 9, 1456–1470. [Google Scholar] [CrossRef] [PubMed][Green Version] - Shin, K.S.; Lee, Y.J. A genetic algorithm application in bankruptcy prediction modeling. Expert Syst. Appl.
**2002**, 23, 321–328. [Google Scholar] [CrossRef] - Castro, J.L.; Mantas, C.J.; Benítez, J.M. Interpretation of artificial neural networks by means of fuzzy rules. IEEE Trans. Neural Netw.
**2002**, 13, 101–116. [Google Scholar] [CrossRef] [PubMed] - Hsieh, T.J.; Hsiao, H.F.; Yeh, W.C. Forecasting stock markets using wavelet transforms and recurrent neural networks: An integrated system based on artificial bee colony algorithm. Appl. Soft Comput.
**2011**, 11, 2510–2525. [Google Scholar] [CrossRef] - Kim, J.H.; Shamsuddin, A.; Lim, K.P. Stock return predictability and the adaptive markets hypothesis: Evidence from century-long US data. J. Empir. Finan.
**2011**, 18, 868–879. [Google Scholar] [CrossRef] - Kumar, D.A.; Murugan, S. Performance analysis of Indian stock market index using neural network time series model. In Proceedings of the International Conference on Pattern Recognition, Informatics and Mobile Engineering, Salem, India, 21–22 February 2013; pp. 72–78. [Google Scholar]
- Armano, G.; Marchesi, M.; Murru, A. A hybrid genetic-neural architecture for stock indexes forecasting. Inf. Sci.
**2005**, 170, 3–33. [Google Scholar] [CrossRef] - Rao, J.N.K.; Box, G.E.P.; Jenkins, G.M. Time Series Analysis Forecasting and Control. Econometrica
**1972**, 40, 970. [Google Scholar] [CrossRef] - Engle, R.F. Autoregressive conditional heteroscedasticity with estimates of the variance of United Kingdom inflation. Econometrica
**1982**, 50, 987–1007. [Google Scholar] [CrossRef] - Karolyi, G.A. A multivariate GARCH model of international transmissions of stock returns and volatility: The case of the United States and Canada. J. Bus. Econ. Stat.
**1995**, 13, 11–25. [Google Scholar] [CrossRef] - Franses, P.H.; Van Dijk, D. Forecasting stock market volatility using (nonlinear) GARCH models. J. Forecast.
**1996**, 15, 229–235. [Google Scholar] [CrossRef] - Wei, L.Y.; Cheng, C.H. A hybrid recurrent neural networks model based on synthesis features to forecast the Taiwan stock market. Int. J. Innov. Comput. Inf. Control
**2012**, 8, 5559–5571. [Google Scholar] - Chong, E.; Han, C.; Park, F.C. Deep learning networks for stock market analysis and prediction: Methodology, data representations, and case studies. Expert Syst. Appl.
**2017**, 83, 187–205. [Google Scholar] [CrossRef][Green Version] - De Faria, E.L.; Albuquerque, M.P.; Gonzalez, J.L.; Cavalcante, J.T.P.; Albuquerque, M.P. Predicting the Brazilian stock market through neural networks and adaptive exponential smoothing methods. Expert Syst. Appl.
**2009**, 36, 12506–12509. [Google Scholar] [CrossRef] - Kim, K.J.; Han, I. Genetic algorithms approach to feature discretization in artificial neural networks for the prediction of stock price index. Expert Syst. Appl.
**2000**, 19, 125–132. [Google Scholar] [CrossRef] - Chen, Y.; Abraham, A.; Yang, J.; Yang, B. Hybrid methods for stock index modeling. In Proceedings of the International Conference on Fuzzy Systems and Knowledge Discovery, Changsha, China, 27–29 August 2005; Springer: Berlin/Heidelberg, Germany; pp. 1067–1070. [Google Scholar]
- Yu, H.; Chen, R.; Zhang, G. A SVM stock selection model within PCA. Procedia Comput. Sci.
**2014**, 31, 406–412. [Google Scholar] [CrossRef] - Chen, Y.; Hao, Y. A feature weighted support vector machine and K-nearest neighbor algorithm for stock market indices prediction. Expert Syst. Appl.
**2017**, 80, 340–355. [Google Scholar] [CrossRef] - Glorot, X.; Bordes, A.; Bengio, Y. Domain adaptation for large-scale sentiment classification: A deep learning approach. In Proceedings of the 28th International Conference on Machine Learning (ICML-11), Bellevue, WA, USA, 28 June–2 July 2011; pp. 513–520. [Google Scholar]
- Krizhevsky, A.; Sutskever, I.; Hinton, G.E. Imagenet classification with deep convolutional neural networks. In Proceedings of the Advances in Neural Information Processing Systems, Lake Tahoe, NV, USA, 3–8 December 2012; pp. 1097–1105. [Google Scholar]
- Guo, Y.; Liu, Y.; Oerlemans, A.; Lao, S.; Wu, S.; Lew, M.S. Deep learning for visual understanding: A review. Neurocomputing
**2016**, 187, 27–48. [Google Scholar] [CrossRef] - Lee, J.; Jang, D.; Park, S. Deep Learning-Based Corporate Performance Prediction Model Considering Technical Capability. Sustainability
**2017**, 9, 899. [Google Scholar] [CrossRef] - Sezer, O.B.; Ozbayoglu, M.; Dogdu, E. A Deep Neural-Network Based Stock Trading System Based on Evolutionary Optimized Technical Analysis Parameters. Procedia Comput. Sci.
**2017**, 114, 473–480. [Google Scholar] [CrossRef] - Ding, X.; Zhang, Y.; Liu, T.; Duan, J. Deep learning for event-driven stock prediction. In Proceedings of the 24th International Joint Conference on Artificial Intelligence, Buenos Aires, Argentina, 25–31 July 2015; pp. 2327–2333. [Google Scholar]
- Kara, Y.; Boyacioglu, M.A.; Baykan, Ö.K. Predicting direction of stock price index movement using artificial neural networks and support vector machines: The sample of the Istanbul Stock Exchange. Expert Syst. Appl.
**2011**, 38, 5311–5319. [Google Scholar] [CrossRef] - Enke, D.; Mehdiyev, N. Stock market prediction using a combination of stepwise regression analysis, differential evolution-based fuzzy clustering, and a fuzzy inference neural network. Intell. Autom. Soft Comput.
**2013**, 19, 636–648. [Google Scholar] [CrossRef] - Kristjanpoller, W.; Fadic, A.; Minutolo, M.C. Volatility forecast using hybrid neural network models. Expert Syst. Appl.
**2014**, 41, 2437–2442. [Google Scholar] [CrossRef] - Nayak, R.K.; Mishra, D.; Rath, A.K. A Naïve SVM-KNN based stock market trend reversal analysis for Indian benchmark indices. Appl. Soft Comput.
**2015**, 35, 670–680. [Google Scholar] [CrossRef] - Lei, L. Wavelet neural network prediction method of stock price trend based on rough set attribute reduction. Appl. Soft Comput.
**2018**, 62, 923–932. [Google Scholar] [CrossRef] - Brocki, Ł.; Marasek, K. Deep belief neural networks and bidirectional long-short term memory hybrid for speech recognition. Arch. Acoust.
**2015**, 40, 191–195. [Google Scholar] [CrossRef] - Donahue, J.; Anne Hendricks, L.; Guadarrama, S.; Rohrbach, M.; Venugopalan, S.; Saenko, K.; Darrell, T. Long-term recurrent convolutional networks for visual recognition and description. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Boston, MA, USA, 7–12 June 2015; pp. 2625–2634. [Google Scholar]
- Dixon, M. Sequence classification of the limit order book using recurrent neural networks. J. Comput. Sci.
**2017**, 24, 277–286. [Google Scholar] [CrossRef] - Fischer, T.; Krauss, C. Deep learning with long short-term memory networks for financial market predictions. Eur. J. Oper. Res.
**2018**, 270, 654–669. [Google Scholar] [CrossRef][Green Version] - Cai, X.; Zhang, N.; Venayagamoorthy, G.K.; Wunsch, D.C. Time series prediction with recurrent neural networks trained by a hybrid PSO–EA algorithm. Neurocomputing
**2007**, 70, 2342–2353. [Google Scholar] [CrossRef] - Rather, A.M.; Agarwal, A.; Sastry, V.N. Recurrent neural network and a hybrid model for prediction of stock returns. Expert Syst. Appl.
**2015**, 42, 3234–3241. [Google Scholar] [CrossRef] - Zhang, G.; Xu, L.; Xue, Y. Model and forecast stock market behavior integrating investor sentiment analysis and transaction data. Cluster Comput.
**2017**, 20, 789–803. [Google Scholar] [CrossRef] - Goodfellow, I.; Bengio, Y.; Courville, A.; Bengio, Y. Deep Learning; MIT Press: Cambridge, MA, USA, 2016; pp. 373–418. [Google Scholar]
- Schmidhuber, J.; Hochreiter, S. Long short-term memory. Neural Comput.
**1997**, 9, 1735–1780. [Google Scholar] [CrossRef] - Gers, F.A.; Schmidhuber, J.; Cummins, F. Learning to forget: Continual prediction with LSTM. Neural Comput.
**1999**, 12, 2451–2471. [Google Scholar] [CrossRef] - Kim, Y.; Roh, J.H.; Kim, H. Early Forecasting of Rice Blast Disease Using Long Short-Term Memory Recurrent Neural Networks. Sustainability
**2017**, 10, 34. [Google Scholar] [CrossRef] - Holland, J.H. Adaptation in Natural and Artificial Systems; University of Michigan Press: Ann Arbor, MI, USA, 1975; p. 183. [Google Scholar]
- Pal, S.K.; Wang, P.P. Genetic Algorithms for Pattern Recognition; CRC Press: Boca Raton, FL, USA, 1996; p. 336. [Google Scholar]
- Muhammad, A.; King, G.A. Foreign exchange market forecasting using evolutionary fuzzy networks. In Proceedings of the IEEE/IAFE 1997 Computational Intelligence for Financial Engineering (CIFEr), New York, NY, USA, 24–25 March 1997; pp. 213–219. [Google Scholar]
- Kai, F.; Wenhua, X. Training neural network with genetic algorithms for forecasting the stock price index. In Proceedings of the 1997 IEEE International Conference on Intelligent Processing Systems, Beijing, China, 28–31 October 1997; pp. 401–403. [Google Scholar]
- Kim, M.J.; Min, S.H.; Han, I. An evolutionary approach to the combination of multiple classifiers to predict a stock price index. Expert Syst. Appl.
**2006**, 31, 241–247. [Google Scholar] [CrossRef] - Kingma, D.P.; Ba, J. Adam: A method for stochastic optimization. arXiv
**2014**, arXiv:1412.6980. [Google Scholar] - Figshare. Available online: https://figshare.com/articles/Data_csv/7120769 (accessed on 22 September 2018).
- Kim, K. Financial time series forecasting using support vector machines. Neurocomputing
**2003**, 55, 307–319. [Google Scholar] [CrossRef] - Vanstone, B.; Finnie, G. An empirical methodology for developing stock-market trading systems using artificial neural networks. Expert Syst. Appl.
**2009**, 36, 6668–6680. [Google Scholar] [CrossRef] - Chen, K.; Zhou, Y.; Dai, F. A LSTM-based method for stock returns prediction: A case study of China stock market. In Proceedings of the 2015 IEEE International Conference on Big Data, Santa Clara, CA, USA, 29 October–1 November 2015; pp. 2823–2824. [Google Scholar]
- Hiransha, M.; Gopalakrishnan, E.A.; Menon, V.K.; Soman, K.P. NSE stock market prediction using deep-learning models. Procedia Comput. Sci.
**2018**, 132, 1351–1362. [Google Scholar] [CrossRef]

Authors (Year) | Data Type (Number of Input Variable × Lagged Time) | Output | Method | Performance Measure |
---|---|---|---|---|

Kara et al. (2011) [33] | Turkey ISE National 100 Index (10 × 1) | Direction of stock market (up/down) | ANN, SVM | Directional accuracy |

Enke and Mehdiyev (2013) [34] | US S&P 500 index (20 × 1) | Stock price | Fuzzy clustering + fuzzy NN | RMSE |

Kristjanpoller et al. (2014) [35] | 3 Latin-American stock exchange indices (4 × 2) | Volatility | ANN + GARCH | RMSE, MSE, MAE, MAPE |

Yu et al. (2014) [25] | China SSE (7 × 1) | Return rank (divided by 25%) | PCA + SVM | Accuracy (classified by return rank) |

Nayak et al. (2015) [36] | India BSE and CNX (11× 1) | Stock index | KNN + SVM | MSE, RMSE, MAPE |

Chen and Hao (2017) [26] | China SSE and SZSE (14 × [1~30]) | Direction of return (profit/loss) | IG+SVM+KNN | Directional accuracy |

Chong et al. (2017) [21] | Korea KOSPI 38 stock returns (38 × 10) | Stock return | DNN | NMSE, RMSE, MAE |

Lei (2018) [37] | China SSE Composite Index, CSI 300 Index, Japan Nikkei 225 Index, and US Dow Jones Index (15 × 1) | Stock price | Rough set + Wavelet Neural Network | RMSE, MAD, MAPE, CP, CD |

Method | Indicator Formula |
---|---|

Simple 10-day moving average | $\frac{{C}_{t}+{C}_{t-1}+\dots +{C}_{t-10}}{10}$ |

Weighted 10-day moving average | $\frac{\left(\left(n\right)\times {C}_{t}+\left(n-1\right)\times {C}_{t-1}+\dots +{C}_{10}\right)}{\left(n+\left(n-1\right)+\dots +1\right)}$ |

Relative strength index (RSI) | $100-\frac{100}{1+({{\displaystyle \sum}}_{t=0}^{n-1}U{p}_{t-I}/n)/({{\displaystyle \sum}}_{t=0}^{n-1}D{w}_{t-I}/n)}$ |

Stochastic K% | $\frac{{C}_{t}-L{L}_{t-n}}{H{H}_{t-n}-L{L}_{t-n}}\times 100$ |

Stochastic D% | $\frac{{{\displaystyle \sum}}_{t=0}^{n-1}{K}_{t-i}\%}{n}$ |

Name of Input | Max | Min | Mean | Standard Deviation |
---|---|---|---|---|

High price | 2231.47 | 472.31 | 1439.90 | 541.51 |

Low price | 2202.92 | 463.54 | 1420.12 | 539.65 |

Opening price | 2225.95 | 466.57 | 1431.28 | 541.15 |

Closing price | 2228.96 | 468.76 | 1430.54 | 540.70 |

Trading volume | 2,379,293,952 | 136,328,992 | 420,925,245 | 192,841,151 |

Simple 10-day moving average | 2208.53 | 474.37 | 1430.06 | 540.35 |

Weighted 10-day moving average | 2210.60 | 473.76 | 1430.22 | 540.42 |

Relative strength index (RSI) | 99.06 | 3.29 | 53.38 | 17.21 |

Stochastic K% | 100.00 | 0.00 | 56.17 | 32.29 |

Stochastic D% | 100.00 | 0.00 | 56.18 | 26.73 |

Method | MSE | MAE | MAPE |
---|---|---|---|

Benchmark | 209.45 | 11.71 | 1.10 |

GA–LSTM | 181.99 | 10.21 | 0.91 |

Method | Mean | Std. Dev. | t | $\mathit{\rho}$ |
---|---|---|---|---|

Benchmark | 1987.15 | 61.22 | −2.43 | 0.015 ** |

GA–LSTM | 1994.01 | 55.07 |

Stock ID | Listed Name |
---|---|

1 | Samsung Electronics Co., Ltd. |

2 | SK Hynix Inc. |

3 | Hyundai Motor Co. |

4 | POSCO |

5 | SK Telecom Co., Ltd. |

6 | Hyundai Mobis Co., Ltd. |

Stock ID | MSE | t | |
---|---|---|---|

Benchmark | GA–LSTM | ||

1 | 323,320,293.39 | 60,935,029.38 | 12.51 *** |

2 | 555,866.78 | 344,163.32 | 16.76 *** |

3 | 7,645,782.15 | 5,346,711.91 | −31.55 *** |

4 | 8,999,908.92 | 16,063,226.96 | −17.47 *** |

5 | 15,378,065.29 | 13,256,115.03 | 7.82 *** |

6 | 22,506,781.62 | 22,319,257.27 | −19.57 *** |

© 2018 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Chung, H.; Shin, K.-s.
Genetic Algorithm-Optimized Long Short-Term Memory Network for Stock Market Prediction. *Sustainability* **2018**, *10*, 3765.
https://doi.org/10.3390/su10103765

**AMA Style**

Chung H, Shin K-s.
Genetic Algorithm-Optimized Long Short-Term Memory Network for Stock Market Prediction. *Sustainability*. 2018; 10(10):3765.
https://doi.org/10.3390/su10103765

**Chicago/Turabian Style**

Chung, Hyejung, and Kyung-shik Shin.
2018. "Genetic Algorithm-Optimized Long Short-Term Memory Network for Stock Market Prediction" *Sustainability* 10, no. 10: 3765.
https://doi.org/10.3390/su10103765