Predicting Closing Stock Price using Artificial Neural ... - CiteSeerX

0 downloads 0 Views 457KB Size Report
Computer Science, Machine Learning. Keywords. Artificial Neural Network (ANN), Adaptive Neuro-Fuzzy Infer- ence System (Anfis), Stock prediction, DSE, ...
International Journal of Computer Applications (0975 - 8887) Volume 129 - No.11, November 2015

Predicting Closing Stock Price using Artificial Neural Network and Adaptive Neuro Fuzzy Inference System (ANFIS): The Case of the Dhaka Stock Exchange

Mustain Billah

Sajjad Waheed

Department of Information And Communication Technology Mawlana Bhashani Science And Technology University Tangail, Bangladesh

Department of Information And Communication Technology Mawlana Bhashani Science And Technology University Tangail, Bangladesh

Abu Hanifa Department of Information And Communication Technology Mawlana Bhashani Science And Technology University Tangail, Bangladesh

ABSTRACT Stock market prediction plays a vital rule in taking financial decisions. Various factors affecting the stock market makes stock prediction somewhat complex and difficult. Different data mining techniques such as Artificial Neural Network (ANN), Adaptive Neuro-Fuzzy Inference System (ANFIS) etc are being widely used for predicting stock prices of different stock exchange cases. But there is no good work on stock prediction using ANN and ANFIS for Bangladesh Stock Markets. The goal of this paper is to find out an efficient soft computing technique for Dhaka Stock Exchange (DSE) closing data prediction. In this paper, ANN and ANFIS have been applied on different companies previous data such as opening price, highest price, lowest price, total share traded. The day end closing price of stock is the outcome of ANN and ANFIS model. Our experiment shows that, ANFIS is more effective and efficient technique to predict Dhaka Stock exchange (DSE) data.

General Terms Computer Science, Machine Learning

Keywords Artificial Neural Network (ANN), Adaptive Neuro-Fuzzy Inference System (Anfis), Stock prediction, DSE, Grameenphone

1.

In the past, people who invested in stock markets used to take decicions just on assumptions. As the more and more investment started to come in, it became necessary to find out a tool that could predict stock market trends correctly. However, it was very difficult to predict the stock price trends[18] efficiently because many factors such as economics, politics, environment etc were deciding parameters. For many years, traditional statistical prediction [19, 4] methods such as linear regression, time series analysis, chaos theory were popular. But for the uncertainity in stock market[2], these methods were failure or partially successfull. Soft computing techniques such as neural network[10, 3, 17], fuzzy systems[16] have been applied to solve this problem as they capture the non-linearity of stock market[1]. Neural netork has the ability to adust itself according to the given information. On the other hand, fuzzy can handle uncertainity well. ANFIS[12] has covered both advantages of neural network and fuzzy. ANFIS have been used for prediction purposes in many areas[13, 20, 14, 15]. The goal of this paper is to findout a prediction system for Dhaka Stock Exchange (DSE)[6] that can predict closing stock price precisely. Different company’s last three years data have been used for both artificial neural network (ANN) and adaptive neuro-fuzzy inference system (ANFIS). ANFIS has shown more accuracy than ANN for predicting Dhaka Stock Exchange closing price.

INTRODUCTION

Stock markets are one of the important part of the economy of a country. Actually it’s the most important way for the companies to raise capital. Not only the investors but also the common peoples are also finding it as an investment tool. As stock market influences individual and national economy heavily, it is so much necessary to predict the future values of stock market to take the correct decision whether to buy or sell the share[8].

2.

RELATED WORKS

Many works have been done on stock prediction using ann and anfis. [5] proposes an adaptive network based fuzzy inference system to predict stock market data. In this paper, they have proved the proficiency of anfis for stock prediction. They have used six macronomic variables and three indices as input variables. [11] proposes an integrated system in combination of wavelet transform and recurrent neural network based on artificial bee colony algorithm.

1

