0% found this document useful (0 votes)
3 views

CISIM2010

This paper explores the use of neural networks, specifically feed forward multi-layer Perceptrons (MLP) and Elman recurrent networks, for predicting stock market values based on historical data. The results indicate that while MLP is more effective in predicting stock value changes, the Elman network and linear regression excel in predicting the direction of changes. The study emphasizes the importance of neural networks in handling complex prediction problems in financial markets due to their self-adjusting nature and generalization capabilities.

Uploaded by

ritajhmz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

CISIM2010

This paper explores the use of neural networks, specifically feed forward multi-layer Perceptrons (MLP) and Elman recurrent networks, for predicting stock market values based on historical data. The results indicate that while MLP is more effective in predicting stock value changes, the Elman network and linear regression excel in predicting the direction of changes. The study emphasizes the importance of neural networks in handling complex prediction problems in financial markets due to their self-adjusting nature and generalization capabilities.

Uploaded by

ritajhmz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Stock Market Value Prediction Using Neural Networks

Mahdi Pakdaman Naeini Hamidreza Taremian Homa Baradaran Hashemi


IT & Computer Engineering Engineering Department School of Electrical and Computer
Department Islamic Azad University Engineering
Islamic Azad University Tehran East Branch University of Tehran
Parand Branch Tehran, Iran Tehran, Iran
Tehran, Iran email: e-mail: [email protected]
e-mail: [email protected] [email protected]

Abstract— Neural networks, as an intelligent data mining regression. These days Neural Networks are considered as a
method, have been used in many different challenging pattern common Data Mining method in different fields like
recognition problems such as stock market prediction. economy, business, industry, and science. [6]
However, there is no formal method to determine the optimal The application of neural networks in prediction
neural network for prediction purpose in the literatur. In this problems is very promising due to some of their special
paper, two kinds of neural networks, a feed forward multi characteristics.
layer Perceptron (MLP) and an Elman recurrent network, are First, traditional methods such as linear regression and
used to predict a company’s stock value based on its stock logistic regression are model based while Neural Networks
share value history. The experimental results show that the
are self-adjusting methods based on training data, so they
application of MLP neural network is more promising in
have the ability to solve the problem with a little knowledge
predicting stock value changes rather than Elman recurrent
network and linear regression method. However, based on the about its model and without constraining the prediction
standard measures that will be presented in the paper we find model by adding any extra assumptions. Bsides, neural
that the Elman recurrent network and linear regression can networks can find the relationship between the input and
predict the direction of the changes of the stock value better output of the system even if this relationship might be very
than the MLP. complicated because they are general function
approximators. Consequently, neural networks are well
Keywords- Stock market prediction; Data mining; neural applied to the problems in which extracting the relationships
networks among data is really difficult but on the other hand there
exists a large enough training data sets. It should be
I. INTRODUCTION mentioned that, although sometimes the rules or patterns that
we are looking for might not be easily found or the data
From the beginning of time it has been man’s common could be corrupted due to the process or measurement noise
goal to make his life easier. The prevailing notion in society of the system, it is still believed that the inductive learning
is that wealth brings comfort and luxury, so it is not or data driven methods are the best way to deal with real
surprising that there has been so much work done on ways to world prediction problems.
predict the markets. Therefore forecasting stock price or Second, Neural Networks have generalization ability
financial markets has been one of the biggest challenges to meaning that after training they can recognize the new
the AI community. Various technical, fundamental, and patterns even if they haven’t been in training set. Since in
statistical indicators have been proposed and used with most of the pattern recognition problems predicting future
varying results. However, none of these techniques or events (unseen data) is based on previous data (training set),
combination of techniques has been successful enough. The the application of neural networks would be very beneficial.
objective of forecasting research has been largely beyond the Third, neural networks have been claimed to be general
capability of traditional AI research which has mainly function approximators. It is proved that an MLP neural
focused on developing intelligent systems that are supposed network can approximate any complex continuous function
to emulate human intelligence. By its nature the stock market that enables us to learn any complicated relationship between
is mostly complex (non-linear) and volatile. With the the input and the output of the system.
development of neural networks, researchers and investors The idea of using neural networks for predicting
are hoping that the market mysteries can be unraveled . problems was first expressed by Hu in 1964 which was used
Artificial Neural networks inspired by human brain cells’ for weather forecasting [8]. The absence of any learning
activity can learn the data patterns and generalize their method for multi layer networks made it impossible to apply
knowledge to recognize the future new patterns. these networks to complex prediction problems. But in 1980s
Researches on neural networks show that Neural the back propagation algorithm was introduced for training
Networks have great capability in pattern recognition and an MLP neural network. Werbos used this technique to train
machine learning problems such as classification and a neural network in 1988 and claimed that neural networks

