You are on page 1of 8

Image Processing & Communication, vol. 17, no. 4, pp.

275-282
DOI: 10.2478/v10248-012-0056-5

275

PREDICTION OF CLOSING PRICES ON THE STOCK EXCHANGE WITH


THE USE OF ARTIFICIAL NEURAL NETWORKS

M ICHA PALUCH , L IDIA JACKOWSKA -S TRUMIO

Computer Engineering Department, Technical University of Lodz, Lodz, Poland


mpaluch@kis.p.lodz.pl

Abstract. Article describes, the use of Arti-

of trading systems complexity there is also a grow-

ficial Neural Networks (ANN) for predicting

ing interest in combining them with artificial neural net-

values of Stock Exchange shares.

Rules of

works [2, 4, 7, 10, 11], with an objective of maximiz-

Stock Exchange functioning, principles of tech-

ing profits. The financial market, which uses the most

nical analysis and the most important stock

advanced IT solutions, provides a variety of products to

market indices are described, which support in-

meet this goal. From all of them, the most popular are fi-

vestors, who plan to make transactions. ANN

nancial instruments offered by the Stock Exchange, which

of Multi-Layer Perceptron (MLP) type, and a

may be the most profitable but there is also a risk of los-

moving window method are applied. A hybrid

ing all assets [3]. This is why the Stock Exchange as a

method is also proposed, in which time series

nonlinear dynamic system [10] is a challenge for the de-

of CLOSE values as a function of the follow-

veloped modelling schemes in which artificial neural net-

ing trading days are used to stock market in-

work (ANN) are gaining in importance. The relation be-

dices calculation, such as moving averages and

tween risk and profit is presented in Fig. 1.

oscillators, which are applied to ANN inputs.

Examples of possible use of ANN on the Stock Ex-

Research was conducted for 80 companies, se-

change are prediction of future stock market indices [2,

lected from the 1218 companies functioning on

7, 10], exchange rates [11], share prices, etc.

Stock Exchange. The achieved maximum er-

most commonly used artificial neural networks to pre-

ror in one day ahead CLOSE value prediction is

dict the trading signals are the feedforward neural net-

1,31%.

works (FNN) [4, 7, 11] and probabilistic neural networks

The

(PNN) [10], but also new approaches and ANN structures,

like for e.g. State Space Wavelet Network (SSWN) [2] are

Introduction

still the subject of scientific studies.


Nowadays, when economics is supported by IT (Informa-

However, analyzing the market state and examples

tion Technology) the modern trading systems can meet from literature [3, 4], it was found that it is risky to make
the most demanding customer needs. With the increase investment decisions based solely on ANN prediction and
Unauthenticated | 85.86.26.162
Download Date | 3/17/14 3:52 PM

276

M. Paluch, L. Jackowska-Strumio

Fig. 1: Relation between profit and risk in the most popular financial instruments [14]
or sometimes even years,

without the use of risk models. Analysis of the market


situation should be approached on many levels. Techni-

short-term investors, who, in order to minimize the

cal analysis provides many tools that can accomplish this

risk, close the positions every day, and their invest-

goal. Therefore, in this work a hybrid approach combin-

ment decisions are based on technical analysis.

ing technical analysis and ANN is proposed.

The functioning of the stock exchange and an introduction to


technical analysis

Fundamental analysis means detailed immersion in the


activity of the company in which one is going to invest,
its sector and related sectors. Technical analysis is a type
of market research, mainly with the help of charts and indicators. The study is based on three premises [12]:

Stock Exchange is a place where buyers and sellers ex-

The market discounts everything.

change the goods after establishing jointly accepted price.

Prices are subject to trends.

Trading is immaterial meaning that all securities are

History repeats itself.

stored in the form of electronic records in the system of


National Depository for Securities and on customers in-

According to the above principles, technical analysis can


serve as a starting point for creating a transaction system,

vestment accounts in brokerage houses.


Each order of buying and selling must contain specific
information such as the name of the security, type of order,
the date, value, number, etc. Stock Exchange is a place in
which, within a short time, much can be gained and much
can be lost. Still, it is difficult to talk about long-term
income without having a strategy. In this aspect, investors
can be divided into two groups [12]:

which, on the basis of the decisions of an artificial neural


network, provides the user with a set of companies that
achieve the highest profit and the highest loss. As a consequence, the user obtains information on when and which
securities should be sold or bought.

Application of ANN for prediction


of closing prices

long-term investors, who, on the basis of a detailed fundamental analysis of companies, buy a Closing price of the asset for the next day is the most imlarge amount of shares and sell after a few months portant parameter for investors, who plan to make transUnauthenticated | 85.86.26.162
Download Date | 3/17/14 3:52 PM

