The Prediction of Stock Price Based on Improved Wavelet Neural Network

To improve the accuracy of forecasting stock prices, a new method is proposed, which based on improved Wavelet Neural Network (WNN). Firstly, the Genetic Algorithm (GA) is used to optimize initial weights, stretching parameters and movement parameters. Then, comparing with traditional WNN, the momentum are added in parameters adjusting and learning of network, what’s more, learning rate and the factor of momentum are self-adaptive. The prediction system is tested using Shanghai Index data, simulation result shows that improved WNN performs very well.


Introduction
The stock prices are time series data with multiple variables, there are non-linear, time-varying and uncertain relationship, and have always been a challenge to both economists and researchers [1] [2].
A variety of models have been established to predict the stock prices by observing the law of data, such as Autoregressive Integrated Moving Average Model (ARIMA) [3], support vector machine [4] and neural network (NN), wavelet neural network (WNN) [5] model.ARIMA is typical linear time series analysis method, but stock market is a large of nonlinear dynamic system and share price index is out of order.So if ARIMA model predicts complex time series, forecasting result often don't be ideal.SVM is a non-traditional nonlinear forecasting technique based on the structure risk minimization principle.It can be use the theory of minimizing the structure risk to avoid the problems of excessive study, calamity data, local minimal value and so on.However, the regression cannot approach every function.With the rapid development of artificial intelligence technology, NN is employed as the nonlinear predictor for financial time series.Although prediction results usually outperform ARIMA models, traditional NN models have several disadvantages, including: a lot of model parameters should be dependent on, easy to be trapped into local minima, and over-fitting on training data resulting in poor generalization ability.As the wavelet analysis theory developed in the mid-1980, WNN was first proposed by Qinghua Zhang, and has been widely applied [6], WNN has following advantages, one is that as the low correlation of wavelet neuron, WNN has fast convergence.What's more, stretching and movement factors of wavelet function make the approximation capability of network more powerful.The third is wavelet neural network matches the signal with the good partial characteristic and multiresolution learning, which can express function characteristic and has higher forecast accuracy [7].But there still have two disadvantages: First, the learning rate is constant, so if there is large, the training may over convergence; Second, WNN training method usually includes the stochastic gradient algorithm and declined gradient, those only consider the nth while ignoring the previous direction of n times, which make training trapped into local minima [8].
Aiming at the shortcomings of WNN, the paper proposes the stocks market modeling and forecasting by using improved WNN.In parameters adjusting and learning of network, momentum items are added, in the same time, learning rate and the factor of momentum are self-adaptive and the form of decreasing factor of learning rate is connected with forecasting error.Using improved WNN to predict Shanghai Stock market, it shows that improved WNN is superior to WNN.

Wavelet Neural Network (WNN)
WNN is neural network model composed by wavelet function as its activation function.Structural diagram of three-layer wavelet neural network is shown in Figure W represents the weight between input layer and hidden layer, jk W is weight between hidden layer and output layer.In this time, the input and output of hidden layer as follows, , nodes is , l k is the number of input layer nodes and m is the output layer nodes'.The correction of parameters such as weights, movement parameters and stretching parameters as follows,

Improved Wavelet Neural Network
As the learning rate is constant, if there is large, the training may over convergence, in the same time WNN training method usually include the stochastic gradient algorithm and declined gradient, those only consider the nth while ignoring the previous direction of n times, which make training trapped into local minima .In order to overcome the shortcomings in the correcting, we propose the formulas of correction as follows, ( represent the nth learning rate and ( ) k n is the nth momentum factor, and in this paper, the formulas of them are expressed as, ( ) ( ) ( ) In the formulas, ( ) ( ) learning error increased, it is better to decrease the learning rate and remove the momentum; if 0 E ∆ ≤ , the learning error decreased and the direction of correction is right, so we keep learning rate and momentum unchanged.

The Training Process by Improved WNN Model
Step 1. Considering when the initial parameters is not suitably selected, the WNN training will slow or even diverging [9], so it is vital to use GA to optimize initial weights, stretching parameters and movement parameters [10].
Step 3. Dividing sample into training sample and test sample.Training sample is used to train the network and test sample is used to test the prediction accuracy.
Step 4. Putting test sample as input of network and calculating the error between expected output and actual output.
Step 5. Making output of network is close to expected output, using error to adjust weights, stretching parameters and movement parameters.
Step 6. Judging the algorithm is end or not.If it is not, return Step 3.

Data Processing
Taking Shanghai stock market for example, the chosen time series is the closing index of daily stock price in Shanghai Stock exchange from March 23th, 2012 to November 28th, 2014.This yields a total of 607 data samples, in which, the former 507 data samples are selected as training samples, the later 100 data samples as test samples.To improve the prediction accuracy, the data are normalized, the formula as follows, min max min where x′ represents the data of normalized processing, x represents original data, max x , min x represent the maximum and the minimum number in data.

Training of Network
To stock market, taking into account the fact that there are five trading days a week, a WNN forecast model of one five-dimension input data [11] and one output data is established and set that the number of neurons in hidden layer is 6.We choose three-layer network because it can approximate arbitrary function.So the structure of WNN is 5-6-1.If the activation function adopts different wavelet functions, then there will be different performance [12].In this paper, we choose Morlet wavelet function as activation function.Learning rate 1, 2 η η are 0.01and 0.001 separately.The expected error is 0.001 and the number of iterations is 100; Improved WNN has the same structure with WNN.The initial learning rate 1, 2 η η are also 0.01 and 0.001 separately; initial mo- mentum factor k is 0.9; the expected error is 0.001; and the number of iterations is 100.GA is used to optim- ize initial weights, stretching parameters and movement parameters of WNN and improved WNN.The number of iterations is 50.What's more, in GA, the population size is 40, the number of evolution is 50, crossover probability is 0.2 and mutation probability is 0.1.

Simulation and Evaluation
The paper use root mean square error (RMSE) and mean absolute percentage error (MAPE) as evaluation standard of network, which are defined as ( ) where n refers to the number of test sample, ( ) , , , n y y y  refers to actual output of network, ( ) , , , n y y y ′ ′ ′  refers to desired output.
Figure 2 shows the forecasting result of WNN improved WNN whose initial parameters were optimized by GA.Their RMSE and MAPE were shown by Table 1.
Figure 2 we can see after optimized by GA, improved WNN has a better forecasting ability than WNN.

Conclusion
In this paper, the application of improved wavelet neural network to stock market prediction is studied.Considering that the forecasting accuracy is easy to be affected by initial parameters, which can provide GA to optimize it at first.The forecasting simulation results of Shanghai index data show that the improved WNN method is effective and the stock market model is of good prediction performance.
error of output of network, ( ) yn k represents expected output, 1, 2 η η represent learning rate.

Table 1 .
Comparison of forecasting error in different methods.

Table 1
summarizes the comparison of performance indicators of forecasting errors between the two models.Comparing with two methods, it can be see that improved WNN improves forecast accuracy, and it substantially reduces the RMSE by about 20% and MAPE by about 19%.