978-1-4244-7818-7/10/$26.00 2010
c IEEE 132
are better than regression methods and Box-Jenkins model in Consequently the more is the weight wij the stronger would
prediction problems [15]. The research on neural network the connection be and vice versa.
applications continued up to the point that all the winners of In this paper, we focus on feed forward multi layer neural
the prediction contest in Santafa institute had used neural networks. These networks are made of layers of neurons.
networks [14]. The first layer is the layer connected to the input data. After
In the recent decade so many researches have been done that there could be one or more middle layers called hidden
on neural networks to predict the stock market changes. One layers. The last layer is the output layer which shows the
of the first efforts was by Kimmoto and his colleagues in results. In feedback networks in contrast with recurrent
which they used neural networks to predict the index of networks all the connections are toward the output layer.
Tokyo stock market [10]. Mizuno and his colleagues also Figure one shows a three layer feed forward Perceptron
used neural networks to predict the trade of stocks in Tokyo network.
stock market. Their method was able to predict with 63% One of the learning methods in multi layer Perceptron
precision [12]. By combining Neural Networks and genetic Neural Networks is the error back propagation in which the
algorithms, Phau and his colleagues managed to predict the network learns the pattern in data set and justifies the weight
direction of Singapore stock market with 81% precision. of the connections in the inverse direction respect to the
In this paper we have suggested a predictive model based gradient vector of Error function which is usually regularized
on MLP neural network for predicting stock market changes
in Tehran Stock Exchange Corporation (TSEC). Using this
model, one can predict the next day stock value of a
company only based on its stock trade history and without
any information of the current market. Our experiments
show that the prediction error of this model is around 1.5%.
In the following we will briefly introduce the idea of
Figure 2: Perceptron neuron’s connections
MLP neural network in the second section. The third section
presents the architecture of the proposed prediction model, sum of squared error. The back propagation method picks a
data preparation methods used in this research and the training vector from training data set and moves it from the
evaluation criteria used for the evaluation of different input layer toward the output layer. In the output layer the
models. In the fourth section the experimental results of the error is calculated and propagated backward so the weight of
simulations on a company’s data will be analyzed using the connections will be corrected. This will usually go on
different models. Finally the fifth section concludes the until the error reaches a pre defined value. It’s proved that
papers describing the future works of the study. we can approximate any continuous function with a three
layer feedback network with any precision. It should be said
II. NEURAL NETWORKS
that the learning speed will dramatically decrease according
The idea of neural networks was first inspired by human to the increase of the number of neurons and layers of the
beings nervous system which consists of a number of simple networks.
processing units called neuron (figure 1). Each neuron
receives some signals from outside or from other neurons III. THE SUGGESTED NEURAL NETWORK
and then by processing them in activation function produces In spite of all the features mentioned for neural networks,
its output and sends it to other neurons. Each input impact is building a neural network for prediction is somehow
different from other inputs. For example in figure two the complicated. In order to have a satisfactory performance one
impact of the ith neuron on jth neuron is shown with wij, the must consider some crucial factors in designing of such a
weight of the connection between neuron i and j. prediction model. One of the main factors is the network
structure including number of layers, neurons, and the
inputs outputs
connections. Other factors to be considered are the activation
functions in each neuron, the training algorithm, data
normalization, selecting training and test set and also
evaluation measurements.
In the suggested model two neural networks, a multilayer
Perceptorn feed-forward and an Elman recurrent are used
and the back propagation algorithm is used to train these
networks.
The inputs to the neural networks are the lowest, the
highest and the average value in the d previous days. Other
Input layer Hidden layer Output layer information available about the stock market is not used
because our goal is to predict the value of the stock share
Figure
Figure 1: Architecture of a1.feedP forward MLP only based on the stock value history. In other words, the

