Future Generation Computer Systems: Dehua Zhang Sha Lou
Future Generation Computer Systems: Dehua Zhang Sha Lou
article info a b s t r a c t
Article history: Under the background of big data and Internet finance, quantitative investment is becoming more and
Received 15 July 2020 more critical, and the prediction of the stock price has become the focus of investors’ concern and
Received in revised form 3 October 2020 research. The purpose of this work is to apply neural network and BP algorithm onto the classification
Accepted 11 October 2020
and prediction of stock price patterns. The method is to use the BP algorithm neural network for the
Available online 13 October 2020
transaction data of 5 consecutive days as input samples, so there are 20 input layer nodes. The final
Keywords: value of the next day is used as the output sample, and the number of nodes in the output layer is 1.
Neural network The purpose of network training is to find 20 spline functions. After the training of the BP algorithm
BP algorithm neural network, the test data (stock price data for 5 consecutive days) independent of the training
Stock price prediction data is leveraged as the input of the neural network, and the closing price of the next day is used as
Stock price pattern classification
the target output of the network. Through the error between the actual output and the target output,
the stock price prediction performance of the network model is analyzed. The results have shown
that the prediction accuracy of the stock price is 62.12% under the prediction of deep learning fuzzy
algorithm and 73.29% under the prediction of the BP algorithm neural network. When the prediction
range is between 15 days, the error of 30 prediction values relative to the real value is within ± 10%,
accounting for 90% of the total days, and the prediction effect is the best. By analyzing the prediction
of the number of hidden layers on the stock price and different ranges, it can be concluded that the
prediction of the stock price trend prediction model of BP algorithm neural network is better than that
of the deep learning fuzzy algorithm prediction model. This algorithm provides investors with a certain
value for stock forecasting, which makes government gain a more active position in macroeconomic
regulation and control.
© 2020 Elsevier B.V. All rights reserved.
1. Introduction signal processing, and other fields, and has achieved amazing re-
sults. Therefore, the artificial neural network is used to predict the
With the development of research on stock market rules, most stock price. In the prediction of the nonlinear system of the stock
stock market prediction models are generated, which are suitable market, the rationality and applicability of the model construction
for the actual investment activities. These forecasting models and have its advantages, which can provide the nonlinear prediction
methods can clarify the operation rules of the stock market to a system for the stock market and theyrovide a wider space for
certain extent. However, due to the structural uncertainty of the development.
stock price system itself and the complexity of external economic For the prediction of the stock market, Kim et al. proposed a
environment factors, the forecasting work of the stock market new long-term and short-term mixed memory (LSTM) model to
will be challenging. Part of the results of the forecasting models predict the change of stock price. Using Kospi 200 index data, the
and applications currently used are not satisfactory to investors. authors found a hybrid model composed of LSTM and 1–3 GARCH
With the rapid development of artificial intelligence and com- models. The performance of each model was compared with the
puter technology, the stock market forecasting model is continu- existing methods. The performance was also compared with the
ously updated and integrated. The principle of the neural network proposed hybrid LSTM model. It was found that gew-slstm is a
is to model according to the internal mechanism of internal data, hybrid model composed of the LSTM model and three GARCH
which is widely used in pattern recognition, intelligent control, models, and its prediction error is the lowest in terms of mean
absolute error, mean square error, heterodispersity adjusted Mae
∗ Corresponding author. and Hetero dispersity adjusted MSE. By combining the neural
E-mail addresses: [email protected] (D. Zhang), [email protected] network model with a single econometric model and multiple
(S. Lou). econometric models, their model greatly improves the existing
https://doi.org/10.1016/j.future.2020.10.009
0167-739X/© 2020 Elsevier B.V. All rights reserved.
D. Zhang and S. Lou Future Generation Computer Systems 115 (2021) 872–879
prediction performance. Finally, his method can be used as a (5) Transaction amount: from the formula, it is equal to the
comprehensive model including time series model and neural transaction price multiplied by the corresponding quantity. An-
network model to expand to various fields, or as a comprehensive other form of currency, representing the total sales of shares
model to predict the volatility of the stock market. The accuracy [6,7].
of this method is low and shown in Ref. [1]. Putrier believed that (6) Trading volume: the total number of shares traded on that
in securities investment, the management of investor funds can day. The minimum unit is 1 batch (100 shares).
be regarded as a dynamic optimal control problem. To optimize (7) Up and down: through the closing price of the stock price
the capital structure of investors, investors must predict the stock for two consecutive days, to judge whether the stock price is
price dynamics of the portfolio. Author used the ARIMA Kalman significantly up or down, the latest closing price will rise when it
filter to predict the daily share price of the portfolio. Next, the is higher than the previous closing price, otherwise it will fall [8].
return value of the stock price was calculated according to the
(8) Pressure point: this means that the stock price stops rising
stock price forecast. Authors tried to use model predictive control
after reaching a certain point in the rising process, which is called
(MPC) to solve combinatorial optimization problems. If we use
pressure point.
the MPC algorithm to get the best controller, we can get the best
(9) Support point: this means that the stock price continues to
combination management strategy [2]. Kuang Y, Singh R, Singh S,
fall, reaches a specific position, and stops falling, then rises, which
et al. A novel macroeconomic et al. proposed a new macroeco-
is called the support point [9].
nomic prediction model based on improved multimedia support
BP neural network model and Ariko algorithm. The choice of fault (10) K line: it is an analysis chart of specific changes in stock
prediction technology is limited and the prediction technology price during the unit period. This is an essential reference for
is uncertain, so the model mainly focused on the following two short-term investors to analyze stocks, with specific technical
aspects. The uncertainty of the selection error of the prediction requirements.
method is more prominent. The possibility of a wrong predic-
tion method leading to a correct prediction result is minimal. 2.2. Stock market
Limitations of prediction methods. It does not depend on which
prediction method has applicable conditions It is neither robust
nor static. Thus, to improve the previous methods, it is needed to The stock market is the issuing and trading market, which
study the updated technology. He used Ant Colony Algorithm to includes the issuing market and the circulation market. The circu-
change the BP model and continues to predict points appropri- lation market is the so-called issuing market, and the circulation
ately, which refers to fixed value prediction. The practicability of market refers to the circulation market. A company limited by
this method is not reliable [3]. shares can raise a lot of capital quickly by issuing shares to the
This study first introduces the stock market and its basic terms society. This is used to expand the scale of the business. People
in detail, then classified the methods and difficulties of stock who invest in stocks are reluctant to share the risk of enterprise
forecasting, lists three kinds of stock price forecasting methods, development and expansion, because they want the value of the
i.e. time series method, securities investment analysis method invested capital [10,11].
and artificial intelligence forecasting method. Three forecasting Introduction to primary and secondary markets:
difficulties influencing factors, i.e. internal factors, fundamental The primary stock market is also known as the issuing market.
factors, and policy factors. Then, the BP neural network and Enterprises that need funds can issue a limited number of shares,
its mathematical model are described, including the formula of so that investors can choose to buy necessary funds. Companies
weight adjustment, algorithm derivation, and so on. At the same that issue stocks usually sell stocks not directly to ordinary in-
time, experimental modeling is carried out in this study. After vestors, but through intermediaries, i.e., securities brokers, so the
the completion, the data are simulated and analyzed, and the primary stock market is also known as the brokerage market. The
results have been obtained. Through the analysis of the number public offering method of listed companies is called a graveyard,
of hidden layer to the stock price prediction, the analysis of BP
which is the public offering of the market. The method of issuing
algorithm and fuzzy algorithm to the stock price prediction, the
shares to specific objects is called a private offering, that is, a
comparative analysis of the errors of different algorithms and the
non-public offer [12].
analysis of the prediction effect of different ranges. This study
The secondary market circulation market provides a trading
demonstrates the validity and superiority of the prediction model
place for issuing stocks, which is a stock trading place. Because
of the BP algorithm neural network in this study.
the secondary market provides liquidity for stocks, investors can
cash at any time, so stockholders can cash at any time. Hence,
2. Prediction of stock price model and BP algorithm
the secondary market has the function of price setting. The main
functions of the secondary market include: absorbing idle private
2.1. Basic terms of stock
funds for the development of enterprises and effectively guiding
the flow of funds. It is also the primary function of the market
(1) Opening price: also known as the opening price of the
economy. The secondary market reflects the social and economic
market, it is the price at which one shares is traded as a unit after
the centralized bidding process before the market [4]. situation and provides the basis for the formulation of national
(2) Closing price: originally refers to the last trading price of policies. The secondary market and primary market promote and
the stock. At present, the closing prices of Shanghai and Shenzhen restrict each other. According to type, quantity, and method of
stock markets are weighted average prices. This refers in partic- the stocks issued in the circulation market, the structure of the
ular to the weighted average price of all transaction prices one securities circulating in the secondary market is determined. As
minute before the last transaction [5]. a stock exchange, the secondary market promotes and promotes
(3) Lowest price: refers to the lowest value of all trading prices the development of the primary market. Through reasonable
of stocks on that day. organization and high-quality service, the stocks in the circulation
(4) Maximum price: refers to the highest value of all trading market can be effectively distributed and transferred, making
prices of shares on the day. investors more suitable for circulation [13,14].
873
D. Zhang and S. Lou Future Generation Computer Systems 115 (2021) 872–879
the input layer, hidden layer and output layer. Finally, the actual weight should be in direct proportion to the decrease of the error
output is compared with the teacher signal. When the difference gradient, namely:
is large, the error will be backpropagation, and the error will be ∂E
distributed to each node of each layer to generate the error signal ∆wjk = −η , j = 0, 1, 2 . . . n; k = 1, 2, . . . , l (10)
of each node. The neural network will change the weight value
∂wjk
of each node on this basis. The weighted correction process will In the formula, the negative sign represents the gradient de-
continue to cycle, and the network learning and training process cline, and the constant η ∈ (0, 1) represents the scale coefficient,
will continue until the final error reaches an acceptable range or which is often called the learning rate of the neural network.
reaches a predetermined number of learning times [25]. (3) Derivation of BP algorithm
The formula of weight adjustment of the three-layer BP algo-
2.6. Mathematical model of BP neural network rithm is deduced.
∂E ∂ E ∂ netk
(1) Basic model ∆wjk = −η = −η (11)
∂wjk ∂ netk ∂wjk
For the three-layer BP neural network mathematical model,
the following assumptions are made: the input vector of the An error signal is defined for the output layer and the hidden
model is X = (x1 , x2 , . . . , xi , . . . , xn )T ; the output vector of the layer respectively, so that:
output layer is O = (o1 , o2 , . . . , ok , . . . , ol )T ; the output vec- ∂E ∂E
tor of the hidden layer is Y = (y1 , y2 , . . . , yj , . . . , yn )T ; the δko = − ; δy = − (12)
∂ netk j ∂ netj
expected output vector is d = (d1 , d2 , . . . , dk , . . . , dl )T ; V = y
(V1 , V2 , . . . , Vj , . . . , Vm ) is the weight matrix from the input layer ∆wjk = ηδko yj ; ∆vij = ηδj xi (13)
to the hidden layer, W = (W1 , W2 , . . . , Wk , . . . , Wl ) is the weight For the output layer, expand to:
matrix from the hidden layer to the output layer; Vj is the weight
vector corresponding to the jth neuron in the hidden layer; Wk is ∂E ∂ E ∂ ok ∂E ′
δko = − =− =− f (netk ) (14)
the weight vector corresponding to the kth Shenjing element in ∂ netk ∂ ok ∂ netk ∂ ok
the output layer. ∂E
For the output layer, the following equation exists: = −(dk − ok ) (15)
∂ ok
ok = f (netk ), k = 1, 2, . . . , l (1) Comprehensive:
m
∑ δ = (dk − ok )ok (1 − ok )
o
(16)
netk = wjk yj , k = 1, 2, l (2) k
j=0 Formula (16) is the final derivation formula of two error sig-
nals. Combining formula (13) and formula (16), the weight adjust-
For hidden layers, the following equation exists:
ment formula of BP learning algorithm of three-layer network is
yj = f (netj ), j = 1, 2, m (3) obtained as follows:
is the input index value of the past n trading days. After the Table 1
network model passes BP, the output value will be generated. This Price information data of Gree Electric.
output value is the forecast value in the following table. The input Time Starting Maximum Minimum Closing Volume
price price price price
variables of the second comparative experiment are the highest
09:40 25.95 26.06 25.95 26.05 1 950 753
value, the lowest value, the starting value, the ending value, the
09:45 25.91 25.92 25.79 25.8 3 098 312
K value, the D value, and the J value. That is to say, the value 09:50 25.96 25.96 25.93 25.93 803 555
index of Experiment 1 is deleted. The prediction process is the 09:55 26.11 26.11 26.07 26.08 1 133 100
same as the initial experiment, and a series of predicted values 10:00 26.01 26.03 26 26.01 664 900
will be obtained later. Finally, the results of the two experiments 10:05 26.1 26.13 26.1 26.12 826 510
10:10 25.95 25.96 25.9 25.92 1 364 700
are compared by error analysis.
4.1. Analysis of the number of hidden layers on the prediction of 4.2. Analysis of BP algorithm and fuzzy algorithm for stock price
stock price prediction
The data collection interval is expected to be 5 min, and the The selected training sample data is imported into the BP
30-min stock price information data of Gree Electric from Decem- algorithm neural network prediction model of this paper for
ber 10, 2019 to December 10, 2019 will be randomly intercepted. training, and compared with the deep learning fuzzy algorithm
Table 1 shows the share price information of Gree Electric. for training. According to the modeling method, the parameters
Table 1 and experimental results show that if three hidden are trained in turn. After configuring the network model in train-
layers are used, the prediction accuracy of the network model is ing depth, input the following content at last. Test the sample
56.17%. The selected training sample data is imported into the data of stock data prediction to find out the accuracy of model
876
D. Zhang and S. Lou Future Generation Computer Systems 115 (2021) 872–879
Table 2
Error comparison table.
Time ε mae mse
0 0.01 11.51 157.81
5 0.05 9.63 126.84
10 0.1 7.15 71.65
15 0.2 4.46 29.21
20 0.3 2.14 9.39
25 0.4 0.89 1.76
30 0.5 1.17 2.54
35 0.6 1.79 3.68
40 0.7 2.56 7.95
4.3. Error comparison and analysis of different algorithms When fitting the closing price with 7-day information, the
prediction error of 5% days is 43% of the total days, and the
When n is 5, the model uses each indicator value within 5 days prediction effect is much better than that of n = 5. Tian’s stock
to predict the closing price of the next day. There are currently
price information cannot fully represent the process of stock price
46 input variables. Five opening prices, five closing prices, the
change.
five highest prices, five lowest prices, 5K values, 5D values, 5J
In the case of n = 10, the number of 30 predicted values for
values, and five dynamic price returns-value, five dynamic prices
the true value is within ±10%, 25, accounting for 83% of the total
to book ratio and one profit margin value. The output variable is
days. There are 15 errors within ±5% of the total number of days,
the closing price of the next trading day. The number of hidden
the prediction effect is further improved, and the number of days
layer nodes is 7.
within 5% of the error range reaches 50%.
A problem was found in the training process: the smaller the
When n = 15, the number of 30 predicted true values is
given fitting error, the better the final prediction result. This is
because if the wrong setting is allowed to be too small, the model within ±10% of 27, accounting for 90% of the total days. There
will lead to overfitting, and the final prediction result is far from are 17 errors within ±5%, accounting for 56% of the total days.
the real value. With the increase of the given error, the final The predicted result is slightly better than that of n = 10.
prediction error will first decrease and then increase. That means When n = 20, the number of 30 predicted true values is within
there is the most suitable specified permissible error that can ±10% of 26, accounting for 86% of the total days. There are 15
minimize the prediction error without changing other conditions. errors within ±5%, accounting for 50% of the total days. The
To find the relative optimum value, some experiments have been prediction results show that the outcome of n = 15 is slightly
carried out to adjust the allowable error ε from 0.01 to 0.7. Table 2 worse, the greater n is, the higher the prediction effect is, and
is the error comparison table. N is also the best value. As shown in Fig. 5, the comparison of
MAE is the average absolute error of the final predicted price different n-value prediction results is shown.
and the actual price, MSE is the mean square error of the pre- When n increases from 5, the prediction accuracy will de-
dicted price and the actual price. It can be seen from the table crease after the initial increase. When n = 15, the maximum
that when the allowable error ε is 0.4, Mae and MSE are both the relative value will be reached. Then, through several experiments
minimum, and when n = 5, 0.4 is the best allowable error value. to confirm the prediction results of n = 14 and N = 16, it is
As shown in Fig. 4, the error comparison analysis diagram of the found that the result is slightly worse than that of n = 15. In this
two algorithms is shown. prediction model, n = 15 is the best value.
877
D. Zhang and S. Lou Future Generation Computer Systems 115 (2021) 872–879
Acknowledgments
[1] H.Y. Kim, C.H. Won, Forecasting the volatility of stock price index: A hybrid
5. Conclusion
model integrating LSTM with multiple GARCH-type models, Expert Syst.
Appl. 103 (aug.) (2018) 25–37.
In recent years, the application of artificial neural networks in [2] E.R.M. Putri, Investment management using portfolio optimization with
the field of finance has become a research hotspot. In particular, stock price forecasting I. Fitria, E. Apriliani, E.R.M. Putri - Applied
BP neural network, which is mature and widely used, has the Mathematical Sciences, 2016, Appl. Math. Sci. 10 (48) (2016) 2405–2413.
[3] Y. Kuang, R. Singh, S. Singh, et al., A novel macroeconomic forecasting
function of approximating complex continuous functions that model based on revised multimedia assisted BP neural network model and
many traditional methods cannot use. Compared with the predic- ant colony algorithm, Multimedia Tools Appl. 76 (18) (2017) 18749–18770.
tion accuracy of the fuzzy algorithm based on deep learning, the [4] E. Meric, M. Kamisli, F. Temizel, Interactions among stock price and
neural network prediction model of the BP algorithm in this study financial ratios: The case of Turkish banking sector, Appl. Econ. Finance
4 (6) (2017) 107.
has the experimental conclusion that the prediction accuracy of
[5] Victor R.R. Jose, Percentage and relative error measures in forecast
the fuzzy algorithm based on deep learning is lower than that of evaluation, Oper. Res. 65 (1) (2017) 200–211.
the neural network based on BP algorithm. [6] G.D. Martino, How do investors perceive long-term growth targets and
In the past technical analysis methods, if we predict such a forecast horizons in strategic plans? Evidence from Italian firms, Issues
nonlinear stock price, satisfactory results cannot be obtained in Stud. 07 (02) (2019) 3–43.
[7] Y.W. Him, L. Camillo, Stock price crash risk and unexpected earnings
most cases. The BP neural network model used in this study is thresholds, Manag. Finance 44 (8) (2018) 1012–1030.
based on the premise of fully using the BP algorithm to improve [8] G.S. Atsalakis, E.E. Protopapadakis, K.P. Valavanis, Stock trend forecasting
the training speed. A stock price index is an experimental object. in turbulent market periods using neuro-fuzzy systems, Oper. Res. 16 (2)
It forecasts the closing price of the next 30 days and achieves a (2016) 245–269.
[9] J.B. Kim, Accounting flexibility and managers’ forecast behavior prior to
satisfactory result. Therefore, the simulation experiment shows
seasoned equity offerings, Rev. Account. Stud. 21 (4) (2016) 1361–1400.
that the neural network stock price prediction method optimized [10] R.K. Loh, R.M. Stulz, Is sell-side research more valuable in bad times? J.
by the BP algorithm has a specific value. The trained BP neural Finance 73 (3) (2018) 959–1014.
network has a certain prediction effect and can provide investors [11] M. Khashei, Z. Hajirahimi, Performance evaluation of series and parallel
with the function of stock price prediction. strategies for financial time series forecasting, Financ. Innov. 3 (1) (2017)
24.
The prediction accuracy of this study is better than that of
[12] K. Chapman, G.S. Miller, H.D. White, Investor relations and information
other algorithms, but there is still room for improvement. In assimilation, Account. Rev. 94 (2) (2019) 105–131.
the next step, research of more stock technical indicators are [13] A. Sethi, Predictive modeling of CNX Nifty 200 from a valuation
improved and find out the relationship between indicators and perspective, Asian J. Manag. 10 (1) (2019) 14–18.
prediction accuracy. Further, improve the prediction accuracy [14] X. Tan, Z. Ji, Y. Zhang, Non-invasive continuous blood pressure measure-
ment based on mean impact value method, BP neural network, and genetic
of the law. In the process of forecasting the stock price with algorithm, Technol. Health Care 26 (6) (2018) 1–15.
the help of a neural network system, this study is only in an [15] S. Zhou, C.Y. Shen, L. Zhang, et al., Dual-optimized adaptive Kalman
ideal state. It does not consider other external factors such as filtering algorithm based on BP neural network and variance compensation
economic development momentum, government policy factors, for laser absorption spectroscopy, Opt. Express 27 (22) (2019) 31874.
[16] F.X. Li, Commutation failure detection algorithm based on stationary
other emergencies and so on. In fact, in a certain period, these
wavelet and BP neural network, Shenyang Gongye Daxue Xuebao/J.
external factors have a great impact on the stock price. Shenyang Univ. Technol. 40 (3) (2018) 248–252.
[17] M. Wang, Z. Yuan, X. Zhang, et al., Construction of air quality evaluation
Declaration of competing interest system based on FCM algorithm and BP neural network, Agric. Biotechnol.
7 (05) (2018) 279–281.
[18] H. Zhou, Y. Zhang, D. Zhang, et al., An anisotropic magnetostriction model
The authors declare that they have no known competing finan- based on BP neural network combining Levenberg–Marquardt algorithm
cial interests or personal relationships that could have appeared and particle swarm optimization, Int. J. Appl. Electromagn. Mech. 55 (3)
to influence the work reported in this paper. (2017) 1–9.
878
D. Zhang and S. Lou Future Generation Computer Systems 115 (2021) 872–879
[19] X. Tongle, W. Yingbo, C. Kang, Tailings saturation line prediction based on Dehua Zhang was born in Heilongjiang, Mudanjiang,
genetic algorithm and BP neural network, J. Intell. Fuzzy Systems 30 (4) P.R. China, in 1984. He received the Ph.D. in Manage-
(2016) 1947–1955. ment from Northeast Agricultural University, P.R. China.
[20] T. Liu, S. Yin, An improved particle swarm optimization algorithm used for Now, He works at the School of Finance, Harbin Uni-
BP neural network and multimedia course-ware evaluation, Multimedia versity of Commerce. At the same time, he conducted
Tools Appl. 76 (9) (2017) 11961–11974. postdoctoral research at the Northeast Asia Service
[21] Y. Liu, C. Hu, Y. Hong, Electric energy substitution potential prediction Outsourcing Research Center of Harbin University of
based on logistic curve fitting and improved BP neural network algorithm, Commerce. His research interest include rural finance,
Elektron. Elektrotech. 25 (3) (2019) 18–24. food economy and farmers’ income.
[22] F. Liu, H. Gong, L. Cai, et al., Prediction of ammunition storage relia- E-mail: [email protected].
bility based on improved ant colony algorithm and BP neural network,
Complexity 2019 (4) (2019) 1–13.
[23] Q.Y. Liu, Y.J. Ruan, X. Shi, et al., Hourly power load forecasting of office Sha Lou was born in Heilongjiang, Hegang, P.R. China,
building based on kmeans clustering and BP neural network algorithm, in 1983. She received the Ph.D. in Management from
Reneng Dongli Gongcheng/J. Eng. Thermal Energy Power 33 (3) (2018) Northeast Agricultural University, P.R. China. Now, she
138–144. works at the School of Finance, Harbin University of
[24] G. Zhou, Y. Sun, P. Jia, Application of genetic algorithm based BP neural Commerce. Her research interest include rural finance,
network to parameter inversion of surrounding rock and deformation agricultural insurance.
prediction, Modern Tunn. Technol. 55 (1) (2018) 107–113. E-mail: [email protected].
[25] Y.L. Song, C. Yu, D.G. Dai, et al., Parameter optimization of heat source
model for laser welding based on BP neural network and genetic algorithm,
Suxing Gongcheng Xuebao/J. Plasticity Eng. 24 (1) (2017) 218–222.
879