Co‐evolved genetic programs for stock market trading

AuthorJason F. Nicholls,Andries P. Engelbrecht
Date01 July 2019
DOIhttp://doi.org/10.1002/isaf.1458
Published date01 July 2019
RESEARCH ARTICLE
Coevolved genetic programs for stock market trading
Jason F. Nicholls
1
|Andries P. Engelbrecht
2
1
Department of Computer Science, University
of Pretoria, Pretoria, South Africa
2
Department of Industrial Engineering and
Computer Science Division, Stellenbosch
University, Stellenbosch, South Africa
Correspondence
Jason F. Nicholls, Department of Computer
Science, University of Pretoria, Pretoria, South
Africa.
Email: jason.nicholls@tuks.co.za
Summary
The profitability of trading rules evolved by three different optimised genetic pro-
grams, namely a single population genetic program (GP), a cooperative coevolved
GP, and a competitive coevolved GP is compared. Profitability is determined by trad-
ing thirteen listed shares on the Johannesburg Stock Exchange (JSE) over a period of
April 2003 to June 2008. An empirical study presented here shows that GPs can gen-
erate profitable trading rules across a variety of industries and market conditions. The
results show that the cooperative coevolved GP generates trading rules perform
significantly worse than a single population GP and a competitively coevolved GP.
The results also show that a competitive coevolved GP and the single population
GP produce similar trading rules. The profits returned by the evolved trading rules
are compared to the profit returned by the buyandhold trading strategy. The
evolved trading rules significantly outperform the buyandhold strategy when the
market trends downwards. No significant difference is identified among the buy
andhold strategy, the competitive coevolved GP, and single population GP when
the market trends upwards.
KEYWORDS
coevolution, cooperative coevolution, competitive coevolution, genetic programming,
Johannesburg Stock Exchange, stock market trading, technical analysis
1|INTRODUCTION
A genetic program (GP) is a domainindependent metaheuristic algo-
rithm that genetically breeds a population of computer programs to
solve a problem (Koza & Poli, 2005). Metaheuristic algorithms search
the solution space by avoiding parts of the search space that produce
poor solutions. The result is an approximate solution to the optimisa-
tion problem under consideration (Bäck, 1996; Bäck & Schwefel,
1996; Engelbrecht, 2007; Fogel, 2006a).
Originally developed by Koza (Koza, 1992) in the late 1980s to
evolve computer programs, a GP can evolve trading rules using basic
mathematical operations. Allen and Karjalainen (Allen & Karjalainen,
1995; 1999) used a GP to evolve trading rules for the S&P 500 index
using daily prices from 1928 to 1995. Their approach used a single
population of individuals to evolve a trading rule over a fixed number
of generations. The single population GP of Allen and Karjalainen was
reimplemented by Neely et al. (Neely et al., 1997), Telbany
(ElTelbany, 2004), Mahfoud and Mani (Mahfoud & Mani, 1996; Mani
et al., 1995), Li and Tsang (Tsang, 2009; Tsang et al., 1998), and
Potvina et al. (Potvina et al., 2004) with varying degrees of success.
In nature, populations rarely evolve in isolation. Instead, popula-
tions evolve in cooperation with other populations or in competition
with other populations (Rosin & Belew, 1997). This paper proposes a
cooperative and competitive coevolutionary approach to GP for
evolving trading rules. The performance of trading rules evolved
through cooperative and competitive coevolution is compared to
trading rules derived by the single population GP of by Allen and
Karjalainen (Allen & Karjalainen, 1995, 1999). It is shown that co
operative coevolved GP generated trading rules perform significantly
worse than trading rules generated by a single population GP and a
competitively coevolved GP. The results also show that a competitive
coevolved GP and the single population GP produce similar trading
rules. The profits returned by the evolved trading rules are compared
to the profit returned by the buyandhold trading strategy. The
Received: 2 May 2019 Revised: 26 August 2019 Accepted: 26 August 2019
DOI: 10.1002/isaf.1458
Intell Sys Acc Fin Mgmt. 2019;26:117136. © 2019 John Wiley & Sons, Ltd.wileyonlinelibrary.com/journal/isaf 117
results show that the evolved trading rules significantly outperform
the buyandhold strategy when the market, including fees trends
downwards. No significant difference is found among the buyand
hold strategy, the competitive coevolved GP, and single population
GP when the market (including fees) trends upwards.
Section 2 provides a short background on the use of technical anal-
ysis in stock market trading and the application of evolutionary algo-
rithms (EAs) in stock market trading. Section 3 discusses Allen and
Karjalainen's implementation of a GP for stock market forecasting
and how it was adapted for this study. Section 4 describes both co
evolved strategies in detail. Section 5 presents the empirical process
and stock market data used for the purpose of this study. Section 6
presents the results of the study. This paper is concluded by Section
7 which presents a summary of the findings and proposals for
future work.
2|BACKGROUND
Stock market analysis is generally exante, focusing on the impacts of
longterm cash flows, earnings and revenue. This type of exante anal-
ysis is known as fundamental analysis Peterson (2007). Fundamental
analysis focuses on analysing company fundamentals such as revenue,
assets, production rates, demand, and interest rates. Fundamental
analysis often relates back to the share price to determine the future
price. Analysis of the share price is known as technical analysis (Peter-
son, 2007). A belief that the share price reflects all known fundamen-
tal information is referred to as the efficient market hypothesis (EMH)
(Fama, 1965).
Charles Dow (Cowles, 1933; Edwards et al., 2007; King, 1934)
argued that the market is not completely efficient, but that fundamen-
tal information rather takes time to propagate through the market. The
propagation of fundamental information is therefore reflected in the
movement of the share price. Dow believed that if the share price is
on the rise, the probability of a continued rise is greater than a fall
and vice versa, resulting in a perceived direction overtime known as
a trend (Cowles, 1933; James, 1968; King, 1934). Dow proposed the
first scientific stock movement theory known as Dow theory (Bishop,
1961; Edwards et al., 2007). Dow theory states that a market is either
in an upward trend, downward trend, or continuing in the same direc-
tion (Bishop, 1961; Edwards et al., 2007; Rhea, 1993).
Technical analysis techniques use the historic share price to find
which of the three Dow trends the market is in and if the trend may
change. Knowledge of the trend, and if the trend is changing, gives
guidance as to when a trader should buy or sell a share. A simple mov-
ing average (SMA) is a technical analysis function used to determine
the current market trend. Summing the share price for nconsecutive
days before a specific day tand dividing the result by nreturns the
average price of the share over time for the day t.
A comparison of different moving averages can reinforce the trend
certainty. For example, if the 10day SMA follows the same direction
as the 50day SMA, then it can be assumed that the trend is set. If
the two moving averages do not follow the same direction, it could
signify a trend reversal. Brock et al. (Brock et al., 1992) examined
the returns generated by various SMAs against the Dow Jones Index
from 1897 to 1986. Brock et al. showed that when costs are excluded,
SMAs can generate profitable buy and sell rules. Many variations of
the SMA function exist. Two variations are:
the weighted moving average (WMA), defined as:
WMAðnÞ¼ωPtþðω1ÞPt1þþPtnþ1
ωþðω1Þþ þ1(1)
where P
t
is the opening, closing, high, or low share price on day t,ω
is a weight. In this example, ωis equal to n.
the exponential moving average (EMA), defined as:
EMAðnÞ¼αnPtþαn1Pt1þþαPtnþ1
αnþαn1þþα(2)
where α¼12
nþ1and αis the weight.
A common technique used to determine the trend using two dif-
ferent moving averages is to subtract the longer (i.e. slower) moving
average from the shorter (i.e. faster) one. A positive result indicates
an upward trend, a negative result indicates a downward trend, and
a zero result indicates a moment of uncertainty. In the 1960s, Appel
(Achelis, 2013; Bäck et al., 1997; Tilkin, 2001) subtracted a 26day
EMA from a 12day EMA, and called this the moving average conver-
gence divergence (MACD) (Achelis, 2013; Tilkin, 2001).
The SMA, EMA, WMA, and MACD are just four of the many tech-
nical analysis functions that exist (Edwards et al., 2007). Each function
requires a set of parameters that may be unique to a specific stock or
market. Technical analysis functions are combined to form a trading
rule. An example of a trading rule is to buy shares when the 20day
SMA is greater than its 50day WMA; otherwise sell the shares held.
Selecting which technical analysis functions to use, and determin-
ing the correct parameters to form a trading rule is an optimisation
problem. Bauer (Bauer, 1994) was one of the earliest researchers to
use a class of metaheuristics known as genetic algorithms (GAs) (Hol-
land, 1992) to optimise the combination of technical analysis functions
and parameters to maximise return on a set of stock trades.
A GA is based on simulated evolution (Bäck et al., 1997; Fogel,
2006b). Simulated evolution breeds a population of candidate solu-
tions called individuals to solve a specific problem (Koza & Poli,
2005). Specifically, GAs iteratively transform a population of individ-
uals into new generations of individuals by applying the analogue of
naturally occurring genetic operations. Each individual has a set of
phenotypes encoded as genes within a chromosome.
Friedman and Fraser (Bäck et al., 1997; Fogel, 2006b; Friedman,
1956) are recognised as the first to experiment with GAs. However,
it was Holland (Bäck et al., 1997; Holland, 1992, 2000, 1995) that
formalised the first version of a GA. Holland's emulation of evolution
used a fixed length binary string representation of a chromosome.
Rather than optimising which technical analysis functions to use
with which parameters for a given stock, a technical analysis function
118 NICHOLLS AND ENGELBRECHT

To continue reading

Request your trial

VLEX uses login cookies to provide you with a better browsing experience. If you click on 'Accept' or continue browsing this site we consider that you accept our cookie policy. ACCEPT