2010 International Conference on Computer Information Systems and Industrial Management Applications (CISIM) 133
proposed model can be viewed as a time series prediction 1 (2)
MAD = ¦ price tomorrow
forecast − pricereal
tomorrow
model. ValidationSet for all days ∈ ValidationSet
This model uses a three layer neural network in which the
forecast − pricereal
price tomorrow tomorrow
1 (3)
input layer has 3d neurons which get the lowest, the highest MAPE = ¦ tomorrow
ValidationSet for all days ∈ ValidationSet pricereal
and the average stock value in the last d days. In the hidden
¦ ( price )
layer there are h neurons which are fully connected to the 1 tomorrow 2 (4)
MSE = tomorrow
forecast − pricereal
input and output layers. There is one neuron in output layer ValidationSet for all days ∈ ValidationSet
which predicts the expected stock value of the next day of (5)
¦ ( price )
1 2
the stock market. RMSE = tomorrow
forecast − pricereal
tomorrow

ValidationSet for all days ∈ ValidationSet

A. Data Preparation prediction of the changes in n+1th day relative to nth day (6).
In this paper the lowest, the highest and the average value When the prediction is completely random this number
of the stock market in the last d days are used to predict the would be around 0.5. As a result, in order to have a reliable
next day’s market value. The stock market data have been prediction method this feature should be at least above 0.5.
extracted from Tehran Stock Market website. In this method Although knowing the direction of the changes is an
in contrast with other methods the disorders in the market important factor for decision making, we also need to know
caused by social or political reasons are not omitted from the the amount of the changes. There will be two other criteria to
data set because we want to predict the value based on the determine the ratio of correct forecast trend to the real trend
value history. The simulation data was extracted in 2000 to of stock changes (7) and the ratio of incorrect forecast trend
2005. In this period of time 1094 companies’ shares were to the real trend of stock changes (8). In the Ideal case, the
traded in Tehran Stock Market. The data used as input to the predicted ratio of correct forecast trend to the real stock
system are the lowest, the highest, and the average value in changes in (7) should be equal to one. In addition, if the
the last d days (d= {1, 2,…, 10}). The prediction system quantity of this ratio is smaller (or greater) than one, it will
predicts the next day’s value using the above data. indicate that the direction of the changes is predicted
In neural networks applications the input data is usually correctly while the amount of changes has been predicted
normalized into the range of [0, 1] or [-1,1] according to the less (or more). In the other hand, when the direction of stock
activation function of the neurons. So in this paper the value changes is predicted incorrectly, the quantity of the (8) is
of the stock market is normalized into the range of [-1, 1] desired to be closer to one as much as possible which shows
using the (1) and then the neural networks are trained and the prediction error is minimum in this case.
tested using the back propagation algorithm. IV. SIMULATION RESULTS
2 × price − (Max Pr ice + Min Pr ice )
price = (1) In this section the prediction results of the two suggested
Max Pr ice − Min Pr ice methods using multi layer Perceptron neural networks and
Elman recurrent network are compared to linear regression
B. Evaluation criteria method results.
In prediction problems general criteria like mean absolute The training algorithm in multi layer neural network is
deviation, mean absolute percentage error, mean squared Levenberg-Marquardt back propagation which can train any
error, and root mean squared error are calculated based on (2, neural networking using differentiable activity functions. In
3, 4, 5). These criteria are preferred to be smaller since they this kind of error back propagation algorithm we use both the
indicate the prediction error of the system. gradient and the Jacobean of the performance measure (error
In addition to the above criteria three other measures are function)of the training set respect to the connection weights,
used to compare stock value prediction methods. The correct to justify the network weights [9, 11].
forecast trend measure shows the percentage of correct
ssssss
1
Correct Forecast Trend = ¦ T ( price tomorrow
forecast
today
, pricereal )
ValidationSet for all days ∈ ValidationSet

­1 if ( price tomorrow
− price today
).( price tomorrow
− price today
)≥0 (6)
forecast real real real
°
T ( price tomorrow
forecast , price today
real )= ®
°0 otherwise
¯

