You are on page 1of 8

Web Site: www.ijettcs.org Email: editor@ijettcs.org, editorijettcs@gmail.

com Volume 2, Issue 3, May June 2013 ISSN 2278-6856

Stock volatility forecasting using Swarm optimized Hybrid Network


Puspanjali Mohapatra1, Soumya Das2, Tapas Kumar Patra3 and Munnangi Anirudh4
1&2

Dept of Computer Science and Engineering IIIT Bhubaneswar

Dept of Instrumentation & Electronics Engineering College of Engineering Technology Bhubaneswar, India

Dept of Electronics and Telecommunications Engineering IIIT Bhubaneswar

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 nonseasonal 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. Volume 2, Issue 3 May June 2013

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 coordinated 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 Page 78

Web Site: www.ijettcs.org Email: editor@ijettcs.org, editorijettcs@gmail.com Volume 2, Issue 3, May June 2013 ISSN 2278-6856
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.
X1
Functio nal expansi on unit

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 t t t Vit+1=Vit 1U1t(Pbit-Xit (3) 2U2 (Gbi -Xi ) Pb-particle best (pBest) Gb-global best (gBest) U1 , U2 random values Vit+1 - velocity of particle i at t+1 iteration Xit - position of particle i at t iteration Update particle position according equation Xit+1 =xit+Vit+1

Wi

Y11=
5 i1 5

wcos X
i

X5 X
1

wsin X
i i1

Y12=
5 i1

Y 1=tanh(Y11 +Y12)
i

X5 F1(X1) X1

wx
i

f1

X2

Y1

DESIRED

X3

Y
X4 X5
f2

ERROR

X1

F 2(X 5 )
Functi onal expans ion unit

Wi

Y 11=
5

Y2
i

wcos X
i i1 5 i1

X5 X1

wsin X
i

Y12=

Y2=tanh(Y11+ Y12)
i

PSO

X5

i1

wx
i

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.

(4)

End While maximum iterations or minimum error criteria is not attained

Vit+1=Vit
Inertia component

U1t(Pbit-Xit
Cognitive component

U2t(Gbit-Xit)
Social component

Volume 2, Issue 3 May June 2013

Page 79

Web Site: www.ijettcs.org Email: editor@ijettcs.org, editorijettcs@gmail.com Volume 2, Issue 3, May June 2013 ISSN 2278-6856
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

adopted to perform the precondition part of the fuzzy rules. As a result, the output function of each inference node is

Uj3=
Where strength of its corresponding rule.

(8)
of a rule node represents the firing

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 random functions in the range [0, 1].

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

U2 are two

Uj4= Uj4
Where the link is weight of FLANN and functional expansion of the inputs.

(9)
is the

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 5: The output layer in node 5 acts as the defuzzification layer. So, the final output of the FLANN model y is expressed as
y=

y F F
11

z11 z11

y F F
22 z 22

z 22

(10)

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

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 Volume 2, Issue 3 May June 2013

Page 80

Web Site: www.ijettcs.org Email: editor@ijettcs.org, editorijettcs@gmail.com Volume 2, Issue 3, May June 2013 ISSN 2278-6856
Root mean square error(RMSE) Mean absolute percentage error(MAPE)

actual versus predicted during training 1 0.9 0.8 0.7 0.6 0.5 0.4 data1 data2

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.
target&predicted of training 0.9 0.8 0.7 actual forecasted

0.3 0.2 0.1 0

100

200

300 400 no.of data samples

500

600

Figure 4: one day ahead actual versus predicted values of stock indices for NASDAQ data set during training using FLANN LMS model

actual versus predicted during training 1 data1 data2

0.6

0.9
0.5

0.8
0.4

0.7
0.3 0.2 0.1 0

0.6 0.5 0.4


0 50 100 150 200 250 300 350 400 450 500

0.3 0.2

Figure 2: one day ahead actual versus predicted values of stock indices for nifty data set during training using FLANN PSO model
target&predicted of testing 0.7 actual forecasted

0.1 0

100

200

300 400 no.of data samples

500

600

0.6

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
error during training 0.12

0.5

0.4

0.1

0.3

0.08

0.2

0.06

0.1

0.04

50

100

150

200

250

0.02

Figure 3: one day ahead actual versus predicted values of stock indices for nifty data set during testing using FLANN PSO model

100

200

300 400 no of data samples

500

600

Figure 6:error value in one month ahaead forecast using NASDAQ data set

Volume 2, Issue 3 May June 2013

Page 81

Web Site: www.ijettcs.org Email: editor@ijettcs.org, editorijettcs@gmail.com Volume 2, Issue 3, May June 2013 ISSN 2278-6856
mape value during testing 2.5

target&predicted of testing 0.9 0.8 actual forecasted

0.7 0.6
1.5

0.5
1

0.4 0.3

0.5

0.2 0.1

100

200

300

400

500

600

50

100

150

200

250

300

Figure 7: mape value in one month ahaead forecast using NASDAQ data set
Actual Vs Predicted during training 1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 predicted ac tual

Figure 10: actual versus predicted values of one week ahead stock indices for nifty data set during training and testing using FLANN-LMS

target&predicted of testing 1 actual 0.9 0.8 0.7 0.6 0.5 forecasted

200

400

600 800 No of iterations

1000

1200

1400

0.4 0.3

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
Actual Vs Predicted during testing 1 0.9 0.8 0.7 predicted ac tual

0.2

50

100

150

200

250

300

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
target&predicted of training 0.9 0.8 0.7 0.6 0.5 actual forecasted

0.6 0.5 0.4

0.4 0.3 0.2 0.1

0.3 0.2

50

100

150

200

250

300

350

400

450

500

100

200

300 No of iterations

400

500

600

Figure 9: actual versus predicted values of one week ahead stock indices for nifty data set during training and testing using FLANN-fuzzy model

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

Volume 2, Issue 3 May June 2013

Page 82

Web Site: www.ijettcs.org Email: editor@ijettcs.org, editorijettcs@gmail.com Volume 2, Issue 3, May June 2013 ISSN 2278-6856
target&predicted of testing 0.9 0.8 0.7 0.6
0.6 1

actual forec asted

0.9 0.8 0.7

0.5
0.5

0.4 0.3 0.2 0.1 0

0.4 0.3 0.2 0.1 0

100

200

300

400

500

600

50

100

150

200

250

300

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
MSE curve during training 0. 07

Figure 16: actual versus predicted values of one month ahead stock indices for nifty data set during training and testing using FLANN fuzzy model
1 0.9 0.8

0. 06

0. 05

0.7 0.6 0.5

0. 04

0. 03

0.4

0. 02

0.3 0.2

50

100

150

200

250

300

0. 01

10

20

30

40 50 60 No of iterations

70

80

90

100

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

Figure 14: MAPE values of one month ahead stock indices for nifty data set during training and testing using FLANN fuzzy PSO model
MSE curve during training 0. 14

0. 12

0.1

0. 08

0. 06

0. 04

0. 02

10

20

30

40 50 60 No of iterations

70

80

90

100

Figure 15: MSE values of one month ahead stock indices for nifty data set during training and testing using FLANN fuzzy PSO model

Volume 2, Issue 3 May June 2013

Page 83

Web Site: www.ijettcs.org Email: editor@ijettcs.org, editorijettcs@gmail.com Volume 2, Issue 3, May June 2013 ISSN 2278-6856
Table 3: Details of NASDAQ dataset
[4] Department of Information and Decision Sciences University of Illinois at Chicago, pp: 563-573. 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). Jung Hua Wang and Jia Wan Leu, Stock market trend prediction using ARIMA based neural networks,IEEE, 1996,pp-2160-2166 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. 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. 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: 09752927, Volume 2, Issue 2, 2010, pp-14-17. 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. Single Layer Perceptrons Least-Mean-Square Algorithm Perceptron Neural Networks and Learning Machines, Third Edition Simon Haykin, PEARSON. 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. 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). 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 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. 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. 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 Satyobroto Talukder, Mathematical Modelling and Applications of Particle Swarm Optimization, Masters Thesis Mathematical Modelling and Simulation Thesis no: 2010:8 Dian Palupi Rini et al, Particle Swarm Optimization: Technique, System and Challenges, International Journal

[5]

[6]

[7]

[8]

[9]

[10]

[11]

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.

[12]

[13]

[14]

[15]

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: 478539. [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, [16]

[17]

[18]

Volume 2, Issue 3 May June 2013

Page 84

Web Site: www.ijettcs.org Email: editor@ijettcs.org, editorijettcs@gmail.com Volume 2, Issue 3, May June 2013 ISSN 2278-6856
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-14244-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.

Volume 2, Issue 3 May June 2013

Page 85

You might also like