International Journal of Computer Applications (0975 - 8887) Volume 129 - No.11, November 2015 [7] presents a three stage stock market prediction system. They have applied multiple regression to define ecoomic and financial variables. Differential evolution based type-2 fuzzy clustering has been used to create a prediction model. Then a fuzzy type-2 Neural networkis used to perform the reasoning for future stock price prediction [9] used linear regression approach to predict stock price. [3] showed a method for predicting the Istambul Stock Exchange (ISE) market index value using ANN. MultiLayer percepton and geeralized Feed Foward Networkare included and comparison was made between them.

3.

THEORY OF ANN

Elements operating in parallel form a neural network. These elements work like the biological nervous systems. The connections between elements determine the network function. Neural network can be trained to perform a particular function by adjusting the values of the connections (weights) between elements. Following figure shows a typical neuron structure:

4.

ANFIS

ANFIS derives its name from adaptive neuro-fuzzy inference system.It works similarly to that of neural networks. Using a given input/output data set, ANFIS constructs a fuzzy inference system (FIS) whose membership function parameters are tuned (adjusted) using either a backpropagation algorithm alone or in combination with a least squares type of method. This adjustment allows the fuzzy systems to learn from the data they are modeling. Assume that the fuzzy inference system has two inputs x and y and one output z. A first-order Sugeno fuzzy model has rules as the following: Rule1: If x is A1 and y is B1 , then f1 = p1 x + q1 y + r1 Rule2: If x is A2 and y is B2 , then f2 = p2 x + q2 y + r2 Here, output =

w1.f 1 + w2.f 2 w1 + w2

(1)

Fig. 1. Typical Neuron in a neural network system

This neuron contains an input layer, a hidden layer and an output layer. Input xj is multiplied by it’s weight wij giving a product xj wij . The transfer function is applied on this product giving an output yi which can be represented by : I = index of neurons in the hidden layer. j = index of an input to the neural network. To make a particular input to lead to a specific target output, neural networks are adjusted or trained. The network is adjusted, based on a comparison of the output and the target, until the network output matches the target. Typically, many such input/target pairs are needed to train a network.

Fig. 3. sugeno model

Infact, ANFIS is the combination of both ANN fuzzy logic.ANN algorithms are also used for anfis training,learning

5. 5.1

After the artificial neural network has been trained wirh known values, it can perform decision making now.

Data set

Five largest companies data have been collected from Dhaka Stock Exchange (DSE) covering the period from January 2013 to april 2015. The data set contains daily opening price (BDT), closing price (BDT), highest price (BDT), lowest price (BDT) and total number of share traded (no.). It consists of about more than 600 data sets. After collecting, all data are preprocessed and incorrect data are cleaned. Total data set was divided into two groups. The training data set was used for training ANN and ANFIS the network to find out the best network. It consists of about more than 500 data from January 2013 to January 2015. The testing data contains about 30 data set from February 2015 to april 2015 which evaluates the trained network. Table 1 contains the list of selected companies and variables.

5.2 Fig. 2. ANN working principle

METHODS AND STRUCTURE

Experimental structure of ANN

Neural Network tool of MATLAB 2015a was used for developing the ANN model. Determining the number of hidden layer is the most important part of ANN model as the model’s complexity and accuracy depends on it. Again input weight and bias should also be considered while training. In this paper, ANN have been trained

2

International Journal of Computer Applications (0975 - 8887) Volume 129 - No.11, November 2015 Table 1. Data Set Selected Companies of DSE Beximco Dutch Bangla Bank Grameenphone RAK ceramic SingerBD

Selected variables Opening price Highest price Lowest price Total share traded Closing price

with different number of hidden nodes number and for each node number experiments were done with different weights and bias at least ten times untill minimum error. Different companies have different data set property. For this reason, 10 neurons are used in the hidden layer for some companies data and 7 neuron for some companies data. Linear transfer function was used for both input and output layer and tangent sigmoid function for the hidden layers. Here is the structure and the MATLAB representation of ANN.

The RMSE is defined as:

r Pn RM SE =

n=1

(y predicted − y actual )2 n

(2)

The R2 is defined as:

Pn (y − y actual )2 n=1 predicted R =1− P n 2

