Forecasting the Stock Price Time Series via All Components of Multi Resolution

Objectives: This research study presents a forecasting model that integrates an efficient discrete wavelet transform and a Backpropagation Neural Network (BPNN) for predicting financial time series. Methods/Statistical analysis: The presented model uses the wavelet transform at several time instances based on local smooth B-Spline wavelets of order d(BSd) to decompose the financial time series data. So, an approximation (long-term trends) component and several details (shortterm deviations) components are obtained. Since the details components act as a complementary part of the approximation component, to prepare a prediction model which applies all decomposed components is very advantageous. Therefore, all components are used as smooth input samples of the neural network to forecast the future of the financial time series. Findings: The proposed model is designed to forecast the stock prices of five different companies, and according to the obtained results, the presented model outperforms a conventional model that uses only the approximation component as a wavelet de-noising-based model. The numerical results have shown the prediction accuracy. Applications/Improvements: The proposed model can predict future stock prices better than the de-noised based model in nearly 70%cases. *Author for correspondence


Introduction
Stock price time series analysis is one of the most considerable topics for financial researchers, and risk managers. Specially predicting the future is an important factor for managing of the capitals. Investors and managers require of making many essential decisions based on the future forecasts, because every day an abundant wealth is traded through the stock markets across the globe and investors are eagerly looking for efficient tools to trace and predict the market to maximize their profits at lower risks. Therefore, financial researchers have extensively pro-been used as a signal processing technique which decomposes a time series into a de-noised component (the approximate data set), and a noisy component (the detail data set), to extract the hidden detail features of the original time series, such as high volatility ( Figure 1). Although in forecasting the future of a financial time series, choosing the approximation data set as predictive inputs is not appropriate when there is important local hidden information, previous models, due to the weaknesses in their structure, were only able to predict de-noised datasets. In [1][2][3] proposed recently, financial researchers postulate that the detail features could improve the forecasting models [4][5][6][7] . Therefore, we design a new forecasting model in which the details are used.  In this paper, our proposed model integrates the B-Spline wavelet transform as the preprocessing tool, and neural network as the peredicting tool for stock price time series. For this purpose, first by applying a B-Spline wavelet multiresolution of order d each stock price time series is decomposed into a smooth approximate component, and several smooth details components ( Figure  2). Then, all components are simultaneously used as a new structure of network inputs to design a new BPNN model.
The novel contributions of the present paper are in the following two aspects: • We have prepared an improved combined forecasting model which has a new design in the structure of the neural network inputs.
• As far as we Know, we are the first ones who have used B-Spline wavelets transform of order d for decomposing stock time series into several data sets, and all of which are simultaneously used in predicting process of the original time series.
Note that BSd is implemented since B-Splines have been extensively used in curve and surface modeling, as well as in approximation theory. Moreover, smoothness, local support, and the existence of efficient linear algorithms make B-Spline wavelets a good choice for scaling functions in constructing the wavelets 8 .
The rest of the study is organized as follows: Section 2 describes some backgrounds and related works in some details. The methodology of the proposed model is demonstrated in Section 3. Performance matrices which are used to evaluate the prediction models are described in Section 4. Section 5 represents the capability of the model in predicting the different stock markets. Section 6 summarizes the results and compares the reliability of the proposed model with a wavelet de-noised-based forecasting models. Finally, Section 7 describes our conclusions.

