stock volatility forecasting using swarm optimized hybrid network · keywords: flann, hybrid swarm...
TRANSCRIPT
Web Site: www.ijettcs.org Email: [email protected], [email protected] Volume 2, Issue 3, May – June 2013 ISSN 2278-6856
Volume 2, Issue 3 May – June 2013 Page 78
Abstract: Swarm networks are a new class of neural networks which are inspired by swarm intelligence. Swarm intelligence is the property of co-ordinated behaviour seen amongst the social organisms. The simple local interaction of the swarm members results in complex and intelligent global behaviour. This phenomenon is adapted in swarm intelligence so as to solve many problems.This paper presents a comparative study of particle swarm optimization (PSO) based hybrid swarmnet and simple FLANN model. Here both the models are initially trained with LMS algorithm, then with PSO algorithm. The models are forecasting the stock indices of two different datasets i.e. NIFTY and NASDAQ on different time horizons i.e. one day, one week, and one month ahead. The performance is evaluated on the basis of Root Mean Square Error (RMSE) and Mean Absolute Percentage Error (MAPE). It was verified that PSO based hybrid swarmnet performed better in comparison to PSO based FLANN model, simple hybrid model trained with LMS and simple FLANN model trained with LMS. Keywords: FLANN, hybrid swarm net, PSO
1. INTRODUCTION In case of a stock market the shares are issued and traded through exchanges by taking the help of various indices.Stock market constitute an invaluable asset for the economy of any nation. For the long term investors it acts as a door to purchase business which is expected to do well in the near future.As far as the short term investors (traders) are concerned they get a quick profit out of the trading in the stock [1]. As more and more money is being invested, the investors get anxious of the future trends of the stock prices in the market. But the stock price data are very chaotic, nonlinear, and non-seasonal as well as very volatile in nature and political events, internal developments, inflation and exchage rates as well as world events are some of the factors that are responsible for its nonstationary nature. Therefore it has always been remained as a challenge for the common investors, stock buyers/sellers, policy makers, market researchers and capital market role players to gain knowledge about the daily stock market price values.
There are many techniques available to predict the stock prices namely fundamental analysis, technical analysis [9], statistical techniques [2][3]. However these techniques fail to draw out the hidden non-linear patter n of the stock market data. On the other hand neural networks have been found to be successful in discovering the non-linear pattern inside the data and to adopt accordingly[4]. The neural networks after discovering the pattern adjust their weight parameters so as to predict the data one day ahead, one week ahead as well as one month ahead by using different models such as radial basis function neural network(RBFNN),functional link artificial neural network(FLANN)[6] and adaptive neuro fuzzy information system(ANFIS) etc and by using algorithms such as least mean square(LMS)[7][10],recursive least square(RLS) for updating the weights. Many research have been carried out to know whether the neural networks are really capable in handling the nonlinear pattern od the financial time series data [8].Various hybrid models also have been proposed combining statistical techniques with neural networks [5] and combining wavelet transform and fuzzy logic with neural networks [11] .However these techniques are derivative in nature and are most likely to be trapped in local minima. To overcome the above flaw bio-inspired techniques come to picture [12],[22]. The bio inspired computing techniques are optimization methods that have been inspired by social behaviour of the organisms. There has been numerous applications of genetic algorithms to be applied in financial sector[13][14].swarm intelligence is another recent and emerging paradigm in the field of bio inspired computing which mimic the social behaviour of the birds, ants, and fishes to search for their optimum food source.In this regard various applications of ant colony optimization and fish swarm algorithm in the field of finance is also seen [15][16].Particle swarm optimization(pso) is a robust optimization technique that is inspired by self co-ordinated behaviour of birds [17][18]. For predicting various stock indices namely s&p 500 and DJIA particle swarm optimization has been applied and promising results were obtained [19].The pso technique is also
Stock volatility forecasting using Swarm optimized Hybrid Network
Puspanjali Mohapatra1, Soumya Das2, Tapas Kumar Patra3 and Munnangi Anirudh4
1&2Dept of Computer Science and Engineering
IIIT Bhubaneswar 3 Dept of Instrumentation & Electronics Engineering
College of Engineering Technology Bhubaneswar, India
4Dept of Electronics and Telecommunications Engineering IIIT Bhubaneswar
Web Site: www.ijettcs.org Email: [email protected], [email protected] Volume 2, Issue 3, May – June 2013 ISSN 2278-6856
Volume 2, Issue 3 May – June 2013 Page 79
applied along with fuzzy garch models [20] and with neural networks in different models namely radial basis function neural network and adaptive neuro fuzzy information system[21]. This paper is organised as follows: Section 2 discusses the Least Mean Square algorithm; section 3 discusses the particle swarm optimization algorithm. The performance criterion and result analysis are discussed in section 4 and 5 respectively.finally the conclusion is drawn in section 6.
F1(X1)
F 2(X 5 )
X2
X3
X4
X1
X5
f1
Wi
Y11=Functional expansion unit
X5
X1
5
1
5
1
sin
cos
iii
iii
Xw
Xw
Y1= tanh(Y11+ Y12)
X
1
X5
Y12=
xw ii
i
5
1
f2
Wi
Y2=tanh(Y11+Y12)
X5
X1
X1
X5
Y12=
Functional expansion unit
Y11=
5
1
5
1
sin
cos
iii
iii
Xw
Xw
xw ii
i
5
1
Y
Y1
Y2
PSO
ERROR
DESIRED
2. LEAST MEAN SQUARE ALGORITHM (LMS): The least mean square algorithm is an adaptive algorithm which uses gradient based method of steepest descent.it was originally the idea of Widrow Anfhoff in 1959.it is an iterative method which makes successive improvements to the weight vector in the direction of steepest descent which eventually resultsin minimization of the error .from the method of steepest descent the weight updation equation is: W(n+1)=W(n)- Where W (n+1) is the weight corresponding to the( n+1)th iteration and W(n) is the weight corresponding to the nth iteration
g(n) is the gradient vector evaluated in case of LMS algorithm the weight updation equation is done with the help of following equation W(n+1)=W(n)- (2) Disadvantages: The lms algorithm is itarative in nature It involves calculation od complex derivative functions
which make the computation tough Rate of convergence is very low.
In order to overcome these difficulties the optimization techniques are used among which swarm intelligence takes the leading role. 3. PARTICLE SWARM OPTIMIZATION (PSO): Particle swarm optimization is one of the leading optimization methods which is inspired by birds and fishes to exhibit co-ordinated, collective behaviour. It was originally proposed by Eberhart and Kennedy in 1995.Each particle in pso has a position vector as well as a velocity vector represented by Xi=[x1, x2,…… ,xi]T and Vi=[v1,v2,……vi] spread over a D-dimensional search space.for each particle there is a personal best position(pbest) represented as Pb=[pbi,pbi,……,pbi]T. the global best position(gbest) of all particles is determined by taking all pbest into consideration. Given for each particle a position vector, velocity vector, personal best vector as well as global best vector , the velocity vector for the next itearation is calculated. From the recent velocity vector and previous position vector the position vector for the next itearation is calculated. The pseudocode for pso can be written as follows: 1. For each particle Initialize particle END 2. Do For each particle Calculate fitness value If the fitness value is better than the best fitness value (pBest) in history set current value as the new pBest End 3.Choose the particle with the best fitness value of all the particles as the gBest 4. For each particle Calculate particle velocity according equation Vi
t+1=Vit
1U1t(Pbi
t-Xit
2U2t(Gbi
t-Xit) (3)
Pb-particle best (pBest) Gb-global best (gBest) U1, U2 –random values Vi
t+1 - velocity of particle ‘i ‘ at ‘t+1’ iteration Xi
t - position of particle ‘i’ at ‘t’ iteration Update particle position according equation Xi
t+1=xit+Vi
t+1 (4) End While maximum iterations or minimum error criteria is not attained Vi
t+1=Vit
1U1t(Pbi
t-Xit
2U2t(Gbi
t-Xit)
Social component
Cognitive component Inertia
component
Web Site: www.ijettcs.org Email: [email protected], [email protected] Volume 2, Issue 3, May – June 2013 ISSN 2278-6856
Volume 2, Issue 3 May – June 2013 Page 80
The cognitive component corresponds to personal influence which represents the private thinking of the particle himself where as the social component corresponds to social influence representing collaboration among particles. It can be noted here that 1U1 as well as 2U2 corresponds to the randomness of the loop. So these parameters must be carefully chosen to land in a semi-optimal solution. 1 and 2 are the acceleration constants determing the importance of personal best and global best.low values allow particles to roam far from target regions while high values result in abrupt movements. Each acceleration constant is usually taken to be 2.0 for almost all applications. U1 and U2 are two random functions in the range [0, 1]. 4. FLANN FUZZY SYSTEM The FLANN fuzzy hybrid system is responsible for the determination of the knowledge base which consists of the following subsystems of developing the membership function, defining a fuzzy reasoning mechanism, the number of rule and rule base. The proposed FLANN based Neurofuzzy hybrid model uses a FLNN based combination of input variables. Each fuzzy rule corresponds to a sub-FLANN, comprising a link. The FLANN model realizes a fuzzy IF-THEN rule in the following form and the same “P” number of patterns ‘Xp’ is passed through the linear combiner and multiplied with the weight to generate the partial sum. Rule j: IF x1 is A1i and x2 is A2j. . . . . and xi is Aij . . . . . and xN is ANj Then Yi= ) (5) Where xi and Y I are the input and local output variables respectively; Aij is the linguistic term of the precondition part with Gaussian membership function, N is the number of input variables, Wi is the link weight of the local output, k is the basis function of input variables, M is the number of basis function, and rule j is the jth fuzzy rule. The operation of each layer of FLANN fuzzy system is described as follows:Ui denotes the output of lth layer Layer 1: No computation is performed in layer 1. Each node in this layer only transmits input values to the next layer directly. Ui
1=Xi (6) Layer 2: Each fuzzy set Aij is described here by a Gaussian membership function. Therefore, the calculated membership value in layer 2 is
U2ij= (7)
Layer 3: Nodes in layer 3 receive one-dimensional membership degrees of the associated rule from the nodes of a set in layer 2. Here, the product operator described earlier is
adopted to perform the precondition part of the fuzzy rules. As a result, the output function of each inference node is Uj
3= (8) Where of a rule node represents the firing strength of its corresponding rule. Layer 4: Nodes in layer 4 are called consequent nodes. The input to a node in layer 4 is the output from layer 3, and the other inputs are calculated from the FLANN that has used the function tanh ( ), as shown in Fig. 1. For such a node Uj
4= Uj4 (9)
Where the link is weight of FLANN and is the functional expansion of the inputs. Layer 5: The output layer in node 5 acts as the defuzzification layer. So, the final output of the FLANN model ‘y’ is expressed as
(10) y=
Where y11 and y22 are the output from the FLANN model and Fz11 and Fz22 are the output from the NeuroFuzzy hybrid model or output from layer 3. 5. SIMULATION STUDY 5.1 Dataset for training and testing: The daily closing price of NIFTY data and NASDAQ data from 01.03.2009 to 11.05.2012 is taken as training samples(approximately 1500 samples).All the inputs are normalized within a range of [0, 1] using the following formula.
(11)
Where Xnorm is the normalised value, Xorig is the actual currency value, Xmax is the maximum value and Xmin is the minimum value. 5.2 Training and testing of the forecasting model: Training of the FLANN model is carried out using the DE and PSO algorithm given in Section 3 and 4 and the optimum weights are obtained. Then using the trained model, the forecasting performance is tested using test patterns for one-day, one week and one-month ahead. MAPE and RMSE (as defined in table 1) is computed to compare the performance of various models.
Table 1: Performance evaluation criteria Evaluation
criteria Formula used
FFFyFy
zz
zz
2211
22221111
Web Site: www.ijettcs.org Email: [email protected], [email protected] Volume 2, Issue 3, May – June 2013 ISSN 2278-6856
Volume 2, Issue 3 May – June 2013 Page 81
Root mean square error(RMSE)
Mean
absolute percentage error(MAPE)
Using the training sample first a FLANN based LMS model is implemented and the actual and forecasted stock prices are compared.Then a PSO based FLANN model is implementedRoot mean square error (RMSE) and Mean absolute percentage error (MAPE) are considered for performance evaluation. The results of nifty dataset and NASDAQ dataset are listed in table-2 and table-3.
0 50 100 150 200 250 300 350 400 450 5000
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9target&predicted of training
actualforecasted
Figure 2: one day ahead actual versus predicted values of
stock indices for nifty data set during training using FLANN PSO model
0 50 100 150 200 2500
0.1
0.2
0.3
0.4
0.5
0.6
0.7target&predicted of testing
actualforecasted
Figure 3: one day ahead actual versus predicted values of
stock indices for nifty data set during testing using FLANN PSO model
0 100 200 300 400 500 6000
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
no.of data samples
actual versus predicted during training
data1data2
Figure 4: one day ahead actual versus predicted values of stock indices for NASDAQ data set during training using
FLANN LMS model
0 100 200 300 400 500 6000
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
no.of data samples
actual versus predicted during training
data1data2
Figure 5: one week ahead actual versus predicted values of stock indices for NASDAQ data set during training and testing for nifty dataset using FLANN LMS model
0 100 200 300 400 500 6000
0.02
0.04
0.06
0.08
0.1
0.12
no of data samples
error during training
Figure 6:error value in one month ahaead forecast using
NASDAQ data set
Web Site: www.ijettcs.org Email: [email protected], [email protected] Volume 2, Issue 3, May – June 2013 ISSN 2278-6856
Volume 2, Issue 3 May – June 2013 Page 82
0 100 200 300 400 500 6000
0.5
1
1.5
2
2.5mape value during testing
Figure 7: mape value in one month ahaead forecast using
NASDAQ data set
0 200 400 600 800 1000 1200 14000
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1Actual Vs Predicted during training
No of iterations
predictedac tual
Figure 8:actual versus predicted values of 1 week ahead stock indices for nifty data set during training and testing
using FLANN-fuzzy PSO model
0 100 200 300 400 500 6000.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1Actual Vs Predicted during testing
No of iterations
predictedac tual
Figure 9: actual versus predicted values of one week
ahead stock indices for nifty data set during training and testing using FLANN-fuzzy model
0 50 100 150 200 250 3000
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9target&predicted of testing
actualforecasted
Figure 10: actual versus predicted values of one week ahead stock indices for nifty data set during training and
testing using FLANN-LMS
0 50 100 150 200 250 3000.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1target&predicted of testing
actualforecasted
Figure 11: actual versus predicted values of one month
ahead stock indices for nifty data set during training and testing using FLANN fuzzy PSO model
0 50 100 150 200 250 300 350 400 450 5000
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9target&predicted of training
actualforecasted
Figure 12: actual versus predicted values of one month ahead stock indices for nifty data set during training and
testing using FLANN fuzzy PSO model
Web Site: www.ijettcs.org Email: [email protected], [email protected] Volume 2, Issue 3, May – June 2013 ISSN 2278-6856
Volume 2, Issue 3 May – June 2013 Page 83
0 50 100 150 200 250 3000
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9target&predicted of testing
actualforecasted
Figure 13: actual versus predicted values of one month
ahead stock indices for nifty data set during training and testing using FLANN fuzzy PSO model
0 10 20 30 40 50 60 70 80 90 1000
0.01
0.02
0.03
0.04
0.05
0.06
0.07MSE curve during training
No of iterations Figure 14: MAPE values of one month ahead stock
indices for nifty data set during training and testing using FLANN fuzzy PSO model
0 10 20 30 40 50 60 70 80 90 1000
0.02
0.04
0.06
0.08
0.1
0.12
0.14MSE curve during training
No of iterations
Figure 15: MSE values of one month ahead stock indices for nifty data set during training and testing using
FLANN fuzzy PSO model
0 100 200 300 400 500 6000
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
Figure 16: actual versus predicted values of one month ahead stock indices for nifty data set during training and
testing using FLANN fuzzy model
0 50 100 150 200 250 3000.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
Figure 17: actual versus predicted values of one month
ahead stock indices for nifty data set during training and testing using FLANN fuzzy model.
Table 2: Details of NIFTY dataset
Web Site: www.ijettcs.org Email: [email protected], [email protected] Volume 2, Issue 3, May – June 2013 ISSN 2278-6856
Volume 2, Issue 3 May – June 2013 Page 84
Table 3: Details of NASDAQ dataset
6. CONCLUSION Stock indices are highly non-linear, chaotic and volatile in nature. Predicting the stock prices accurately have always been remained a mystery to the mankind.In this paper first a simple FLANN model is getting trained with LMS. In order to overcome the limitations of neural nets, fuzzy logic was integrated to form the hybrid network .The performance of hybrid network is determined using LMS.However the derivative free training algorithms like GA,PSO are making the computation faster,simpler and better in comparison to the traditional derivative based LMS method. Finally pso based FLANN fuzzy hybrid network is predicting the stock prices very accurately .For further work this hybrid network is to be combined with other derivative free training algorithms like BFO, ACO etc. REFERENCES [1] ser-huang poon and Clive w. J. Granger, “Forecasting
Volatility in Financial Markets: A Review”, Journal of Economic Literature, Vol. XLI, June 2003, pp: 478–539.
[2] Chand Sohail et al, “Modeling and Volatility Analysis of Share Prices Using ARCH and GARCH Models”, World Applied Sciences Journal, pp: 77-82, 2012.
[3] John J. Sparks and Yuliya V. Yurova, “Comparative Performance of ARIMA and ARCH/GARCH Models on Time Series of Daily Equity Prices for Large Companies”,
Department of Information and Decision Sciences University of Illinois at Chicago, pp: 563-573.
[4] Adya M and Fred Collopy, “How Effective are Neural Networks at Forecasting and Prediction? A Review and Evaluation”, Journal of Forecasting J. Forecast. 17, pp: 481-495, (1998).
[5] Jung Hua Wang and Jia Wan Leu, “Stock market trend prediction using ARIMA based neural networks”,IEEE, 1996,pp-2160-2166
[6] Kumaran Kumar. J, Kailas, “A Prediction of Future Stock Close Price using Proposed Hybrid ANN Model of Functional Link Fuzzy Logic Neural Model” IAES International Journal of Artificial Intelligence (IJ-AI) Vol. 1, No. 1, March 2012, pp. 25-30 ISSN: 2252-8938.
[7] Feng Li, Cheng Liu, “Application Study of BP Neural Network on Stock Market Prediction” Ninth International Conference on Hybrid Intelligent Systems,IEEE computer society,2009,pp:174-179.
[8] Dase R.K. and Pawar D.D, “Application of Artificial Neural Network for stock market predictions: A Review of literature”, International Journal of Machine Intelligence, ISSN: 0975–2927, Volume 2, Issue 2, 2010, pp-14-17.
[9] A.A. Adebiyi, 1C.K. Ayo, 1M.O Adebiyi, and 2S.O. Otokiti, “An Improved Stock Price Prediction using Hybrid Market Indicators”,African Journal of Computing & ICT, IEEE, Vol 5. No. 5, Sept 2012, pp: 124-135.
[10] “Single Layer Perceptrons Least-Mean-Square Algorithm Perceptron” Neural Networks and Learning Machines, Third Edition Simon Haykin, PEARSON.
[11] Nassim Homayouni and Ali Amiri,“Stock price prediction using a fusion model of wavelet, fuzzy logic and ANN”, International Conference on E-business, Management and Economics IPEDR Vol.25 (2011) © (2011) IACSIT Press, Singapore, pp: 277-282.
[12] Mohanty D,Nayak S,K R,Rout P, “Comparative study of five bio-inspired evolutionary optimization techniques for various engineering application”,National conference on advances in computational intelligence application in power,control,signal processing and telecommunications(NCACI).
[13] Kyoung-jae Kim, Ingoo Han, “Genetic algorithm approach to feature discreetization in artificial neural networks for prediction of stock price index” Expert systems with applications,2009, ELSEVIER, 125-132
[14] Efstathios Kalyvas “Using neural networks and genetic Algorithms to predict stock market returns”, a thesis submitted to the university of manchester For the degree of master of science In advanced computer science In the faculty of science and engineering,2001.
[15] W. Gao, “New Neural Network Based on Ant Colony Algorithm for Financial Data Forecasting,International Conference on Intelligent Information Hiding and Multimedia Signal Processing” ,IEEE computer society,2008.
[16] Wei Shen et al “forecasting stock indices using radial basis function neural networks optimized by artificial fish swarm algorithm”, knowledge based systems,ELSEVIER,2011,pp:378-385
[17] Satyobroto Talukder, “Mathematical Modelling and Applications of Particle Swarm Optimization”, Master’s Thesis Mathematical Modelling and Simulation Thesis no: 2010:8
[18] Dian Palupi Rini et al, “Particle Swarm Optimization: Technique, System and Challenges”, International Journal
Web Site: www.ijettcs.org Email: [email protected], [email protected] Volume 2, Issue 3, May – June 2013 ISSN 2278-6856
Volume 2, Issue 3 May – June 2013 Page 85
of Computer Applications (0975 – 8887) Volume 14– No.1, January 2011.
[19] Majhi Ritanjali, Panda G, Panda Abhisek, Choubey Arvind, “Prediction of S&P500 and DJIA stock indices using particle swarm optimization Technique” , 978-1-4244-1823-7/08 ,IEEE.
[20] Jui Chang Hung, “Adaptive Fuzzy-GARCH model applied to forecasting the volatility of stock markets using particle swarm optimization”, journal of Information Science,2011, pp:4673-4683.
[21] Puspanjali Mohapatra, Munnangi Anirdh, Tapas Kumar Patra,“Forex Forecasting: A Comparative Study of LLWNN and NeuroFuzzy Hybrid Model”, International Journal of Computer Applications (0975 – 8887) Volume 66– No.18, March 2013.
[22] Puspanjali Mohapatra, Soumya Das, “stock market prediction using bio-inspired computing:a survey”, International Journal of Engineering Science and Technology (IJEST), Vol. 5 No.04 April 2013,pp:739-746.
AUTHOR
Puspanjali Mohapatra received the B.E in Electrical Engineering from IGIT Sarang, M.Tech in Computer Science from Utkal University in 1999 and 2002 respectively.Since April 2003; she has been in teaching profession. Currently she is working as an Asst.Prof.in
CSE department of IIIT Bhubaneswar. She has proposed many papers in national and international, conference in the area of Time Series data mining using Soft Computing Techniques.
Soumya Das received her B.Tech degree in CSE from BPUT, Odisha, India in 2011.Currently she is pursuing M.Tech in IIIT Bhubaneswar under the department of computer science engineering.Her primary research interest are neural networks,soft computing techniques. Tapas Kumar Patra has a B.E. in Electronics and Telecommun ication engineering from Sambalpur University. He passed M.E.From NIT, Rourkela in 1993. He is pursuing PhD in Centre for Electronics Design and Technology at Indian Institute of Science,
Bangalore.. His research interests include wireless mobile network, sensor network, modeling, analysis and control of stochastic systems, soft computing techniques
Munnangi Anirudh is a B.Tech student in IIIT Bhubaneswar under the department of Electronics and Telecommunications Engineering.His primary research interests are neural networks, fuzzy logic and Soft computing techniques.