LSTM Stock Prediction Model Based on Improved Particle Swarm Optimization
-
摘要: 针对LSTM网络中存在的重要参数通常由经验决定、主观性强、或受计算成本影响无法确定最优值,导致模型的拟合能力降低等问题,提出使用改进的粒子群算法优化LSTM网络中的关键参数,减少人为因素影响,优化预测过程,从而构建预测精度更高的股票价格预测模型。该模型通过构建动态多群粒子群优化器来提高粒子群算法的寻优性能,避免出现局部最优。同时,针对股票市场数据维度高、噪声大及数据冗余导致模型训练成本增大、预测性能降低的问题,基于多种特征选择算法构建特征选择模型完成指标特征的过滤筛选,构建完善的预测指标体系。实验结果证明,所提出的股票价格预测模型的准确率得到了明显的提高,且具有普遍适用性。
-
关键词:
- LSTM网络 /
- 粒子群算法(PSO) /
- 股票价格预测 /
- 动态调整 /
- 特征选择
Abstract: Since LSTM network can effectively deal with time series, it has been widely used to analyze stock prices and future trends. However, the important parameters in the LSTM network are usually determined by experience, which is highly subjective, or the optimal value cannot be determined due to the influence of calculation cost, resulting in the reduction of the fitting ability of the model. Aiming at the above problems, this paper proposes an improved particle swarm algorithm to optimize the key parameters of LSTM network. By reducing the influence of human factors and optimizing the forecasting process, a stock price forecasting model with higher forecasting accuracy is constructed. By utilizing a dynamic multi-swarm particle swarm optimizer to avoid local optimization, the obtained model can improve the optimization performance of PSO algorithm. At the same time, aiming at the problem of high dimension, large noise and data redundancy in the stock market data, which lead to the increase of model training cost and the decrease of prediction performance, a feature selection model is further constructed based on a variety of feature selection algorithms to complete the filtering and screening of index features and build a perfect prediction index system. Finally, it is shown via experimental results that the proposed model can attain higher prediction accuracy and universal applicability in stock price prediction.-
Key words:
- LSTM network /
- PSO /
- stock price prediction /
- dynamic adjustment /
- feature selection
-
表 1 股票价格预测指标
Table 1. Stock price prediction index
Category Predictor Trading indicators preclosePrice, openPrice, highestPrice, lowestPrice, closePrice, Rf, Applies, turnoverVol, chgPct, Amplitude Market
indicatorCSI 300 Technical indicator Volume type: AD, OBV
Overbought and oversold: ATR, ROC, RSI
Trending: MA, MACD, TRIX, ADX, Aroon表 2 指标重要度(上证指数000001.SH)
Table 2. Importance of indexs(Shanghai component index)
Indicator Corr Importance Lasso Importance MIC Importance RF Importance RFE Importance preclosePrice 0.55 M 0 W 0.95 S 0.78 S 0.68 S openPrice 0.39 M 0 W 0.98 S 0.82 S 0.75 S highestPrice 0.68 S 0.46 M 0.97 S 0.54 M 0.71 S lowestPrice 0.72 S 0.37 M 1 S 0.84 S 0.90 S closePrice 1.00 S 1 S 1 S 0.97 S 0.95 S Rf 0.02 W 0 W 0.35 M 0.33 M 0.17 W Applies 0 W 0 W 0.05 W 0.39 M 0.32 W turnoverVol 0.05 W 0 W 0.36 M 0.82 S 0.54 M chgPct 0 W 0 W 0.44 M 0.93 S 1 S Amplitude 0.34 M 0.04 W 0.55 M 0.39 M 0.32 W AD6 0 W 0 W 0.94 S 0.35 M 0.37 M AD20 0.12 W 0 W 0.96 S 1 S 0.44 M OBV6 0 W 0 W 0.82 S 0.25 W 0.12 W ATR6 0.05 W 0 W 0.86 S 0.38 M 0.90 S ATR14 0.03 W 0 W 0.46 M 0.36 M 0.92 S ROC6 0 W 0 W 0.43 M 0.35 M 0.37 M ROC20 0.15 W 0.01 W 0.36 M 0.73 S 0.47 M RSI 0 W 0 W 0.14 W 0.55 M 0.37 M MA120 0.08 W 0 W 0.76 S 0.69 S 0.67 S MACD 0 W 0 W 0.35 M 0.70 S 0.72 S TRIX5 0.19 W 0.02 W 0.58 M 0.66 M 0.85 S ADX 0.14 W 0 W 0.75 S 0.09 W 0.50 M Aroon 0.10 W 0 W 0.41 M 0.19 W 0.38 M 表 3 指标重要度(深证成指399001.SZ)
Table 3. Importance of indexs (Shenzhen component index)
Indicator Corr Importance Lasso Importance MIC Importance RF Importance RFE Importance preclosePrice 0.62 M 0.18 W 0.90 S 0.77 S 0.65 M openPrice 0.22 W 0.01 W 0.93 S 0.69 S 0.72 S highestPrice 0.63 M 0.47 S 0.99 S 0.51 M 0.79 S lowestPrice 0.88 S 0.39 S 0.99 S 0.81 S 0.82 S closePrice 1.00 S 1 S 1 S 0.99 S 0.91 S Rf 0.01 W 0 W 0.37 M 0.44 M 0.39 M Applies 0.02 W 0 W 0.05 W 0.39 M 0.34 M turnoverVol 0.02 W 0 W 0.33 M 0.75 S 0.66 M chgPct 0 W 0 W 0.40 M 0.89 S 0.94 S Amplitude 0.31 W 0 W 0.49 M 0.51 M 0.33 M AD6 0 W 0 W 0.93 S 0.45 M 0.42 M AD20 0.07 W 0 W 0.90 S 0.99 S 0.34 M OBV6 0 W 0 W 0.73 S 0.33 M 0.23 W ATR6 0 W 0 W 0.66 M 0.57 M 0.94 S ATR14 0.05 W 0.01 W 0.55 S 0.46 M 0.87 S ROC6 0 W 0 W 0.38 S 0.45 M 0.27 W ROC20 0.09 W 0 W 0.53 S 0.60 M 0.49 M RSI 0.01 W 0.02 W 0.17 W 0.45 M 0.32 W MA120 0.02 W 0 W 0.56 M 0.62 M 0.57 M MACD 0 W 0 W 0.35 M 0.68 S 0.80 S TRIX5 0.21 W 0.13 W 0.47 M 0.58 M 0.87 S ADX 0.19 W 0 W 0.70 S 0.39 M 0.44 M Aroon 0 W 0 W 0.59 M 0.22 W 0.31 W 表 4 PSO与DMPSO寻优结果
Table 4. Optimization results of PSO and DMPSO
Function Algorithm Best fitness Mini Average Variance f1 PSO 0.0128 8.14×10−9 0.00275 7.72x10−5 DMPSO 0.0021 1.61×10−6 1.62×10−0.2 6.65×10−7 f2 PSO 3.26 0.0016 0.09129 0.00863 DMPSO 2.58 8.14×10−3 0.00312 4.69x10−8 f3 PSO −0.80037 0.013 0.02842 0.01927 DMPSO −0.98052 7.64x10−0.2 0.00627 3.32x10−6 表 5 各模型的评估结果(上证指数)
Table 5. Evaluation results of models(Shanghai component index)
Model RMSE MAPE MAE R2 SVM 45.3243 0.0125 35.1927 0.8609 RF 43.3969 0.0120 32.1178 0.8860 RNN 43.4705 0.0108 34.1901 0.8986 LSTM 40.0170 0.0099 29.0087 0.9165 PSO-LSTM 38.5019 0.0094 27.9021 0.9183 DMPSO-LSTM 35.9214 0.0067 25.3374 0.9315 表 6 各模型评估结果(深证成指)
Table 6. Evaluation results of models(Shenzhen component index)
Model RMSE MAPE MAE R2 SVM 399.4516 0.0462 239.7021 0.9179 RF 221.7186 0.0159 177.0426 0.9368 RNN 200.4326 0.0146 150.8910 0.9519 LSTM 213.9164 0.0140 145.4261 0.9586 PSO-LSTM 179.5563 0.0107 130.5739 0.9619 DMPSO-LSTM 160.3716 0.0081 118.7957 0.9705 -
[1] GRANGER C W J. The random character of stock market prices[J]. Journal of the American Statistical Association, 1965, 128(3): 447-449. [2] BAEK Y, KIM H Y. ModAugNet: A new forecasting framework for stock market index value with an overfitting prevention LSTM module and a prediction LSTM module[J]. Expert Systems with Applications, 2018, 113: 457-480. [3] CHATZIS S P, SIAKOULIS V, PETROPOULOS A, et al. Forecasting stock market crisis events using deep and statistical machine learning techniques[J]. Expert Systems with Applications, 2018, 112: 353-371. doi: 10.1016/j.eswa.2018.06.032 [4] CHEN Y, HAO Y. A feature weighted support vector machine and K-nearest neighbor algorithm for stock market indices prediction[J]. Expert Systems with Applications, 2017, 80: 340-355. doi: 10.1016/j.eswa.2017.02.044 [5] WENG B, LIN L, XING W, et al. Predicting short-term stock prices using ensemble methods and online data sources[J]. Expert Systems with Applications, 2018, 112: 258-273. [6] KIM H Y, WON C H. Forecasting the volatility of stock price index: A hybrid model integrating LSTM with multiple GARCH-Type models[J]. Expert Systems with Applications, 2018, 103: 25-37. [7] HOCHREITER S, SCHMIDHUBER J. Long short-term memory[J]. Neural Computation, 1997, 9(8): 1735-1780. doi: 10.1162/neco.1997.9.8.1735 [8] CHEN K , ZHOU Y , DAI F . A LSTM-based method for stock returns prediction: A case study of China stock market[C]// IEEE International Conference on Big Data. USA: IEEE, 2015: 2823-2824. [9] FISCHER T, KRAUSS C. Deep learning with long short-term memory networks for financial market predictions[J]. European Journal of Operational Research, 2017, 270(2): 654-669. [10] XIONG YC, ZHAO H. Chaotic time series prediction based on long short-term memory neural networks[J]. Scientia Sinica(Physica, Mechanica & Astronomica), 2019, 49(12): 120501. [11] MUnlin M , ANANTATHANAVIT M . New social-based radius particle swarm optimization[C]// 2017 12th IEEE Conference on Industrial Electronics and Applications (ICIEA). USA: IEEE, 2017: 838-843. [12] SHAO B, LI M, ZHAO Y, et al. Nickel price forecast based on the LSTM neural network optimized by the improved PSO algorithm[J]. Mathematical Problems in Engineering, 2019(2): 1-15. [13] YUAN X, CHEN C, JIANG M, et al. Prediction interval of wind power using parameter optimized Beta distribution based LSTM model[J]. Applied Soft Computing, 2019, 82: 105550. doi: 10.1016/j.asoc.2019.105550 [14] CHUN H, SHIN K S. Genetic algorithm-optimized long short-term memory network for stock market prediction[J]. Sustainability, 2018, 10: 1-18. doi: 10.3390/su10020001 [15] CHANG Z, ZHANG Y, CHEN W. Electricity price prediction based on hybrid model of adam optimized LSTM neural network and wavelet transform[J]. Energy, 2019, 187: 115804. doi: 10.1016/j.energy.2019.07.134 [16] FREUND Y, SEUNG H S, SHAMIR E, et al. Selective sampling using the query by committee algorithm[J]. Machine Learning, 1997, 28(2/3): 133-168. doi: 10.1023/A:1007330508534 [17] RAJESH K S, DASH S S. Load frequency control of autonomous power system using adaptive fuzzy based PID controller optimized on improved sine cosine algorithm[J]. Journal of Ambient Intelligence and Humanized Computing, 2019, 10(6): 2361-2373. doi: 10.1007/s12652-018-0834-z [18] JIANG J G, TIAN M, WANG X Q, et al. Adaptive particle swarm optimization via disturbing acceleration coefficents[J]. Journal of Xidian University, 2012, 39(4): 74-80. [19] PANT M , THANGARAJ R , ABRAHAM A . Particle swarm optimization using adaptive mutation[C]// 2008 19th International Workshop on Database and Expert Systems Applications. Italy : IEEE, 2008: 519-523. [20] 龙文, 梁昔明, 董淑华, 等. 动态调整惯性权重的粒子群优化算法[J]. 计算机应用, 2009, 29(8): 2240-2242. [21] SHI Y , EBERHART R . A modified particle swarm optimizer[C]// 1998 IEEE International Conference on Evolutionary Computation Proceedings. IEEE World Congress on Computational Intelligence. USA: IEEE, 1998: 69-73. [22] 任君, 王建华, 王传美, 等. 基于正则化LSTM模型的股票指数预测[J]. 计算机应用与软件, 2018, 35(4): 44-48,108. doi: 10.3969/j.issn.1000-386x.2018.04.008 [23] HUANG X, ZHANG J, ZHAN Z H. Faster particle swarm optimization with random inertia weight[J]. Computer Engineering and Design, 2009, 30(3): 647-650. [24] LIANG J J , SUGANTHAN P N . Dynamic multi-swarm particle swarm optimizer[C]//Proceedings 2005 IEEE Swarm Intelligence Symposium. USA: IEEE, 2005: 124-129. -