Sunteți pe pagina 1din 5

A Comparison of GA-trained and Backpropagation-trained Artificial Neural

Networks for Discovery of Financial Trading Strategies


Andrew Skabar and Ian Cloete
School of Information Technology, International University in Germany
Bruchsal, D-76646, Germany
{andrew.skabar, ian.cloete}@i-u.de

Abstract Despite the implications of the efficient markets hy-


pothesis, many traders continue to make buy and sell de-
Several sources have suggested the use of neural networks for cisions based on historical data. These decisions are made
predicting profitable buy and sell points for financial commodi-
under the premise that patterns exist in that data, and that
ties traded on a stock exchange. In this paper we compare the
performance of two neural network traders—one trained using these patterns provide an indication of future movements.
backpropagation, the other trained indirectly using a genetic If such patterns exist, then it is possible in principle to
algorithm based weight optimization procedure. Comparison of apply automated pattern recognition techniques such as
results on Dow Jones Industrial Average index data shows that neural networks to the discovery of these patterns.
the GA-trained network performs markedly better than the Several sources have reported on the simulation of
backpropagation-trained network in making good buy and sell trading agents based on Artificial Neural Networks
decisions on test data. Comparison of the performance of the (ANNs) (White 1988; Kimoto et al 1990; Yoon & Swales
traders on the Dow Jones data with performance on random 1991; Weigend & Gershenfeld 1994). While the tradi-
walk data lends support to the claim that the observed predict-
ability on the Dow Jones index is real and not anomalous.
tional approach to supervised neural network weight op-
timization is the well-known backpropagation algorithm
(Rumelhart & McClelland 1986), Beltratti, Margarita and
Keywords Terna (1996) report on the use of genetic search for neural
Neural networks, genetic algorithms, stock market network weight optimisation in this domain. One of the
advantages of genetic search as a weight-optimisation
1. Introduction technique is that it allows flexibility in the choice of crite-
ria that can be used as an objective function to guide
Approaches to forecasting the future direction of share search through the space of weight configurations.
market prices fall broadly into two categories—those that In this paper we compare the performance of two
rely on technical analysis, and those that rely on funda- neural network traders in predicting buy and sell points
mental analysis. While technical analysis uses only his- for the Dow Jones Industrial Average Index over a period
torical data (past prices, volume of trading, volatility, etc.) of approximately three years. One of the neural traders is
to determine the movement in the price of some financial trained using back-propagation, the other is trained indi-
asset, fundamental analysis is based on external informa- rectly using a genetic algorithm based weight optimiza-
tion; that is, information that comes from the economic tion procedure. The architecture of the neural networks in
system surrounding the market. Such information in- each case is identical. In order to test whether the predict-
cludes interest rates, prices and returns of other assets, ability that we observe on the Dow Jones data is real or
and many other macro- or micro-economic variables. The anomalous, we compare the performance of the neural
use of technical analysis goes against the grain of conser- network traders on real data with their performance on
vative academic opinion, which regards this behaviour as random walk data.
irrational given the efficient markets hypothesis (Malkiel The paper is organized as follows. Section 2 outlines
1996). how neural networks can be used to represent a financial
The efficient markets hypothesis asserts that the price training strategy. Section 3 describes how back-
of an asset reflects all of the information that can be ob- propagation can be used to train a network on financial
tained from past prices of the asset. The main argument time series data, and Section 4 describes the use of ge-
for the hypothesis is that any opportunity for a profit will netic search for weight optimisation. In Section 5 we pre-
be exploited immediately, and hence disappear. That is, sent empirical results on the performance of the traders.
the market is so efficient that no one can buy or sell Section 6 concludes the paper.
quickly enough to consistently benefit. A consequence of
this hypothesis is that stock prices follow a random walk 2. Neural Networks for Automated Trading
and are unpredictable based on any amount of historical
data. The most appropriate investment strategy is thus a One approach to developing neural network trading mod-
buy-and-hold strategy. els is to first train the neural network to predict the value
of the closing price of some asset one or more days into achieved on the training data given complete knowledge
the future. An entry/exit (i.e. buy or sell) decision can of the future—no expert could have performed better.1
then be made on the basis of this prediction. We take an
alternative approach that does not attempt exact numeric 4. Genetic Algorithm Weight Optimization
prediction of the asset value, but rather attempts to recog-
nize patterns in the input data that can provide clues as to An alternative approach to backpropagation is to discover
the optimal points to make buy or sell decisions. a set of network weights indirectly by using some crite-
The neural buying and selling agent we use consists rion to measure the performance of the trading decisions
of an input layer, one hidden layer of sigmoidally acti- made by the agent, and to use this measure to guide
vated units, and a single sigmoidally activated output that search through the space of weight configurations. Ge-
is thresholded such that output values above 0.5 are inter- netic algorithms are particularly suitable for this as they
preted as a buy signal, and all other values are interpreted allow complete flexibility in the choice of an objective
as a signal to sell. These signals, in conjunction with the function to guide search.
particular trading strategy that is adopted, determines the Genetic algorithms (Goldberg 1989; Holland 1975)
trading position. have been extensively applied to complex parameter tun-
In this paper, we adopt a one-point buying and selling ing problems in which various parameters of a system
strategy. This means that all available capital is invested interact in unknown and non-linear ways resulting in a
in shares, or all capital is invested in some low-risk fixed complex, irregular response surface (Bäck and Schwefel
interest security. On the basis of the trading signal issued 1993). They have also been applied to neural network
by the network, either the low-risk security is sold and weight optimisation (Whitley 1995).
shares are bought (buy signal), or vice-versa (sell signal). The performance of genetic algorithms relies funda-
The general approach is to first discover a set of net- mentally on the formulation of an objective function that
work weights representing a trading strategy that per- is able to evaluate the success of competing individuals in
forms well on a set of training data, and to then apply this solving the problem at hand. Since we wish to discover a
same trading strategy to a set of test data. neural trading agent that is able to maximize returns, we
must formulate an objective function that determines the
return made by the agent over data representing the value
3. Backpropagation Training
of the index over some period of time. The optimality of
The traditional approach to neural network weight opti- the agent’s decisions can be measured in terms of the
mization is backpropagation training (Rumelhart & monetary return in following the agent’s decisions.
McClelland 1986). This is a supervised training algorithm Assuming that the investor has a choice of investing
that relies on the availability of a set of labelled training her capital in either shares or a low-risk fixed interest se-
data. Thus, in order to apply backpropagation training to curity, the accumulation of wealth over a period of N days
this problem domain, we require the training data to be can be expressed as:
labelled with buy and sell decisions which result in good