B-Spline Wavelet Multiresolution
AB-Spline wavelets transform of order d (BSd) is defined as a local, and discrete wavelet transform. B-Spline wavelet Transform of order d = 1 (BS1) is known as Haar wavelet transform with discontinuous wavelets, while a B-Spline wavelet transform of order d>1, is generated by continuous wavelets. In this article, we have adopted a notation for representing multiresolution operations used by Samavati and Bartels, for which they had found simple matrix forms of B-Spline wavelet transform of order d used in decomposition and reconstruction of any curves and surfaces in computer graphic models 9 . They have denoted {it analysis filter} matrices by A j and B j , and synthesis filter matrices by P j and Q j , where the subscript j is used as the level of resolution. These matrices are related as follows: .
In the matrix form of BSd, the given data vector Cj is decomposed into two parts: C j-1 (lower-resolution vector) and D j-1 (details vector), which are generated by using filters of Aj and Bj as follows: and the reconstruction process are prepared by using filters P j and Q j as follows: Therefore, applying wavelet transform process on a time series C j by BSd, for j levels, decompose it into several parts, C 0 , C 1 , ..., C j-1 , approximation data sets with lower-resolution, and the corresponding D 0 ,D 1 ,..., D j-1 , details data sets. These are defined as B-Spline wavelet multiresolution of a high-resolution sample vector C j , and the sequence C 0 ,D 0 ,D 1 , ...,D j-1 is known as a wavelet transform 10 .
B-Spline wavelets are often used as scaling functions, since their matrix filters are very simple and efficient 11 . Conventionally, B-Spline wavelets of higher order are constructed with the goal of semi orthogonality, which results in full matrices analysis 9 . An alternative approach for generating multiresolution matrices is the reverse subdivision, which has been originally introduced by Bartels and Samavati 8 . By using this approach, it is possible to obtain banded matrices for biorthogonal B-Spline wavelets whose bands are narrower than the ones conventionally produced by B-Spline wavelets. Olsen and Samavati used the reverse subdivision as a discrete approach for constructing scheme of many curves and surfaces 12 .
Multiresolution analysis has proven itself as a very powerful mathematical framework in many applications 13 . Decomposition of a high-resolution signal to low resolution and details signals, for multiple times, provides an effective tool for better compression and also model synthesize. In [13][14][15] proposed exploited multiresolution analysis to achieve curve synthesis by capturing and reusing artistic styles. In 16 used multiresolution in iris synthesis and contextual void patching in terrains. In 17,18 proposed used reverse subdivision for optimizing line-of-sight queries in real-time navigation in large terrains 19 . As far as we know in contrast to Haar wavelet transform as a B-Spline wavelet transform of order one, B-Spline wavelet transforms of order d >1 have not yet been used for preprocessing of financial time series.
In the present study, we have employed BSd in order to achieve more accurate prediction of stock market. We particularly use reverse subdivision multiresolution filters 8-9 since they are simple and efficient to implement for stock price prediction. Finally, we use Matlab for the coding of BSd.

An ANN Model for Forecasting of Stock Market
Artificial Neural Network (ANN) is a computational method which is designed to work like the brain 20 . An ANN has two parts: the structure and the training. There are different structures and arrangements of neurons in an ANN. For example, a kind of ANNs is a feed forward Multilayer Perceptron which includes perceptrons arranged in several layers, like BPNN 21 . The simplest ANN consists of three layers: Input, hidden, and output layers. The first layer (Input layer) takes normalized input data vectors, in the standard range [-1; 1], for sending to the second layer (hidden layer) in which there are several neurons. Finally, the second layer sends its outputs to the last layer (Output layer) in which there is only one neuron which produces the network output. Each connection from one layer to the next layer has a weight. These weights are coefficients (parameters) of the ANN model. The size of each weight represents the relative strength of the connection. The most important aspect of an ANN is its ability to address the problem of learning. The learning process finds the optimum weights and biases (they are parameters regarding to each neuron) from a given training set. In backpropagation learning method, the weights are adjusted for each training sample to achieve a desired output. Optimization methods (e.g. gradient descent method) are used for updating weights. An ANN with backpropagation learning ability, which is commonly used in prediction of stock price time series, is called a BPNN 6,23 .
The relationship between the output of the network O(t) and its input I(t)is given by 5 (2.5) where, W p,q 's are the connection weight vectors, each of which has m components for the pth input node and the qth neuron in the hidden layer, w 0 is the bias for output neuron, w 0,q is the bias for qth neurons in the hidden layer, P is the number of input nodes, Q is the number of hidden neurons, and f is a nonlinear activation function that enables the system to learn nonlinear relationships 6 .