(7)
forecast − pricereal
pricetomorrow today
Correct Forecast Trend 1
= ¦
Re al Trend ValidationSet for all days ∈ ValidationSet
tomorrow
pricereal − pricereal
today

forecast − pricereal
Incorrect Forecast Trend 1 ª price tomorrow today
º (8)
= ¦ «1 + »
Re al Trend ValidationSet for all days ∈ ValidationSet «
¬
tomorrow
pricereal − pricereal
today
»¼

134 2010 International Conference on Computer Information Systems and Industrial Management Applications (CISIM)
Mean squared error
Mean abstract deviation
95 60,00

90
50,00

Mean squared error


Mean abstract deviation

85

80 40,00

75
30,00
70

20,00
65

60
10,00
55

0
50
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
MLP (1 hidden layer)
Past days (as NN input)
Past days (as NN input) Elman (1 hidden layer)
Linear regression Figure 4. comparing mean squared error (MSE) in Elman and MLP.

Figure 2. comparing minimum abstract deviation (MAD) in Elman and increase (in this simulation lr_inc=1.05). On the other hand
MLP. if the performance measure increases more than a threshold
(max_perf_inc=1.04), leaning rate will decrease with the rate
of lr_dec (in this simulation lr_dec=0.7) and the related
Mean absolute percentage change which has increased the performance measure, will
0.02 not be applied to the network weights.
Mean absolute percentage error

When one of the below happens the algorithm will stop.


0.02
• The training epochs reach its maximum (in this
simulation 1000 epochs).
• The performance measure reaches its goal.
0.01
(MSE=10to-6)
• The gradient of the performance measure gets under
0.01 a threshold. (10to-6)
In the following the results of these two methods are
0.00
going to be compared to the result of the linear regression
method. In figure 3, 4, and 5 it’s clearly shown that the MLP
Neural Network has less MSE, MAPE, and MSE comparing
0.00 to Elman and linear regression though this method cannot
1 2 3 4 5 6 7 8 9 10
predict the direction of the changes as well as Elman and
Past days (as NN input)
regression (figure 6). However the linear regression method
Figure 3. comparing mean absolute percentage error (MAPE) in Elman
predicts the direction of the changes well (figure 6), the error
and MLP in the prediction of the value is much more than multilayer
Perceptron and Elman (figure 7). The Elman network can
On the other hand, to train Elman network, the error back predict the direction of the changes better than multilayer
propagation with momentum and adaptive learning rate is Perceptron (figure 6) but suffers from greater error in
used. This algorithm like Levenberg-Marquardt has the prediction (figure 7) .
capability to train any network using differentiable activity
functions. The weights of the network in this algorithm are V. CONCLUSIONS
adjusted according to Gradient decent (with momentum) In this paper we used neural networks model to predict
based on the (9) in which mc is the momentum, dXprev is the the value of stock share in the next day using the previous
previous change in the network weights and lr is the learning data about stock market value. For this purpose two different
rate. well known types of neural networks were applied to the
d pref problem. The obtained results show that for predicting the
d X = mc × d Xprev + lr.mc. (9) direction of changes of the values in the next day none of
dX these methods are better than simple linear regression model.
In each epoch if the performance measure (Mean squared But the error of the prediction of the amount of value
error) is moving toward its goal value, the learning rate will changes using MLP neural network is less than both Elman
network and linear regression method. In addition to this,
when the feed forward MLP neural network predicts the
direction of the changes correctly, the amount of change is

2010 International Conference on Computer Information Systems and Industrial Management Applications (CISIM) 135
Correct direction change Ratio of incorrect forecast direction change to real direction change

Ratio of incorrect froecast direction change to real


1.0 5.0
Correct direction change forecast

0.9 4.5

0.8 4.0

direction change
0.7 3.5

0.6
3.0
0.5
2.5
0.4
2.0
0.3
1.5
0.2
1.0
0.1
0.5
0.0
1 2 3 4 5 6 7 8 9 10
0.0
Past days (as NN input) 1 2 3 4 5 6 7 8 9 10

Past days (as NN input)