n=1

(y actual − y mean )

(3)

Here, n is the total data sample, ypredicted is the predicted value and ymean is the average value of actual output, yactual is the actual output. RMSE values nearer to 0 predicts less error and R2 values nearer to 1 indicates higher correlation.

6. 6.1

RESULT AND DISCUSSIONS Beximco Data Set

7 nodes have been used for training ANN. After training with different weights and bias the best result was found. On the other hand, to get least error we trained ANFIS with three gbell membership function for each input variable and constant membership function for output variable. The testing data set result is as below: Fig. 4. Final neural network architechture

Table 2. ANN and ANFIS test result

5.3

Experimental structure of ANFIS

Variation in ANFIS membership function brings variation in Anfis result. So to model a system with less error it is necessarry to choose the correct membership function and their number. For this purpose, different membership are selected for diffrent input. For example, four gbell membership are used for four input variable and constant membership function for output variable for a company.

RMSE R2

ANN 0.366 0.992069

ANFIS 0.28 0.994027

Following figure shows comparison among closing price, ANN and anfis outcome.

Fig. 6. Beximco Closing price vs ANN output vs ANFIS

Fig. 5. Proposed ANFIS structure

For Beximco data set, proposed ANFIS has less RMSE value than ANN. Again, higher R2 value shows that ANFIS can better predict Beximco closing stock price.

6.2 5.4

Performance measurement techniques

Numerous statistical methods are used for measuring the accuracy and peformance of prediction models.In this study, we have used root mesn square eror (RM SE) and the coefficient of multiple determinations (R2 ) to compare predicted and actual values.

DBBL Data Set

The best result for Dutch Bangla Bank Limited (DBBL) found using 10 node in ANN. Two trapezoidal MF for each input variable and linear MF for output variable give the best result for ANFIS. Following figure and table show comparison among closing price, ANN and anfis outcome.

3

International Journal of Computer Applications (0975 - 8887) Volume 129 - No.11, November 2015 Table 3. Dutch Bangla Bank ANN and ANFIS test result RMSE R2

ANN 2.2313 0.797797

ANFIS 1.27 0.946713

6.4

RAK CERAMIC Data Set

RAK ceramic dataset finally results in a formation of 7 nodes in ANN and 3 3 3 3 configuration of gbell MF for input and constant MF for output variable. The testing data set result was found as below: Table 5. RAK ceramic ANN and ANFIS test result ANN 0.4559 0.988

RMSE R2

ANFIS 0.39 0.990447

Following figure shows comparison among closing price, ANN and anfis outcome. Fig. 7. Dutch Bangla actual, ANN, ANFIS outcome

ANFIS has so much less error compared to ANN. Again it’s R2 value is higher than ANN which indicates higher correlation with the actual outcome.

6.3

Grameenphone Data Set

For Grameenphone data set, ANN is trained with 10 nodes in the hidden layer. ANFIS has better performance using 4 2 2 2 configuration of triangular MF for four input and constant MF for output variables. The testing data set result was found as below:

Table 4. Grameenphone ANN and ANFIS test result RMSE R2

ANN 1.881 0.985

ANFIS 1.86 0.98116

Following figure shows comparison among closing price, ANN and anfis outcome.

Fig. 9. RAK Ceramic actual, ANN, ANFIS outcome

Higher R2 and lower RMSE value of ANFIS has proved itself to be efficient system to predict stock market data of RAK ceramic company.

6.5

SingerBD Data Set

Repeating with differenmt nodes and weights and bias best result is found using 10 node in ANN and 4 2 2 3 configuration of gbell MF in input and constant MF for output variables in ANFIS. The testing data set result was found as below: Table 6. SingerBD ANN and ANFIS test result RMSE R2

ANN 1.162 0.996637

ANFIS 0.99305 0.997577

Fig. 8. Grameenphone actual, ANN, ANFIS outcome

Comparing the results, it is found that, though ANN shows somewhat better correlation with actual outcome than ANFIS, ANFIS has less RMSE value indicating lower error and better performance.