∑ {[ δ ][ ] }
N
performance over the data representing the training pe-
W N = W0 + t −1 rm ,t + (1 − δ t −1 ) r f × 1 − δ t'−1 c × Wt −1
riod. How might one go about labeling the training data?
t =1
One approach to labeling the training data is to have
an expert label the data with optimal trading points. While where Wt is the total wealth at day t, rf is the return rate of
one difficulty with this is that experts will not necessarily the fixed interest security calculated daily, rm,t = (It - It-1) /
agree on what the optimum buy and sell points are, a It-1 is the market return at day t where It is the share price
more profound concern is the interpretation of a neural at time t, δt-1 is a delta function which equals 1 if capital is
network trained on such expert assigned data. The expert invested in shares at the completion of trading day t-1 and
will undoubtedly use rules of thumb in assigning the 0 otherwise, c is the commission rate on a trade, and δ t'−1
training labels, and any network trained on such data will
merely result in a neurally encoded (approximate) repre- is a delta function which equals 1 if a trade occurs at the
end of day t-1 and 0 otherwise. Thus, the first factor ap-
sentation of the decision strategy used by the expert.
To avoid these problems we automate the labeling of pearing in the summation represents the daily return rate
data by assigning an example a buy target if a decision to that is applicable for the current day (i.e. the market return
rate or the fixed interest return rate), the second factor
buy on the day represented by that example would have
resulted in a profit. Similarly, an example is assigned a provides an adjustment for the cost of transactions, and
sell target if a decision to sell would have resulted in a 1
In practice, one should factor in trading costs into the labelling
profit. In other words, all points in a downward trend are procedure. That is, the relative increase or decrease in the value
labeled as sells, and all points in an upward trend are la- of the stock may not be sufficient to offset the cost of the trans-
beled as buys. Thus, assuming a one-point trading strat- action. We ignore transaction costs in the labelling procedure on
egy, trades will take place at every peak and trough. the grounds that the network will not be able to model the train-
The justification for this labeling procedure is that it ing data perfectly, and that small increases/decreases are not as
results in the best possible return that could have been important as larger ones. That is, it is the larger in-
creases/decreases that are more important in regards to perform-
ance on future data.
the third factor is the wealth at the close of the previous sponding to a buy-and-hold strategy are respectively
day’s trading. The return at the end of the trading period 14.9% and –5.2%.
is just the change in wealth divided by the initial wealth Testing the traders over a longer period can be
i.e. r = (WN – W0) / W0 , and it is this quantity which we achieved using a moving windows approach in which the
wish to maximize. training/testing set windows are advanced by N days after
Genetic search proceeds as follows. A population of each training/testing cycle, where N is the number of days
individuals, each representing a distinct neural network, is in each test period. The results of applying this approach
generated. Each of these networks is evaluated by fol- over an 880 day test period (i.e. 22 training/testing cycles)
lowing its trading predictions over the period represented are shown in Figure 2 (the results in Figure 1 correspond
by a set of historical training data and determining the to the last of these 22 cycles).
return at the end of this period. The fitness of an individ-
200%
ual is measured directly as the return that it is able to GA -trained netwo rk
180%
achieve. Reproduction, crossover and mutation operators B ackpro pagatio n-trained netwo rk
160%
are then applied to produce a new generation, with fitter 140%
B est P o ssible
individuals having a greater likelihood of contributing 120%
B uy-and-ho ld
offspring to the next generation. This procedure is al- 100%
lowed to proceed until either a predetermined number of 80%
generations has been reached, or until there is no further 60%
increase in fitness. At the completion of search, the best 40%
network is used to make buy/sell decisions over a test 20%
period. 0%
-20%
590 640 690 740 790 840
5. Empirical Results t ra ding da ys