Figure 5. Maximum number of correct change direction forecast in Elman
and MLP. Figure 7. Ratio of incorrect forecast of direction change to real direction
change in Elman and MLP.

Ratio of correct forecast direction change to real direction change


[3] Qing Cao, Leggio Karyl, Marc Schniederjans, ”A Comparison
Ratio of correct forecast direction change to real

Between Fama and French’s Model and Artificial Neural Networks in


100.0
Predicting the Chinese Stock Market,” Computers & Operations
Research, vol. 32, 2005, pp. 2499-2512.
[4] Olson Dennis, Mossman Charles,“Neural Network Forecasts of
Canadian Stock Returns Using Accounting Ratios,” International
direction change

10.0
Journal of Forecasting, vol.19, 2003, pp. 453-465.
[5] C.W.J. Granger and A.P. Anderson, “An Introduction to Bilinear
Time Series Models,” Vandenhoeck and Ruprecht, Gottingen, 1978.
[6] G. Grudnitzky and L. Osburn, “Forecasting S&P and Gold Futures
Prices: An Application of Neural Networks,” Journal of Futures
1.0 Markets, vol. 13, No. 6, pp. 631-643, September 1993.
1 2 3 4 5 6 7 8 9 10
[7] Zhang Guoqiang, Patuwo Eddy, Hu Michael, “Forecasting with
Artificial Neural Networks: The State of the Art,” International
Journal of Forecasting, vol. 14, 1998, pp 35-62.
0.1
[8] M.J.C. Hu, “Application of the Adaline System to Weather
Past days (as NN input) Forecasting,” Master Thesis, Technical Report 6775-1, Stanford
Electronic Laboratories, Stanford, CA, June 1964.
[9] Levenberg K., “A Method for the Solution of Certain Problems in
Figure 6. Ratio of correct forecast of direction change to real direction Least Squares,” Quart. Appl. Math. , no. 2, 1944, pp. 164-168.
change in Elman and MLP. [10] T. Kimoto, K. Asakawa, M. Yoda, and M. Takeoka, "Stock market
prediction system with modular neural network," Proceedings of the
completely close to the real one in comparison to the other International Joint Conference on Neural Networks, 1990, pp. 1-6.
two mentioned methods. In future works of this study we [11] D. Marquardt, “An Algorithm for Least Squares Estimation of
are going to apply other recently proposed regression Nonlinear Parameters,” SIAM Journal of Applied Mathematics, no.
methods such as Support Vector Regression models which is 11, 1963, pp. 431-441.
newer in the field of machine learning researches and [12] H. Mizuno, M. Kosaka, H. Yajima, and N. Komoda, “Application of
Neural Network to Technical Analysis of Stock Market Prediction,”
claimed to have good generalization ability due to Studies in Informatic and Control, vol.7, no.3, 1998, pp.111-120.
application of large margin concept.
[13] H. Tong and K.S. Lim, “Threshold Autoregressive, Limit Cycles and
Cyclical Data,” Journal of the Royal Statistical Society Series, vol. B-
42, no. 3, 1980, pp. 245–292.
REFERENCES
[14] A.S. Weigend and N.A. Gershenfeld, “Time Series Prediction:
[1] Chen An-Sing, Leung Mark, Daouk Hazem, “Application of Neural Forecasting the Future and Understanding the Past,” Addison-
Networks to an Emerging Financial Market: Forecasting and Trading Wesley, Reading, MA, 1993.
the Taiwan Stock Index,” Computers & Operations Research, vol. 30, [15] P.J. Werbos, “Generalization of back propagation with application to
2003, pp. 901–923. a recurrent gas market model,” Neural Networks, vol. 1, pp. 339-356,
[2] G. Armano, M. Marchesi, and A. Murru, “A Hybrid Genetic-Neural 1988.
Architecture for Stock Indexes Forecasting,” Information Sciences, [16] Md. Rafiul Hassan and Baikunth Nath, “ Stock Market Forecasting
vol. 170, 2005, pp 3-33. Using Hidden Markov Model: A New Approach,” 5th International
Conference on Intelligent Systems Design and Applications, 2005.

136 2010 International Conference on Computer Information Systems and Industrial Management Applications (CISIM)

You might also like