Vous êtes sur la page 1sur 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 Articial Neural Networks (ANN) for predicting values of Stock Exchange shares. Rules of Stock Exchange functioning, principles of technical analysis and the most important stock market indices are described, which support investors, who plan to make transactions. ANN of Multi-Layer Perceptron (MLP) type, and a moving window method are applied. A hybrid method is also proposed, in which time series of CLOSE values as a function of the following trading days are used to stock market indices calculation, such as moving averages and oscillators, which are applied to ANN inputs. Research was conducted for 80 companies, selected from the 1218 companies functioning on Stock Exchange. The achieved maximum error in one day ahead CLOSE value prediction is 1,31%.

of trading systems complexity there is also a growing interest in combining them with articial neural networks [2, 4, 7, 10, 11], with an objective of maximizing prots. The nancial market, which uses the most advanced IT solutions, provides a variety of products to meet this goal. From all of them, the most popular are nancial instruments offered by the Stock Exchange, which may be the most protable but there is also a risk of losing all assets [3]. This is why the Stock Exchange as a nonlinear dynamic system [10] is a challenge for the developed modelling schemes in which articial neural network (ANN) are gaining in importance. The relation between risk and prot is presented in Fig. 1. Examples of possible use of ANN on the Stock Exchange are prediction of future stock market indices [2, 7, 10], exchange rates [11], share prices, etc. The most commonly used articial neural networks to predict the trading signals are the feedforward neural networks (FNN) [4, 7, 11] and probabilistic neural networks (PNN) [10], but also new approaches and ANN structures, like for e.g. State Space Wavelet Network (SSWN) [2] are still the subject of scientic studies. However, analyzing the market state and examples

Introduction

Nowadays, when economics is supported by IT (Informa-

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 prot and risk in the most popular nancial instruments [14] without the use of risk models. Analysis of the market situation should be approached on many levels. Technical analysis provides many tools that can accomplish this goal. Therefore, in this work a hybrid approach combining technical analysis and ANN is proposed. or sometimes even years, short-term investors, who, in order to minimize the risk, close the positions every day, and their investment decisions are based on 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]: The market discounts everything. Prices are subject to trends. History repeats itself. According to the above principles, technical analysis can serve as a starting point for creating a transaction system, which, on the basis of the decisions of an articial neural network, provides the user with a set of companies that achieve the highest prot and the highest loss. As a consequence, the user obtains information on when and which securities should be sold or bought.

The functioning of the stock exchange and an introduction to technical analysis

Stock Exchange is a place where buyers and sellers exchange the goods after establishing jointly accepted price. Trading is immaterial meaning that all securities are stored in the form of electronic records in the system of National Depository for Securities and on customers investment accounts in brokerage houses. Each order of buying and selling must contain specic 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 difcult to talk about long-term income without having a strategy. In this aspect, investors can be divided into two groups [12]: long-term investors, who, on the basis of a de-

Application of ANN for prediction of closing prices

tailed 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

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

277

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 proposed, 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 calculate moving averages and oscillators, which are important market indicators. These are the inputs of ANN, which SM AN (k ) = 1 [C (k ) + C (k 1) + . . . N +C (k N + 1)] (1) ing Average)

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 algorithm [8] were used for the CLOSE value prediction. For the comparison purposes the CLOSE value signal was LW M AN,C (k ) predicted by the use of MLP and so called moving window method [6], in which the network is exposed to current 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 ) work training and testing. Finally, the results obtained with the hybrid and with the purely ANN-based approach were compared. + = 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 (3) + = b. Weighted (5-, 10-, 20-days) - LW M A (Linearly Weighted Moving Average) N C (k ) + (N 1)C (k 1) + . . . N + (N 1) + . . . + 1 C (k N + 1) N + (N 1) + . . . + 1 (2)

where: a - coefcient,

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 already existing trend. Their task is to signal the launch of a new trend or a reversal of the current trend. They follow the trend and not precede it, so they do not predict market behavior. They are used primarily to mitigate deviations of prices. Additionally, the Bollinger band and envelopes are used to determine when the market is overbought.

Technical analysis provides many tools that support investors in making decisions. The most commonly used are moving averages and oscillators, which were selected for the proposed approach [5]. These include the following: Moving averages:

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

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 uctuations, 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 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 prices are shaping near the lower limit of that range. %K = 100[C (k ) L(14)/(H (14) L(14))] (6)

b. RSI - Relative Strength Index - i.e. the measure of d. Moving Average Convergence/Divergence (M ACD) overbought / oversold market. It assumes values in the range of 0-100. For values greater than 70 it is considered that the market is buyout. When oscillator values are below 30, it means that market is sold out. In the case of periods of strong trends it is assumed that the market is buyout when RSI > 80 (at the time of a bull market) and sold out for RSI < 20 (during a bear market). For: C (k ) > C (k ) < C (k 1), U (k ) = C (k ) C (k 1) SL(k ) = EM A9,M ACD (k ) (8) M ACD(k ) = EM A12,C (k ) EM A26,C (k ) (7) is the difference between two moving averages. On the graphs, it usually occurs with 10- day, exponential moving average (called the signal line). The intersection of the signal line (SL) with the M ACD line coming from the bottom is a buying signal, while with the line from the top selling signal.

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, sewhere U (k ) - average increase in the k -th day, D(k ) average decrease in the k -th day c. Stochastic oscillator (K %D) - determines the relation 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 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 uctuations 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

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

279

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 formula: (V alue/V aluemax) 0, 8 + 0, 1 (9) The neural network of MLP (5-9-1) structure shown in Fig. 3 is composed of an input layer which consists of ve 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. Fig. 3: An example of Multi-Layer Perceptron MLP (5-91) - position 1 in Tab. 2

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 with the smallest training and testing errors have been se-

Summary and conclusions

lected. 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 2500 a 0,0018 0,0011 a ve 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 ve 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 nal decision to purchase or sell securities.

Signals Using Neural Networks, In Proc. of the 14th Annual Global Finance Conference (GFC 2007), Melbourne, Australia, pp. 171-179, Sep. 2007

References
[1] R. Bensignor, New Concepts in Technical Analysis, Wig-Press, (in Polish) Warsaw 2004

[11] D. Witkowska, Articial Neural Networks and statistical methods, Selected nancial issues, (in Polish), C. H. Beck, Warsaw 2002

[2] M.A. Brdy s, A. Borowa, P. Id zkowiak, M.T. Brdy s, [12] A. Zaremba, Stock Exachange, (in Polish), 2010 Adaptive Prediction of Stock Exchange Indices by [13] J. Zieli nski, 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. D ebski, Financial Market and it mechanisms, inwestora/fundusze/narzedzia/ryzyko(in Polish), PWN, Warsaw 2010 [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, Identication 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, Articial 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
inwestycyjne.html

Vous aimerez peut-être aussi