277

Image Processing & Communication, vol. 17, no. 4, pp. 275-282

actions at the Stock Exchange. In this work a hybrid a. Arithmetical (5-, 10-, 20-days) - SMA (Simple Movapproach combining technical analysis and ANN is pro-

ing Average)

posed, which can support them in making correct decisions. The main idea of the proposed method is shown
in Fig. 2. Technical analysis methods are used to calcu-

SM AN (k)

1
[C(k) + C(k 1) + . . .
N

late moving averages and oscillators, which are important

+C(k N + 1)]

market indicators. These are the inputs of ANN, which

(1)

predicts the CLOSE value for the next day. The aim of where: N - number of days, N = 5, 10, 20 C(k) - closing
this work was to investigate, if the proposed data prepro- price in the k-th day
cessing and market indicators calculation would improve
the ANN effectiveness in the CLOSE value prediction.
Feedforward networks of Multi-Layer Perceptron
(MLP) type trained with the backpropagation algo-

b. Weighted (5-, 10-, 20-days) - LW M A (Linearly


Weighted Moving Average)

rithm [8] were used for the CLOSE value prediction. For
the comparison purposes the CLOSE value signal was LW M AN,C (k)

N C(k) + (N 1)C(k 1) + . . .
N + (N 1) + . . . + 1

C(k N + 1)
N + (N 1) + . . . + 1

predicted by the use of MLP and so called moving window method [6], in which the network is exposed to cur-

(2)

rent and a number of past samples of the signal.


For research purposes, quotations of 1218 companies
appearing on the stock market were downloaded and limited to the data since 3.01.2000 until 27.01.2012. The c. Expotential (5-, 10-, 20-days) - EMA (Expotential
Moving Average)
programming application was designed and implemented
for the data collecting and preprocessing. The calculated
moving averages and oscillators were used for neural net- EM AN,C (k)

C(k) + aC(k 1) + a2 C(k 2) + ...


1 + a + a2 + ... + aN 1

aN 1 C(k N + 1)
1 + a + a2 + ... + aN 1

work training and testing. Finally, the results obtained


with the hybrid and with the purely ANN-based approach
were compared.

where: a - coefficient,

Averages and indicators used for


networks training

d. Envelopes (3% error with 20-days average)


e. Bollinger Bands These tools are used to study the al-

Technical analysis provides many tools that support in-

ready existing trend.

Their task is to signal the

vestors in making decisions. The most commonly used

launch of a new trend or a reversal of the current

are moving averages and oscillators, which were selected

trend. They follow the trend and not precede it, so

for the proposed approach [5]. These include the follow-

they do not predict market behavior. They are used

ing:

primarily to mitigate deviations of prices. Additionally, the Bollinger band and envelopes are used to

Moving averages:

determine when the market is overbought.

Unauthenticated | 85.86.26.162
Download Date | 3/17/14 3:52 PM

(3)

278

M. Paluch, L. Jackowska-Strumio

Fig. 2: Processing scheme for predicting course of a CLOSE value for the next day
Oscillators

as the closing price near the top of the range of its


fluctuations, and K%D < 30 points to the fact that

a. ROC - Rate of Change (5-, 10-, 20-days) - determines


the rate of price changes in a given period (usually

prices are shaping near the lower limit of that range.


%K = 100[C(k) L(14)/(H(14) L(14))]

(6)

10 days)
where: L(14) - the lowest price from last fourteen days,
ROCN (k) = C(k)/C(k N )

(4)

H(14) - the highest price from last fourteen days

b. RSI - Relative Strength Index - i.e. the measure of d. Moving Average Convergence/Divergence (M ACD)
overbought / oversold market. It assumes values in

is the difference between two moving averages. On

the range of 0-100. For values greater than 70 it is

the graphs, it usually occurs with 10- day, exponen-

considered that the market is buyout. When oscilla-

tial moving average (called the signal line). The in-

tor values are below 30, it means that market is sold

tersection of the signal line (SL) with the M ACD

out. In the case of periods of strong trends it is as-

line coming from the bottom is a buying signal, while

sumed that the market is buyout when RSI > 80 (at

with the line from the top selling signal.

the time of a bull market) and sold out for RSI < 20
(during a bear market).

M ACD(k) = EM A12,C (k) EM A26,C (k)

(7)

SL(k) = EM A9,M ACD (k)

(8)

For:
C(k) >

C(k 1), U (k) = C(k) C(k 1)

C(k 1), D(k) = |C(k) C(k 1)| 5 Experimental research

100
Research was conducted for 80 companies appearing on