This section presents results of applying of the above (a)


techniques to predicting buy and sell points for the Dow 20%
Jones Industrial Average index.2 The experiments are GA -trained netwo rk
B ackpro pagatio n-trained netwo rk
based on daily close values of the index over a period 15%
B est P o ssible
from July 1996 to March 2001. In all experiments, the 10% B uy-and-ho ld
input variables used were Pt-1 (the closing price of the
index on the previous trading day), MA5, MA10, MA15, 5%
MA30, and MA60 (the 5, 10, 15, 30 and 60 day moving
averages), based on commonly suggested trading rules 0%

(LeBaron et al 1999). All input variables were scaled -5%


linearly to the interval [0,1]. The size of the training win-
dow was set at 250 days. The network trained on this data -10%
was then applied to a test window consisting of the next 840 850 860 870 880
t ra ding da ys
40 trading days. We assume a low-risk fixed interest rate
of 4.0% per annum compounded daily, and a trading cost (b)
of 0.1% per trade. Figure 1. Single training/testing cycle (a) 250 day training
Figure 1a compares the performance of the back- cycle. The GA-trained network represents a better trading
propagation- and GA-trained networks over one train- strategy than the backpropagation-trained network; (b) 40 day
ing/testing cycle. Also shown are the best possible return test cycle. The GA-trained network achieves a 4.8% return in
and the return resulting from a buy-and-hold strategy. comparison to a return of 1.1% for the backpropagation-trained
Over the 250 day training period (Figure 1a), the buy and network.
sell decisions made by the GA-trained trader achieve a
120% GA -trained netwo rk
return of 59.1%, in comparison to a return of 28.0% for B ackpro pagatio n-trained netwo rk
the backpropagation-trained trader. The best possible per- 100%
B uy-and-ho ld
formance over the 250 day period is 199.7%, while a buy- 80% Fixed Interest
and-hold strategy results in a return of –6.8% (i.e. a loss).
60%
Over the 40 day test period (Figure 1b), the GA-
trained network achieves a return of 4.8% in comparison 40%
with a return of 1.1% for the backpropagation-trained 20%
trader. The best possible return and the return corre-
0%