Fig. 10. SingerBD actual, ANN, ANFIS outcome

4

International Journal of Computer Applications (0975 - 8887) Volume 129 - No.11, November 2015 For the case of Singerbd company, ANfis shows better performance with less error and higher R2 value than ANN.

7.

CONCLUSION

This paper makes a comparison between artificial neural network and adaptive neuro fuzzy inference system and proppose a system for predicting closing price of Dhaka Stock Exchange (DSE) data. Five major companies historical stock data have been used.Our analysis shows that, ANFIS has less error than ANN and higher R2 value indicating strong correlation with output. So now we can say that, ANFIS can be used to predict one day ahead closing price of stock market providing previous historical data. In future, we will work on disease diagnosis using ANFIS and ANN.

8.

[16] Bart Kosko. Neural networks and fuzzy systems: a dynamical systems approach to machine intelligence/book and disk. [17] Jibendu Kumar Mantri, P. Gahan, and Braja B. Nayak. Artificial neural networksan application to stock market volatility. page 179. [18] David G. McMillan. Stock return, dividend growth and consumption growth predictability across markets and time: Implications for stock price movement. 35:90–101. [19] M. Hashem Pesaran and Allan Timmermann. Predictability of stock returns: Robustness and economic significance. 50(4):1201–1228. [20] Han Yan, Zhihong Zou, and Huiwen Wang. Adaptive neuro fuzzy inference system for classification of water quality status. 22(12):1891–1896.

REFERENCES

[1] Reza Gharoie Ahangar, Mahmood Yahyazadehfar, and Hassan Pournaghshband. The comparison of methods artificial neural network with linear regression using specific variables for prediction stock price in tehran stock exchange. [2] Doron Avramov. Stock return predictability and model uncertainty. 64(3):423–458. [3] Asst Birgul Egeli. Stock market prediction using artificial neural networks. 22:171–185. [4] Johan Bollen, Huina Mao, and Xiaojun Zeng. Twitter mood predicts the stock market. 2(1):1–8. [5] Melek Acar Boyacioglu and Derya Avci. An adaptive network-based fuzzy inference system (ANFIS) for the prediction of stock market return: the case of the istanbul stock exchange. 37(12):7908–7912. [6] Abdur R. Chowdhury. Statistical properties of daily returns from the dhaka stock exchange. pages 61–76. [7] David Enke, Manfred Grauer, and Nijat Mehdiyev. Stock market prediction with multiple regression, fuzzy type-2 clustering and neural networks. 6:201–206. [8] Eugene F. Fama and Kenneth R. French. Common risk factors in the returns on stocks and bonds. 33(1):3–56. [9] Farhad Soleimanian Gharehchopogh, Tahmineh Haddadi Bonab, and Seyyed Reza Khaze. ALinear REGRESSION APPROACH TO PREDICTION OF STOCK MARKET TRADING VOLUME: ACase STUDY. 4. [10] Martin T. Hagan, Howard B. Demuth, Mark H. Beale, and others. Neural network design. Pws Pub. Boston. [11] Tsung-Jung Hsieh, Hsiao-Fen Hsiao, and Wei-Chang Yeh. Forecasting stock markets using wavelet transforms and recurrent neural networks: An integrated system based on artificial bee colony algorithm. 11(2):2510–2525. [12] Jyh-Shing Roger Jang. ANFIS: adaptive-network-based fuzzy inference system. 23(3):665–685. [13] Jyh-Shing Roger Jang. Input selection for ANFIS learning. In Proceedings of the fifth IEEE international conference on fuzzy systems, volume 2, pages 1493–1499. Citeseer. [14] Gurbinder Kaur, Joydip Dhar, and Rangan K. Guha. Stock market forecasting using ANFIS with OWA operator. 12(2):102–114. [15] Gurbinder Kaur, Joydip Dhar, and Rangan K. Guha. STOCK MARKET PREDICTION FROM SECTORAL INDICES USING AN ADAPTIVE NETWORK BASED FUZZY INFERENCE SYSTEM. 4(2):74.

5