RSI(k) = 100
(5)
EM AN,U (k)
1 + EM AN,D (k)
the stock market in Warsaw since 3.01.2000 until now, seC(k) <

where U (k) - average increase in the k-th day, D(k) average decrease in the k-th day

lected from the all 1218 companies functioning on stock


market since 1991. The aim of the research was to test
different ANN architectures and to choose the best one

c. Stochastic oscillator (K%D) - determines the relation

for predicting the CLOSE value of the asset for the next

between the last closing price and the range of price day. The research was performed with the use of Java and
fluctuations in the given period. The result belongs Neuroph 2.6. library, creating ANN of Multi-Layer Perto the range of 0-100. K%D > 70 is interpreted ceptron (MLP) type. Each network consists of an input,
Unauthenticated | 85.86.26.162
Download Date | 3/17/14 3:52 PM

279

Image Processing & Communication, vol. 17, no. 4, pp. 275-282

Tab. 1: Combinations of the tested MLP architectures


Input layer Hidden layer
Output
n+1
n
1, 5n
1
2n 1
2n + 1
where n - number of neurons (n = 4, 5, 6 neurons)
hidden and output layer. A common feature of all of the
tested network architectures is a small number of the input
nodes and neurons in the hidden layer, and only one neuron in the output layer. Too many neurons would increase
the network training error and could cause learning time
extension [4]. The relations between the number of input
nodes and the number of neurons in the hidden layer were
tested for the combinations shown in Tab. 1.
Market indicators for the input data were selected as
described in literature [1, 4, 5, 13] or randomly. ANN
training was performed according to the following rules:
1. All entered data were normalized using the following
Fig. 3: An example of Multi-Layer Perceptron MLP (5-91) - position 1 in Tab. 2

formula:
(V alue/V aluemax) 0, 8 + 0, 1

(9)

2. The results of each company were divided into two


groups: learning data and testing data in the proportion 80:20 [9].
3. Weights for each input were set randomly.
4. Neural networks were taught with the back propagation algorithm with momentum factor [7, 8].
5. For each ANN architecture and each set of input
data, eight neural networks were trained, and the
ANN with the smallest error has been selected as the
best one.
As a result of these studies six best ANN architectures

The neural network of MLP (5-9-1) structure shown in


Fig. 3 is composed of an input layer which consists of five
input nodes and a hidden layer with nine neurons. The
result is derived in a single output. The above architecture
represents one of the tested relations between the number
of neurons in the input layer and their number in the hidden layer. The results of short-term forecast of CLOSE
value of Asseco Poland SA shares in August 2011 predicted with the use of MLP (5-9-1) network are presented
in Fig. 4 and in Tab. 3.

Summary and conclusions

with the smallest training and testing errors have been selected. The results for these ANN architectures obtained The presented studies on application of neural networks
for one exemplary company Asseco Poland SA are pre- for predicting the closing prices on the stock exchange
sented in Tab. 2. An example of MLP (5-9-1) structure, have shown that the relatively low rates of errors were
which is listed in position 1 is shown in Fig. 3.

achieved (less than 1,5%). Hence, the studied neural

Unauthenticated | 85.86.26.162
Download Date | 3/17/14 3:52 PM

280

M. Paluch, L. Jackowska-Strumio

Tab. 2: Architectures of the selected networks, which achieved the best results
No.
Input
MLP
Transfer
Periods Training Testing
function
error
error
(MSE)
(MSE)
SMA10
SMA20
1.
Bollinger Band 5-9-1 sigmoidal
1000
0,026
0,0017
RSI
MACD
SMA10
2.
MACD
4-5-1 sigmoidal
4000
0,031
0,0024
Bollinger Band
RSI
LWMA5
3.
LWMA20
4-7-1 sigmoidal
1000
0,027
0,0021
Envelope
RSI
EMA5
EMA10
4.
Bollinger Band 6-9-1 sigmoidal
4000
0,034
0,0028
ROC
MACD
RSI
EMA5
EMA20
5.
Envelope
6-9-1 sigmoidal
700
0,032
0,0023
K%D
MACD
RSI
CLOSE values
6.
from last
5-6-1 sigmoidal
2500a
0,0018
0,0011a
five days

Unauthenticated | 85.86.26.162
Download Date | 3/17/14 3:52 PM

Image Processing & Communication, vol. 17, no. 4, pp. 275-282

281