-20%
2 0 200 400 600 800
This presumes the existence of an investment product (e.g. a
t ra ding da ys
unit trust) which purchases according to the make-up of the
index (i.e. the investment fund manager invests in all thirty Figure 2. Performance of traders over an 880 day forecast period
companies representing the index). using 22 training/testing cycles. The GA-trained network
achieves a total return of 128% over the test period (26.6% per
annum average return). The backpropagation-trained network
achieves a return of 48.0% (11.9% per annum average return).
Despite the fact that the backpropagation-trained
network models the training data poorly, it still appears to
Over the 880 day period, the average yearly return make some good trading decisions when projected onto
from following the decisions made by the GA-trained future data, resulting in an overall return slightly better
agent is 127.6% (26.6% per annum average return), while than that of a buy-and-hold strategy. However, this return
the return for the back-propagation-trained network is is significantly lower than that achieved by the GA-
only 48.0% (11.9% per annum average return). The buy- trained trader.
hold-return over the 880 day period is 27.2% (7.1% per
annum average return). The number of trades made by the 5.1 Performance on Random Walk Data
two networks over the 880 day period are almost identi-
cal—52 for the GA-trained network, and 54 for the back- Discovery of a neural network trader is based on the as-
propagation-trained network. sumption that patterns that have occurred in the past pro-
The relatively poor performance of the backpropaga- vide an indication of future movements in the value of the
tion-trained network can be attributed to its poor ability to index. Thus, the technique implicitly assumes that
model the training data presented to it. This poor ability is changes in the value of the index are not entirely random.
reflected in the relatively high mean square error on the How might we determine whether the predictability that
training data (approximately 0.25 on most 250 day train- we have observed in the Dow Jones Index data is real or
ing windows), and is due to the high frequency of trend anomalous?
reversals, many of which occur after only a marginal rise One way of testing this is to compare the perform-
or fall in the value of the index. ance on real data with performance on one or more sets of
There are at least two ways in which a better model random walk data. If performance on the random data is
for the training data could have been achieved: (i) using a found to be comparable with that on real data, then we
more complex network architecture; (ii) filtering out the cannot claim to have discovered any real predictability.
high frequency, low amplitude, fluctuations. While in- Random walk data for the Dow Jones Index can be
creasing the complexity of the network (i.e. increasing simulated by taking the sequence of relative daily changes
number of hidden layer units) would result in a network in the index value, and randomizing this sequence tempo-
better able to model the training data, this would most rally. That is, the same set of relative daily changes are
likely result in over-fitting and hence degraded generali- maintained, but the order in which these changes occur is
zation ability. While filtering out the smaller high fre- randomized. This means that the increase in the index
quency fluctuations in the training data would also result over the entire period will be identical for each time series
in a better model, the problem here is that there does not produced in this manner, thus reducing problems with
appear to be any objective means for deciding on a suit- biases that can arise from long term upward or downward
able filtering procedure, and the approach would be ad trends.
hoc.
13000 13000
12000 12000
11000 11000
10000 10000
9000 9000
8000 8000
7000 7000
6000 6000
5000 5000
0 200 400 600 800 0 200 400 600 800

(a) (b)
13000 13000
12000 12000
11000 11000
10000 10000
9000 9000
8000 8000
7000 7000
6000 6000
5000 5000
0 200 400 600 800 0 200 400 600 800

(c) (d)