Methodology of BSd-BPNN Model for Prediction of the Stock Market
The proposed automated stock price time series prediction system consists of three steps: (1) The original stock price time series S is preprocessed by BSd.
(2) The approximation, and all details components are then used for the predicting of the time series. These components are used as the inputs of a BPNN. The structure of the proposed model is shown in Figure 3, and then the performance measures are described in more detail. For comparison purposes, a similar prediction system is simulated in which details components are excluded from predictors.
In this section, we bring forward a combined model BSd-BPNN, which integrates BSd multiresolution and the back propagation neural network. The BSd-BPNN model is employed to predict the future term in the stock price time series S = (s 1 , s 2 , ..., s N ), l steps ahead (i.e. s N+1 ). The vector S shows all the historical prices, where N is usually a large number and s i = s ti is the price at time instance t j , i =1,2,...,N. For this purpose, first B-Spline multiresolution is applied on the financial time series at jth level, and according to recursivity of (2.4), we obtain the matrix form of the B-spline multiresolution representation of the signal ), as the high resolution sample, which is given by: where, G 1 =P j P j-1 … P 1 C 0 ,H k = P j P j-1 … P k+1 Q k D k-1 ,k=1, …, j-1andH j =Q j D j-1 . Therefore, C j = S decomposed into several parts by BSd: the low-resolution sample of stock price time series,G 1 =(g 11 ,g 12 ,...,g 1N ) and the details price data sets H k =(h k1 ,h k2 ,...,h kN ), k=1,2,...,j, see Figure 2. Then, we simultaneously use G 1 , and all H k 's, k=1, 2,...,jto design a new structure for every S p , p=1,2,...,P, as the new inputs of BPNN model, as follows: where, , And , k=1, …,j (3.3) and the given target output for every S p is: According to (3.1) and (3.2), the relationship between every output of the network OUTnet p and the input S p in (2.5) is given by: where, W k,p,q 's are the connection weight vectors, each of which has m members relating to kth detail data sets and W 0,p,q 's are the connection weight vectors each of which has m members relating to approximation data sets for the pth input node and the qth neuron in the hidden layer, w 0 is a bias for output neuron, w 0,q is a bias for the qth neuron in the hidden layer, P is the number of input nodes, Q is the number of the hidden neurons, and for the hidden neurons f(x)=(1-e -2x )/(1+e -2x ) is the hyperbolic tangent activation function which is called tansig. A large subset of {(S p ;OUT p ), p = 1, 2,..., P} can be used to train the BPNN for predicting the future price s N+l , for stock price time series. The remaining elements of {(S p ;OUT p ), p = 1, 2,..., P} are used for testing the method. This process is shown in Figure 3.
For instance, in back propagation training method, at the beginning, some arbitrary small values are assigned as the weights and biases. Then they are modified by minimizing the error function by moving in the direction of gradient decent of the activation function. After training the network, the modified weights and biases are calculated. The BPNN is repeatedly simulated for each testing S p input to obtain OUTnet p .  where, and are respectively the actual closing price and the predicted closing price on kth day, and N is number of data. Also L(.)'s which denote the loss functions corresponding to errors are respectively defined by 25 :

Superior Predictive Ability (SPA) Test
The forecasting performances of various predicting models can be assessed in a better way by using the superior predictive ability (SPA) test, instead of the error metric values like MAPE, etc. This test helps to identify, in terms of expected loss, whether any of the competing models, M m , m=1, 2,...,M is better than the benchmark modelM 0 . For this purpose, the null hypothesis, H 0 is specified as: "None of the models is better than the benchmark model", against the alternative one: "Among the competing models at least one is significantly better than the benchmark model".