Fig. 4: Short-term forecast of MLP (5-9-1) network, with real CLOSE value of Asseco Poland SA shares in August
2011
network based model can be used to make good investTab. 3: Comparison of real quotes and network forecast
for Asseco Poland SA
Data
CLOSE CLOSE
Relative
real
network
error in
quotes
forecast prediction
[PLN]
[PLN]
[%]
1-08-2011
47,67
47,21
0,97
2-08-2011
47,8
47,28
1,08
3-08-2011
46,9
46,45
0,97
4-08-2011
45,17
44,71
1,02
5-08-2011
43,85
43,46
0,88
8-08-2011
40,95
40,67
0,68
9-08-2011
39,81
39,73
0,19
10-08-2011
37,5
37,82
0,84
11-08-2011
37,15
37,51
0,98
12-08-2011
39,47
39,45
0,06
16-08-2011
39,88
39,78
0,26
17-08-2011
39,38
39,36
0,05
18-08-2011
36,99
37,37
1,04
19-08-2011
36,39
36,87
1,31
22-08-2011
37,25
37,6
0,93
23-08-2011
37,2
37,55
0,93
24-08-2011
36,9
37,29
1,06
25-08-2011
38,74
38,84
0,25
26-08-2011
38,21
38,28
0,19
29-08-2011
39,45
39,19
0,66
30-08-2011
39,8
39,45
0,87
31-08-2011
42,5
42,23
0,63

ment decisions and reduce the risk of loss. The results


presented in Tab. 2, allow to conclude that for all studied networks, the best results were obtained by the network architecture no. 6 in Tab. 2, for which, in the input, CLOSE values for last five days were forwarded.
In this approach, the ANN was able to predict with the
low error rate, CLOSE value for next day. Nevertheless
this approach has disadvantages. ANN is exposed to receive false signals from the market, which may ultimately
lead to increase network errors. This explains the differences between the current and predicted by the network,
CLOSE values in a number of periods. Taking this into
consideration, the safer solution would be to use a neural network architecture no. 1 in Tab. 2. This network
features a larger error, but is not so vulnerable to false
signals from the market because economic models are incorporated into the proposed hybrid modeling scheme.
However, because the Stock Exchange market, often
occurs uncontrollable, there is a need to protect investments by additional mechanisms and risk models, mitigating the impact of similar situations on the "investors
wallet." Still, regardless of the number of the developed
neural networks and economic models, it should be the

Unauthenticated | 85.86.26.162
Download Date | 3/17/14 3:52 PM

282

M. Paluch, L. Jackowska-Strumio

stock broker who makes the final decision to purchase or

Signals Using Neural Networks, In Proc. of the 14th

sell securities.

Annual Global Finance Conference (GFC 2007),


Melbourne, Australia, pp. 171-179, Sep. 2007

References

[11] D. Witkowska, Artificial Neural Networks and sta-

[1] R. Bensignor, New Concepts in Technical Analysis,

tistical methods, Selected financial issues, (in Polish), C. H. Beck, Warsaw 2002

Wig-Press, (in Polish) Warsaw 2004

[2] M.A. Brdys, A. Borowa, P. Idzkowiak, M.T. Brdys, [12] A. Zaremba, Stock Exachange, (in Polish), 2010
Adaptive Prediction of Stock Exchange Indices by [13] J. Zielinski, Intelligent management systems - theState Space Wavelet Networks, Int. J. Appl. Math.
ory and practice, (in Polish), Warsaw 2000
Comput. Sci., Vol. 19 , No. 2, pp. 337-348, 2009
[14] http://www.mbank.pl/inwestycje/centrum[3] W. Debski, Financial Market and it mechanisms,
inwestora/fundusze/narzedzia/ryzyko(in Polish), PWN, Warsaw 2010

inwestycyjne.html

[4] Ed. Gately, Neural Networks - Financial forecasting


and transactional systems design, (in Polish), WigPress, Warsaw 1999
[5] J.J. Murphy, Technical Analysis of Financial Markets, (in Polish), Wig-Press, Warsaw, 2008
[6] K.S. Narendra, K. Parthasarathy, Identification and
control of dynamics systems using neural networks,
IEEE Transactions on Neural Networks, Vol. 1, No.
1, pp. 4-27, 1990
[7] P. Sutheebanjard, W. Premchaiswadi, Stock Exchange of Thailand Index Prediction Using Back
Propagation Neural Networks, In Proc. of the Second International Conference on Computer and Network Technology (ICCNT), Bangkok, pp. 377-380,
2010
[8] R. Tadeusiewicz, Artificial Neural Networks, (in
Polish), Warsaw 1993
[9] R. Tadeusiewicz, Discovering Neural Networks, (in
Polish), Cracow 2007
[10] C.D. Tilakaratne, S.A. Morris, M.A. Mammadov,
C.P. Hurst, Predicting Stock Market Index Trading
Unauthenticated | 85.86.26.162
Download Date | 3/17/14 3:52 PM

You might also like