Figure 3. (a) Dow Jones Industrial Average index values, (b) – (d) Random walk time series produced by temporally randomizing the
daily relative changes in the Dow Jones Industrial Average index.
Figure 3 shows the original Dow Jones Industrial In- References
dex data (Figure 3a) and three time series (Figures 3b,c,d)
generated by randomizing the sequence of relative daily Bäck, T. & Schwefel, H.P. 1993, ‘An overview of evolu-
changes as described above. Table 1 shows the average tionary algorithms for parameter optimization’, Evolu-
yearly returns achieved by GA-trained and backpropaga- tionary Computation, vol. 1, pp. 1-23.
tion-trained neural network traders on each of these da- Beltratti, A., Margarita, S. and Terna, P. 1996, Neural
tasets. Networks for Economic and Financial Modelling,
Thomson Computer Press, London.
Table 1. Avg. yearly returns of network traders on 4 datasets Goldberg, D.E. 1989, Genetic Algorithms in Search, Op-
Average yearly return timization and Machine Learning, Addison-Wesley
GA Backprop. Buy&Hold Publishing Company, inc., Reading, Ma.
Dow Jones 26.6% 11.9% 7.1% Holland, J. 1975, Adaptation in Natural and Artificial
Random_1 3.1% -4.5% 7.1% Systems, University of Michigan Press, Ann Arbor.
Random_2 4.6% 0.6% 7.1%
Random_3 12.3% 9.4% 7.1% Kimoto,T., Asakaya, K., Yoda, M. & Takeoka, M. 1990,
‘Stock market prediction system with modular neural
Each of the network traders perform better than a networks’, Proceedings of the IEEE International Joint
buy-and-hold strategy on the 3rd randomized dataset, but Conference on Neural Networks, pp. I1-I6.
worse than that of a buy-and-hold strategy on the other LeBaron, B., Arthur, W.B. and Palmer, R. 1999, ‘Time
random datasets. The GA-trained trader performs better series properties of an artificial stock market’, in Jour-
than the backpropagation-trained trader on each dataset. nal of Economic Dynamics & Control, vol. 23, pp.
Thus, while the network traders (in particular the 1487-1516.
GA-trained trader) may be able to find a trading strategy Malkiel, B.G. 1996, A Random Walk Down Wall Street,
that operates well on a set of (randomized) training data, 6th edn, W.W. Norton, New York.
this trading strategy is not able to satisfactorily predict
Rumelhart, D.E. & McClelland, J.L. 1986, Parallel dis-
good buy and sell points when projected into the future.
tributed processing: exploration in the microstructure
We can thus draw the weak conclusion that the predict-
of cognition (Vols. 1 & 2), MIT Press, Cambridge, MA
ability that we have observed in the daily movements of
the Dow Jones Index is not anomalous, but indicates some Weigend, A.S. & Gershenfeld, N.A. (eds) 1994, Time
regularity in the time series which can be exploited to Series Prediction: Forecasting the Future and Under-
make future decisions. standing the Past, Addison-Wesley, Reading.
White, H. 1988, ‘Economic prediction using neural net-
6. Conclusions works: the case of the IBM daily stock returns’, Pro-
ceedings of the IEEE International Conference on Neu-
The results reported in this paper illustrate that a genetic ral Networks, pp. II-451-II458.
algorithm-trained neural network trader performs signifi-
Whitley, D. 1995, ‘Genetic algorithms and neural net-
cantly better than a backpropagation-trained trader (with
works’ in Genetic Algorithms in Engineering and Com-
identical architecture) in deciding on good buy and sell
puter Science, eds G. Winter and J. Periaux, John
points on test financial data. Comparison of the perform-
Wiley, pp: 203-16.
ance of the traders on real data with performance on ran-
dom walk data lends support to the claim that the predict- Yoon, Y. & Swales, G. 1991, ‘Predicting stock price per-
ability observed on the Dow Jones index is real and not formance: a neural network approach’, Proceedings of
anomalous. the IEEE 24th Annual International Conference of Sys-
tems Sciences, pp. 156-62.

S-ar putea să vă placă și