Experimental Forecasting Results of BSd-BPNN
In this section, firstly, we have selected the daily closing prices of five stock price time series. These are stock prices of TATASTEEL, WIPRO, SBI, TCS, and INFOSYS companies. They have been predicting their future stock prices at 1, 2, and 3 days (l=1D, 2D & 3D) and 1 week (l=1W) ahead, as short-terms forecasting, and at 1 month (l= 1M) ahead, as long-term forecasting. All the historical prices have been downloaded from yahoofinance. com website, which is a standard reference for financial data. We have considered the prices for the time period from Dec 12, 2010 to Dec 12, 2016. In this period, there were about 1500 closing prices, where we have selected 80% of which as the training samples and the rest of them have been used as the testing samples. The learning method is back propagation and the learning rate and the momentum parameter are arbitrarily set to 0.1 and 0.9, respectively. The training of the BPNN will stop when the error MSE(net)becomes less or equal to 0.0001 or when the number of epochs reaches 1000. Secondly, in order to demonstrate the effectiveness of the BSd-BPNN model of different orders (d=1,2,3 and d=4), the models BS1-BPNN, BS2-BPNN, BS3-BPNN, and BS4-BPNN have predicted the above stocks, and the results have been compared to the ones predicted by BPNN model itself via SPA test.
Results of SPA test, which are obtained by loss function MAPE, applied on the BSd-BPNN models for the forecasting of five stock companies are tabulated in Table  1. As it is shown, the ranking of predictive ability (R) for BSd-BPNN models are almost all superior to BPNN model. For example, in the stock price forecasting at l= 1M ahead for INFOSYS stock market, the ranking of BS4-BPNN model is R=1, and the ranking of BS3-BPNN model is R=2, while the ranking of BPNN model is R=3. In summary, percentage of superiorities of these models is as follows: BS3-BPNN model in 36% of cases is able to predict stock prices more accurate than the others. Moreover, BS4-BPNN model in 28%, BS1-BPNN model   (Figure 4 part A).
Results of percentage of SPA test (PSPA) on the BSd-BPNN models for the forecasting of five stock companies are shown in Figure 5. As it is seen, for example, in the stock price forecasting at l= 1W ahead for any stock markets, the PSPA for all models, which have R=1 are as follows: For BPNN model, PSPA is 0%, for BS1-BPNN model, PSPA is 20%, and respectively, for BS2-BPNN, BS3-BPNN, and BS4-BPNN models, the PSPA's are 20%, 40%, 20%, see Figure 4 part B.  Therefore, BS3-BPNN has the highest percentage of superior predictive ability for the stock price forecasting at l= 1W ahead. According to Figure 5, we can arrange the best model for the forecasting of the above stock markets. For the forecasting at l= 1D ahead, the best model is BS1-BPNN model, at l= 2D ahead the best models are BS1-BPNN and BS3-BPNN, at both l= 3D and l= 1W ahead, the best model is BS3-BPNN model, and finally, for the stock price forecasting at l= 1M ahead, the best model is BPNN model for all stocks. Therefore, BS3-BPNN model is more efficient than the others. In order to test the effectiveness of the BS3-BPNN model, this model was also applied for prediction of the above stocks and the performance errors are tabulated in Table 2. Accuracy of     Table 3. As it is shown, the ranking of predictive ability (R) for BS1-BPNN model is almost always superior to the others. For example, in the stock price forecasting at l= 1M ahead for TCS company, the ranking of BS1-BPNN model is R=1, and the ranking of D-Haar-BPNN model is R=2, while the ranking of BPNN model is R=3.
In general, percentage of superior ability for all models are as follows: BS1-BPNN model in 64% of cases is able to predict the future stocks prices more accurate than the others, D-Haar-BPNN model in 12%, and BPNN model only in 24% of cases have better predictive ability than the others. Therefore, BS1-BPNN model has the superior predictive ability than others. In summary, the back propagation neural network for prediction of stock time series is well trained with high accuracy by using all decomposed multiresolution components in the proposed model.
So, according to all tables, the BSd-BPNN model can be employed to predict the stock price time series at short and long-terms with the highest accuracy.

Conclusion
The forecasting accuracy of a model for predicting the behavior of a time series can be improved by preprocessing the original data set, optimizing the model, or both. In the present paper, we have proposed a forecasting model with both improvements. In our proposed model, BSd-BPNN, first the stock price time series is preprocessed by local and smooth BSd. Then, we can design a new structure for the inputs of BPNN. So, B-Spline wavelet transform is remarkable from two aspects: Firstly, because the use of tridiagonal matrices in constructing them, culminates to linear algorithms which increases the efficiency of the model. Secondly, because all decomposed components which are obtained from the BSd are local and smooth, BSd enables us to design a new structure for BPNN inputs which can be explained as an innovative method to prepare continuous samples for the training of ANN models.
Based on practical findings, the BSd-BPNN model can be used as an efficient and innovative model for fore-  Table 3 Continued casting the future stock prices and is applicable even in long-terms. The proposed model can predict future stock prices better than the de-noised based model in nearly 70% cases.