You are on page 1of 30

Computational Economics 16: 207236, 2000.

207
2001 Kluwer Academic Publishers. Printed in the Netherlands.

Genetic Programming Prediction of Stock Prices

M. A. KABOUDAN
Management Science and Information Systems, Smeal College of Business, Penn State Lehigh
Valley, Fogelsville, PA 18051, U.S.A., E-mail: mak7@psu.edu

(Accepted 10 August 1999)


Abstract. Based on predictions of stock-prices using genetic programming (or GP), a possibly
profitable trading strategy is proposed. A metric quantifying the probability that a specific time series
is GP-predictable is presented first. It is used to show that stock prices are predictable. GP then
evolves regression models that produce reasonable one-day-ahead forecasts only. This limited ability
led to the development of a single day-trading strategy (SDTS) in which trading decisions are based
on GP-forecasts of daily highest and lowest stock prices. SDTS executed for fifty consecutive trading
days of six stocks yielded relatively high returns on investment.

Key words: evolved regression models, stock returns, financial market analysis, nonlinear systems

1. Introduction

The application of genetic programming (or GP) to financial markets has been
rather limited with fewer than fifty papers found in the literature. Among these are
studies by Andrew and Prager (1994), Bhattacharyya et al. (1998), Chen (1996),
Chen (1998), Chen and Ni (1997), Chen and Yeh (1995, 1996, and 1997a, b), Chen
et al. (1998), Chidambaran et al. (1998), Eglit (1994), Kaboudan (1998a), Neely
et al. (1996), Oussaidene et al. (1996), and Warren (1994). This seems (at least to
the author) counterintuitive since (i) there exist high monetary financial rewards
for reasonably accurate forecasts of financial data and (ii) advancements in ge-
netic computations now furnish adequate and even relatively superior forecasting
techniques. Genetic programming will probably contribute improved forecasting
methods in the future.
In a way, this paper investigates what has been debated in the financial literature
for decades namely market efficiency. Maurice Kendall (1953) was the first to
suggest that stock returns follow a random walk. He implied that successive price
changes are random or independent of each other. Alternatively, (Pt Pt 1 ) = ut ,
where ut is a random variable drawn independently with E(ut ) = 0, and where
E(.) is the expected value or mean. Evidence of market efficiency during the
1960s and 1970s flooded the financial literature until the 1980s when anomalies
were documented. See Fama and French (1988) and Lo and MacKinlay (1988) for
example. Evidence supporting or refuting market efficiency is based on analysis of
208 M. A. KABOUDAN

price returns. Returns are defined as the percentage change in price over time or
Rt = (Pt Pt 1 )/Pt 1 .
It is natural to argue that traders are most interested in the price level (Pt ),
and one should be evaluating Pt instead. Evaluating returns is important if these
can be useful in computing accurate and statistically defendable price forecasts.
But returns have been shown to be either random or very highly complex. Studies
that document non-random behavior of returns and evaluate their chaotic beha-
vior (Brock et al., 1992; Hsieh, 1989; Kaboudan, 1998b; Scheikman and LeBaron,
1989) foster the notion of unpredictable returns. Whether random or non-random
with complex dynamics, the question of whether genetic programming can predict
them remains unanswered. If returns are unpredictable, one still needs to determine
whether prices are predictable; and if they are one would want to find out if their
forecast is better than price forecasts computed from returns forecast. To elaborate,
assume that one needs to predict tomorrows price of a stock. One may attempt to
predict returns then use them to forecast tomorrows price. Alternatively one may
estimate a model that predicts price levels, use it to generate tomorrows price
forecast and then, if interested, compute tomorrows return. While both meth-
ods generate price forecast errors, the natures and magnitudes of the errors are
significantly different and influence trading decisions differently. Natures and mag-
nitudes of errors and their impact are clarified in Section 4 below after presenting
a foundation for the discussion.
While forecasting returns seems almost impossible, predicting price levels is
an intriguing, challenging, and admittedly risky endeavor. Generally, an analyst
who desires to predict any variable faces three challenges: the first is to determine
whether the variable is predictable. To determine whether it is predictable, a test
based on an -metric (Kaboudan, 1998c) is used. A complete review of it is in the
next section. The metric measures the probability that a series is GP-predictable. By
design, the computed metric should approach zero for a highly complex variable
with signal badly distorted by noise. Alternatively, the computed metric should ap-
proach one for a variable with low complexity and loud signal. If a series estimated
-metric indicates GP-predictability, the analyst deals with the second challenge:
identifying the factors that explain variation in the series. The third challenge is
perhaps most difficult. It is the determination of a data generating process (DGP
for short) that best reproduces the dynamics of that series. If the first two challenges
have been successfully met, genetic programming aspires to carrying out the final
complex task of finding the fittest DGP.
Forecasting one-day-ahead price levels is a modest but hopefully achievable
objective for now. Attempts to forecast stock prices for more than one day ahead
were unsuccessful and the task is left for future research. While gains from success-
fully forecasting a few days ahead would be greater, it is still possible to benefit
from forecasting intra-day fluctuations. Traders should be able to profit from both
positive and negative daily price movements. If positive movements are expected,
traders should take long positions. If negative ones are expected traders should
GENETIC PROGRAMMING PREDICTION OF STOCK PRICES 209

take short positions. If a trader buys then later sells, this trader has taken a long
position. In a short position, the trader sells before buying the stock. The broker
actually borrows the stock from another individual (or account) holding a long
position assuming availability. Here are two examples of long and short positions to
demonstrate profitable trading within a given day based on price level forecasting.
Assume first that a one-day-ahead GP-forecast predicts that the closing price of a
specific stock is $102.5. Assume further that the stock opens at $100 for that day.
If one takes a long position, i.e., buys at $100.25 and sells at $102.5, one nets $2
in profit if trading cost in commission is reasonable. (Buying at $100.25 instead of
$100 assumes that price changes by the time the order is executed.) To demonstrate
profitable trading when prices are falling, assume in the previous example that the
stock opens at $102.5 and GP predicts a close of $100. Then one would sell first
(or take a short position) at $102.25 then buy (or cover that short position) when
the price falls to $100. This trade also provides a return of 2% if one pays the
stocks full price. A higher percentage return is possible if one buys long or sells
short on margin. In margin trading, the investor pays only 50% of the transaction
cost. (Margin trading is possible only if the price of the stock is > $5.) The broker
holds the securities bought for collateral and lends the remaining 50% of cost to
the buyer or seller who pays interest at or just above the prime rate. However, no
interest is charged if one buys and sells within the same day, regardless of order
of occurrence. Financing 50% of the transaction cost increases daily net return in
the above-mentioned examples to 4%. These two hypothetical examples (of long
and short trading positions) assume accurate GP forecasting. While GP forecasting
may not provide a high level of accuracy yet, it is shown below that profitable
trading is enhanced when using GP forecasts even if they are less than perfect.
While generating reasonable one-day-ahead stock price forecasts is the object-
ive, the aim in this paper is to introduce a new trading strategy. The proposal is of
a single-day trading strategy (SDTS) where a trader buys and sells stocks the same
day using GP-forecasts of next days highs and lows. Prior to presenting SDTS, it is
suggested that one should test predictability of stock prices, and a GP-predictability
of time series measure is reviewed first. It is then used to show that stock prices
have a higher chance of being predicted than returns, and that computed prices
from predicted returns yield higher errors than those obtained from GP-models
that directly predict prices. However, GP-prediction of stock prices is conditional.
As will be demonstrated later, GP-forecasts appear to be reasonable only when
exogenous factors that affect price movements radically are absent. Examples of
such factors are firms announcing earnings warnings or mergers and acquisitions
news occurring while the markets are closed. Such exogenous events render GP
price-forecasts useless. Therefore, in the absence of exogenous disruptions, if stock
prices are in fact predictable, then price formation may be inefficient, and if the
resulting yet to find possibly nonlinear specifications GP price models can be used
to compute returns, then stock prices do not follow random walk. Reluctantly, this
suggests the existence of market efficiency only to the extent of incorporating news
210 M. A. KABOUDAN

affecting stock price movements into trading prices and traders cannot make any
profit from such news. Alternatively, it appears then that prices continue to be
predictable so long as there is no price-moving news.
The GP-predictability measure applied to stock prices indirectly capitalizes on
existing literature suggesting market inefficiencies and non-randomness of prices.
Based on examples of anomalous evidence of market efficiency brought together
in a special issue of the Journal of Financial Economics, Jensen (1978) concludes
that the Efficient Market Hypothesis (EMH) has more solid empirical evidence
supporting it than any other proposition in economics. There are recent studies
that strongly suggest rejection of EMH. See for example, Jegadeesh (1990), Leh-
man (1990), Hsieh (1991), and Richardson and Smith (1993). More importantly,
Lo and MacKinlay (1988) reject the random walk hypothesis for weekly stock
market returns and explain that the rejection of the random walk model does not
necessarily imply the inefficiency of stock-price formation. Lo and MacKinlay
(1999) present a more complete and comprehensive study of evidence rejecting
the random walk model in Part I of their book. In Part II, they review the issue of
predictability of returns and investment risk. Their conclusions represent modern
thought in financial economics. The current paper draws on their views. It presents
new evidence suggesting non-random walk, presents a measure of predictability
of stock prices, and proposes single-day trading strategy. Although a comparison
between work presented here and modern thought is desirable, it is left for future
research. The reason for not exploring the comparison here is the need to investig-
ate risk associated with single-day trading first. The risk associated with single-day
trading is different in nature than risk associated with long term investment. As-
sessment of risk associated with long term investments attracted attention after the
development of the Sharpe-Lintner capital asset pricing model (CAPM). CAPM is
not helpful when the longest period a position held is less than a single trading day.
By design SDTS minimizes the risk of holding a long or short position overnight.
It is basically a trading strategy that takes advantage of stock trading daily market
disequilibrium conditions.
The balance of this paper contains four other Sections. The next one introduces
the method of evolving regression models using GP. A review of the test used to
evaluate GP-predictability of time series is in Section 3 where after the tests formal
introduction; it is applied to series with known dynamics. Section 4 begins by
applying the test to prices and returns of six stocks (Citigroup, Compaq Computers,
General Electric, Pepsi, and Sears symbols C, CPQ, GE, PEP, and S, respectively,
on the NY Stock Exchange, and Microsoft symbol MSFT on the NASDAQ). These
stocks (analyzed by the author for a few years) were selected because they trade
a reasonably heavy volume daily. Such heavy volume is needed to implement a
single-day-trading-strategy (SDST) proposed in Section 4. There, trading rules are
proposed and GP-forecasts of daily high and low prices of each stock over fifty days
are used to make and trading decisions. Section 5 contains concluding remarks and
discussion of future research.
GENETIC PROGRAMMING PREDICTION OF STOCK PRICES 211

2. Evolved Regression Models

GPQuick computer code written in C++ (Singleton, 1995) produces all GP


runs in this study. (It is available from http://www.cen.uiuc.edu/klipp/research/
ssprob.Cxx/ and via anonymous ftp: node cs.ucl.ac.uk directory genetic/gp-code.)
GPQuick replicates an original GP program in LISP by Koza (1992). Both are com-
puter programs designed to randomly evolve regression models and determine the
one that replicates the series DGP best. This section contains a brief description
of how GPQuick was used in this paper.
GPQuick randomly evolves and finds the fittest regression model. Fitness
is measured by the regression sum of squared errors (SSE). The program ran-
domly selects and combines explanatory variables and operators to generate a
pre-specified number of equations known as a population. It keeps the fittest 10%
(equations with the lowest SSE statistics) of that first population and includes them
in the next generation of equations. The other 90% are replaced by new equa-
tions. The new ones are produced using a combination of crossover and mutation
processes. In crossover, one section of an equation is randomly exchanged with
another section from a different equation. In mutation one section of an equation
is replaced by a different set of variable(s) and operator(s). New regression models
continue to evolve until a pre-specified program termination condition is reached.
The program then saves the fittest equation and its statistics in an output file. In this
study, evolved models serve two purposes: (a) to evaluate series predictability, and
(b) to forecast with. Inputs to execute the program differ accordingly. The program
demands providing the following inputs needed to evolve the regression models:

1. It must be given individual files containing input data. The dependent and each
of the independent variables should be in separate files. To test predictability,
the independent variables are lagged-dependent ones. To evolve the fittest
model, other variables are used.
2. Whether evolving models to evaluate predictability or to forecast with, the
program must be given operators to select from. The operators used through-
out are: +, , , %, exp, sqrt, ln, sin, and cos, where %, exp, sqrt, and ln
are protected operators. These protections follow standards commonly used
in all GP software. They provide solutions to computational-problems com-
puters may encounter during the search for an equation. Such solutions are
intentionally formulated to yield less fit equations than those that the search
already identified without protections. (They prevent program halting during
execution.) The operator % is a protected division that returns a value = 1 if
the denominator in a division = 0. The operator exp is a protected exponential
which returns e10 if e is raised to a power more than ten. The operator sqrt is
a protected square root operation that returns the square root of the absolute
value of any argument. Finally the operator ln calculates the natural logarithm
of the absolute value of nonzero arguments and returns zero otherwise.
212 M. A. KABOUDAN

3. The program is also given instructions to use a random number generator that
produces random constants when evolving equations.
4. It must be given population size. Population size is 2,000 equations in runs
for testing and 5,000 in runs for forecasting. Smaller population sizes produce
faster runs but less accurate results. Since accuracy is needed when actually
searching for forecast models, it is only logical that the population size be
larger.
5. The program must be given a maximum length of arguments in an equation.
This maximum is set equal to fifty.
6. It must be given a condition to terminate the program. The program is set to
terminate if one of the equations produces SSE < 0.00001 or if the number
of equations reaches 20,000 when testing predictability and that number is in-
creased to 80,000 when evolving forecast models. These criteria were selected
to produce reliable results within reasonable time as determined by trial and
error.

3. A GP-Predictability Test
The -metric applies to time series in general. It is useful in two ways. Given
a variable Yt , the metric may be used to test the null hypothesis: Ho : Yt is GP-
predictable, versus the alternative: Ha : Yt is not GP-predictable. Given two series
Y 1t and Y 2t , where Y 1t 6 = Y 2t , the metric may be used to test the hypothesis:
Ho : Y 1t and Y 2t are equally GP-predictable, versus the alternative: Ha : Y 1t and
Y 2t are not equally GP-predictable. Completing these tests has obvious benefits.
The first test helps prevent prematurely deciding that an observed sequence of data
is unpredictable. Completing the test is important because GP is a random search
mechanism for the best DGP. It searches the SSE space for a global minimum.
Therefore, it is conceivable that occasionally the program gets trapped in a local
minimum and produces an inferior model. Consider two situations. In one, the
observed sequence cannot be predicted because it is simply random. In the other,
the observed sequence is predictable but GP produces poor results. One falsely
concludes that the second sequence is unpredictable or random. An estimate of
may prevent this misidentification. The second test compares the predictability of
two variables. Although not used in this study, this second test can help in deciding
which variable to predict when more than one is available for use.
To compute two SSE statistics must be calculated: one is from GP prediction
of a series and the other is from its randomly scrambled sequence. The idea is rather
simple. One randomly shuffles the sequence of an observed data set using Efrons
(1982) bootstrap method. Bootstrapping generates an equally long new series by
randomly sampling from the original set. Sampling may be with or without re-
placement for long series but according to statistical theory sampling should be
without replacement for short series. Therefore, it is only logical that sampling be
always without replacement. If the observed data contained any signal, shuffling
GENETIC PROGRAMMING PREDICTION OF STOCK PRICES 213

dismembers this signal and the two SSE representations will be significantly dif-
ferent. They will be very similar if the observed data were pure noise. This logic is
intuitive but its efficacy is unknown. Efficacy is determined by applying the test to
data with known dynamics. The tests development is presented first.

3.1. METHODOLOGY

The GP-predictability measure uses an idea similar to an approach proposed by


Oakley (1996). His test compares two outcomes: the best fit from 50 GP-runs
for a single data set before shuffling with the best from 50 GP-runs of the same
set after shuffling. If the original data set is deterministic the two outcomes will
be different; otherwise they should be very similar. Unlike Oakleys the proposed
method quantifies predictability by a metric . It is based on measuring the relative
change in GPs ability to explain variation in a variable Y if its
Psequence is shuffled.
The unexplained variation in Y before shuffling is SSE Y = Tt=1 (Yt Yt )2 , where
Yt = the predicted Yt . Shuffling increases
P the unexplained variation in Y to a
maximum. This maximum is SSES = Tt=1 (St St )2 where St is the shuffled Yt .
Assuming that unexplained variation is noise, then the ratio of noise in Y relative
to the maximum possible level of noise in such series is:
SSE Y
W = . (1)
SSE S
If series Y is a totally GP-predictable deterministic signal then SSE y = 0 and
W = 0, and if it is totally GP-unpredictable noise or random SSEy = SSES and
W = 1. If W is the proportion of noise in a series, then the predictable proportion
or probability of predictability is (1 W ).
Equation (1) has two practical problems because GP randomly searches for
the best DGP depicting the dynamics of a system. First and as indicated earlier,
the search for a DGP may occasionally produce less than optimal result. Second,
the result of a single search is statistically inconsistent because repeated random
search will not generate identical DGPs unless that process is totally deterministic.
Completing a large number of GP runs (30) and evaluating an average (1 W )
instead may reduce the impact of these problems. Analyses in this study are based
on completing 100 GP runs and selecting the best 50 to average. The worst 50
are discarded to eliminate local minimum solutions. (Selecting 50 is subjective
but conservative. Experiments in this study showed that no more than 20% of the
runs are poor.) Accordingly, and to formalize the predictability measure, let =
Probability of Predictability = E(1 W ), or
n  
1X SSE Y
= 1 , (2)
n i=1 SSE S i

where n 30 runs to compute average predictability. Theoretically, 0 1.


The upper boundary of is strong because SSEY 0 and SSE S 0. But its lower
214 M. A. KABOUDAN

boundary is weak since for random data it is possible that more SSEY > SSES than
the otherwise, rendering < 0. Resolving this problem is simple given that its
source is obvious. If < 0 then is simply set equal to zero. Therefore, is the
following conditional measure:
( n  )
1X SSEY
= max 0, 1 . (3)
n i=1 SSES i

If for a given time series Yt , the estimated = 1, then this series is 100%
GP-predictable. If the estimated = 0 (e.g., random data), that series is GP-
unpredictable. For 0 < < 1, the metric approximates the percentage of
GP-predictable structure in the series. To test whether Yt is GP-predictable, the
null and alternative hypotheses become: Ho : r, and Ha : < r, respectively,
where r is a discretionary ratio representing level of predictability to test. To test
the null hypothesis that Yt is at least r = 90% GP-predictable for example, the null
hypothesis to test that 0.90 can be tested by the statistic
h
z= , (4)
sh n
where h is the estimate of , n is the size of the averaged sample, and sh is the
sample standard deviation, i.e.,
v
u n
uX
u (hi h)2
u
t i=1
sh = . (5)
n1
The z-statistic is appropriate since h is a mean based on a sample 30. (For a
description of this test and conditions to use it, see Mason et al. (1999), p. 317.) To
use this test, is estimated, the r to test is selected, the z-statistic calculated using
Equation (4), and a decision is made. The computed statistic z then helps decide
whether to reject Ho or not. At the 5% significance level for a one-tailed test, Ho is
rejected if z < 1.645.
This test is acceptable since GP-prediction of historic values of a Y variable
yields models characteristically different from ones conventional statistical and
econometric methods produce. Generally, statistical and econometric methods seek
to identify logically and statistically defendable relationships between a depend-
ent variable and a set of independent variables. These methods may occasionally
capture spurious correlation between variables. This problem produces a spuri-
ous regression where a statistical fit is found when in fact there is none. (Further
discussion of this problem is in Mills (1993) and Greene (1997).) When using
OLS, if the dependent variable follows a random walk the regression is spurious
and OLS would not yield consistent parameter estimators given that the Gauss-
Markov theorem does not hold. (See Pindyck and Rubinfeld, 1998, p. 507). GP is
GENETIC PROGRAMMING PREDICTION OF STOCK PRICES 215

different because it is a technique that employs random search for a mathematical


fit regardless of the existence of a defendable correlation between variables. GP
has no statistical foundation. It is based on heuristics. A users selection of the
most logical variables to explain variation of Y is only motivated by finding a best-
fit equation. Frequently, the resulting GP-equation is complex, unusual, and almost
impossible to translate into meaningful relationships between the independent vari-
ables and the dependent one. In the absence of a statistical foundation and with final
models non-interpretable, investigating the problem of spurious regressions in GP-
produced models is perhaps not warranted and for now is beyond the scope of this
investigation. Undoubtedly, investigating this problem becomes important if and
when GP is used to identify a functional relationship rather than a mathematical
fit.

3.2. TEST EVALUATION

Efficacy of the proposed predictability test is determined by controlled experiment-


ation. Experimentation employs artificially generated series with known statistical
properties. These series are from different DGPs including strictly linear, nonlinear,
linear- and nonlinear-stochastic, and pseudo-random. Data generated by chaotic
processes are given special attention since they provide complexly rich determin-
istic dynamics. Studies that investigated application of GP to chaotic dynamical
systems include Fogel and Fogel (1996), Mulloy et al. (1996), and Oakley (1994,
1995, 1996). Each DGP generates a single data set that is randomly scrambled
as described earlier. GPQuick is then used to evolve the best DGP for each pair
the original set and its scrambled sequence. Individual variables (original or
scrambled) are represented by data sets containing 112 observations each: twelve
are lost degrees of freedom in explanatory variables, and 100 are the data used to
search for the best (or fittest) equation. Stated differently, for any variable (original
or shuffled) Yt = f (Yt 1, . . . , Yt 12).
Two experiments were completed using artificially created series. Because
all experimental data are simulated, measurement noise is assumed nonexistent
and properly estimated models should produce dynamical noise that should be
approximately normally distributed with constant variance. The first experiment
employs thirty data sets. They are constructed from these known nonlinear chaotic
dynamical systems:
1. The Henon map (Henon, 1976):

Yt = 0.3Yt 2 + 1 1.4Yt21 . (6)

2. The logistic map (May, 1976):

Yt = 4 Yt 1(1 Yt 1 ) . (7)
216 M. A. KABOUDAN

3. The tent map (Wolfe and Vastomous, 1986):



2Yt 1 if Yt 1 < 0.5 ,
Yt = (8)
2(1 Yt 1) if Yt 1 0.5 .

These maps furnish three data sets of pure signal. The remaining twenty-seven sets
in this first experiment are variations of these signals contaminated with different
noise levels. Noise was generated using the statistical software package RATS (or
Regression Analysis of Time Series by Estima). Twenty-seven normally distributed
pseudo-random series with a mean of zero and a constant variance 2 = 1 (or j
is N (0, 1) for j = 1, 2, . . . , 27.) were generated. They are used to construct
new series differentiated by their signal-to-noise ratio. Signal-to-noise ratio is a
standard measure of complexity defined as = sY2 /s2 , where sY2 is sample variance
of the signal and s2 is that of noise . Here is how signals were contaminated to
yield new series with desired different signal-to-noise ratios: first a signal Yt is gen-
erated (using one of Equations (6)(8)) and its variance is computed. Then RATS
produces the pseudo-random data t . If one constructs a new series Xt = Yt + t
its = (sY2 /s2 ) = sY2 given that s2 = 1 by construction. Now define the desired
signal-to-noise ratio = sY2 /c2 s2 , where c is a computable adjustment constant.
This constant is used to produce a new series with the desired level of contam-
ination. By definition, the variance of the generated pseudo-random numbers is
s2 = [{6(t )2 }/(n 1)]. Then c2 s2 = [{6(ct c )2 }/(n 1)] where is the
mean of t . Accordingly, each value of t is multiplied by the constant c and data
sets with the desired noise levels are:

Xt = Yt + ct . (9)

Nine contaminated series with = 1, 5, 10, 15, 20, 30, 40, 50, and 60 were
generated from each of the three chaotic signals using this method. Contamination
of the original signal is static rather than dynamic to preserve stationarity of these
processes. Dynamic contamination involves adding ct to the right-hand-side of
each of Equations (6)(8) instead. Such periodic addition of noise creates solutions
that reach infinity quickly whereas static addition of noise helps create endless
series. Further, given that this data is simulated, measurement noise is assumed
nonexistent and properly estimated models should produce dynamical noise that is
N(0, 2 ).
The second experiment employs data sets generated by known functional forms
but unknown signal-to-noise ratios. Most of them are functions often cited in
chaos and time series literature and include linear, transcendental, linear-stochastic,
chaotic but rational, nonlinear-stochastic, and pseudo-random. Other studies that
investigated time series using evolutionary algorithms include McDonnell and
Waagen (1994), Numata et al. (1998), and Sathyanarayan and Chellapilla (1996).
Here are the DGPs in this experiment:
GENETIC PROGRAMMING PREDICTION OF STOCK PRICES 217

1. OZ: this is a linear function known as the Ozaki equation (Ozaki, 1985):

Yt = 1.8708 Yt 1 Yt 2 . (10)

2. TF: this transcendental function is characteristically trigonometric (created


for this study):

Yt = 3.9 sin Yt 1 + 0.85 cos Yt 2 . (11)

3. EF: this transcendental function is with exponentially weighted coefficients


and has complex roots (Tong, 1990, p. 71):

Yt = (1.43 4.5eYt1 )Yt 2 .


2
(12)

4. AR2: this is a linear-stochastic autoregressive model where t N(0, 1)


(also created for this study):

Yt = 0.6Yt 1 + 0.15Yt 2 + t . (13)

5. BL: this is a bilinear nonlinear-stochastic function (Granger and Andersen,


1978):

Yt = a Yt 1 + b t Yt 1 + t , (14)

where t N(0, 1) and a = 0.3 and b = 0.6, where for stationarity


a 2 + b2 < 1.
6. MG: this is a rational chaotic function known as the MackeyGlass equation
(Mackey and Glass, 1977):

0.2yt 30
Y = + 0.1yt , (15)
1 + yt1030

where the left-hand side is the first derivative of Y . The generated data was
approximated by a discrete set using the fourth order RungeKutta technique.
7. GR: this is a nonlinear-stochastic function in the form of a generalized autore-
gressive model with conditional heteroscedasticity or GARCH(1,1) process
(Hsieh, 1989):

Yt = t ht ,
(16)
ht = 1 + 0.25Yt21 + 0.7ht 1 ,

where t N(0, 1).


8. GS: this is a Gaussian random set produced using RATS.
9. ER: this is an exponentially random set also produced using RATS.
218 M. A. KABOUDAN

Results of the two experiments are in Tables I and II. Table I presents the GP-
predictability probabilities of series with different signal-to-noise ratios and their
hypotheses testing. The first column identifies each series by its levels where
= identifies noise-free signals. The estimated -probability (h) for each of
the three maps and their contaminated series are in the second column followed
by the standard error (sh / n) of each estimate. Using Equation (4), is computed
at z = 1.645. These computations are in the last column of the table. They are
the r levels at which Ho : r cannot be rejected. The results suggest that
predictability chances deteriorate as (or signal-to-noise ratio) decreases. The
three discrete chaotic maps without noise are fairly predictable. At the 5% level
of significance and = or a series of pure signal with no noise, there is a
95% chance that the Henon, logistic, and tent maps are at least 94.1%, 97.9%,
and 92.8% predictable, respectively. Predictability decreased with the introduction
of very low noise. At = 60, there is a 95% chance that they are 87.1%, 87%,
and 85% predictable, and so on. Table II is similar in construction but represents
the series ranging from totally predictable to totally unpredictable included in the
second experiment. These results furnish phenomenalogical evidence suggesting
that time series with different complexity are not equally predictable.

4. Stock Prices
The method presented in the previous section can now be used to test the predict-
ability of stock market data and more specifically to test the hypothesis that stock
prices and returns are equally predictable. If test results suggest that price levels
are more predictable than returns, one uses GP to evolve the fittest price model to
forecast with. The forecast can then be used to make trading decisions that would
increase returns on investment or (ROI). To increase ROI one must formulate a
trading strategy first. Such a strategy should accommodate stock market uncer-
tainties and limitations of GPs forecasting ability. Accordingly, the predictability
test is applied to closing daily prices and returns of C, CPQ, GE, MSFT, PEP,
and S first. Next, predicted prices and prices computed using predicted returns
are compared to lend more support to the argument made. After confirming that
returns are relatively less GP-predictable, GP forecasts of daily closing prices are
compared with simple baseline (nave) price forecast strategy where Pt = Pt 1 .
This comparison is interesting since it delimitates the gains from using GP in
financial forecasting. Next, the trading strategy is formulated and the variables to
forecast are accordingly identified. The two methods GP and nave, referred to
hereon as GPM and NM are then used to produce two forecasts (GP and nave).
Finally, ROI from trading decisions based on the two forecasts are compared.
GENETIC PROGRAMMING PREDICTION OF STOCK PRICES 219

Table I. Hypotheses testing of data with known complexity.

h Standard Do not reject


error Ho :

Henon:
0.932 0.005 0.941
60 0.868 0.002 0.871
50 0.851 0.001 0.854
40 0.834 0.002 0.836
30 0.764 0.002 0.767
20 0.718 0.001 0.720
15 0.672 0.001 0.673
10 0.538 0.003 0.543
5 0.524 0.001 0.527
1 0.156 0.001 0.157

Logistic:
0.976 0.002 0.979
60 0.870 0.000 0.870
50 0.836 0.000 0.837
40 0.800 0.000 0.800
30 0.783 0.000 0.783
20 0.745 0.000 0.745
15 0.539 0.000 0.540
10 0.525 0.001 0.526
5 0.285 0.001 0.287
1 0.000 0.001 0.000

Tent:
0.922 0.004 0.928
60 0.845 0.003 0.850
50 0.863 0.003 0.868
40 0.824 0.002 0.828
30 0.632 0.009 0.647
20 0.601 0.006 0.610
15 0.539 0.006 0.550
10 0.528 0.001 0.530
5 0.374 0.002 0.378
1 0.000 0.002 0.000
220 M. A. KABOUDAN

Table II. Hypotheses testing of data with unknown complexity.

h Standard Do not reject


error Ho :

OZ 0.995 0.000 0.995


TF 0.905 0.004 0.912
EF 0.597 0.004 0.604
AR1 0.470 0.007 0.481
BL 0.440 0.008 0.453
MG 0.360 0.005 0.368
GR 0.036 0.002 0.039
GS 0.000 0.002 0.000
ER 0.000 0.005 0.000

4.1. PREDICTABILITY OF STOCK PRICES AND RETURNS

To test the null hypothesis that a stocks prices and returns are equally predictable
their metrics are estimated. If they are statistically different (as should be expec-
ted) the null hypothesis that they are equally predictable is rejected. For each stock,
actual closing prices and returns for 112 trading days (AprilNovember 1998) are
used to evolve models. GPM in-sample predictions of prices and returns for each
day per stock were produced. To estimate their respective representations, their
in-sample scrambled sequences should be predicted first. Each stocks series of
returns were bootstrapped to obtain their randomized sequences. Randomized price
levels were produced differently. Scrambled prices were computed after bootstrap-
ping their periodic price changes. Here is how: first actual daily price changes
or 1Pt = Pt Pt 1 are computed then bootstrap-shuffled. These produce the
scrambled price series:
St = Pt 1 + ut , (17)
where ut is the scrambled sequence of 1Pt . This provides price series with ran-
dom changes that should help determine whether returns contain GP-predictable
information. GPM was then used to obtain predictions of the scrambled series and
the estimates were computed.
Statistically, price levels were found to be more predictable than returns.
Table III contains a comparison of results representing a sample of ten days per
stock. The estimate of for price levels is hP and for returns is hR . Rather than
testing Ho : r using the z-statistic defined in Equation (4), the equation is used
to calculate the level at which Ho cannot be rejected (similar to computations
in Tables I and II). These computations are in the column labeled in Ho :
of Table III. Clearly, the information provided suggests that price predictability is
higher than returns predictability for all stocks in all days reported. Figures 1a, b
GENETIC PROGRAMMING PREDICTION OF STOCK PRICES 221
Table III. Predictability of prices and returns using models representing ten days.

hP Ho : hR Ho : hP Ho : hR Ho :

C: CPQ:
0.580 0.582 0.000 0.000 0.551 0.553 0.313 0.322
0.621 0.623 0.000 0.000 0.575 0.577 0.340 0.343
0.596 0.598 0.000 0.000 0.637 0.639 0.000 0.000
0.639 0.640 0.177 0.183 0.736 0.739 0.000 0.000
0.703 0.705 0.000 0.006 0.575 0.578 0.000 0.000
0.616 0.618 0.114 0.121 0.551 0.555 0.015 0.022
0.532 0.535 0.000 0.000 0.577 0.581 0.000 0.000
0.569 0.571 0.025 0.033 0.481 0.484 0.122 0.128
0.513 0.515 0.000 0.000 0.668 0.670 0.000 0.000
0.717 0.719 0.212 0.216 0.718 0.720 0.113 0.117

GE: MSFT:
0.641 0.646 0.000 0.000 0.641 0.644 0.000 0.000
0.630 0.633 0.000 0.000 0.505 0.509 0.080 0.082
0.725 0.727 0.000 0.000 0.686 0.688 0.000 0.000
0.595 0.597 0.000 0.000 0.653 0.654 0.174 0.180
0.621 0.622 0.000 0.000 0.640 0.642 0.000 0.000
0.705 0.707 0.000 0.000 0.526 0.527 0.000 0.000
0.589 0.590 0.000 0.000 0.524 0.526 0.123 0.127
0.676 0.679 0.000 0.000 0.635 0.636 0.096 0.103
0.633 0.635 0.028 0.033 0.680 0.682 0.056 0.061
0.603 0.604 0.000 0.000 0.603 0.604 0.047 0.051

PEP: S:
0.670 0.676 0.000 0.000 0.603 0.605 0.000 0.000
0.534 0.536 0.076 0.083 0.609 0.615 0.000 0.000
0.693 0.699 0.422 0.426 0.665 0.666 0.005 0.007
0.682 0.684 0.325 0.328 0.678 0.680 0.046 0.049
0.709 0.710 0.049 0.055 0.664 0.666 0.000 0.000
0.592 0.595 0.000 0.000 0.690 0.694 0.000 0.000
0.656 0.659 0.343 0.348 0.598 0.602 0.000 0.000
0.645 0.647 0.000 0.000 0.594 0.597 0.000 0.000
0.541 0.544 0.000 0.000 0.461 0.465 0.000 0.000
0.641 0.642 0.000 0.000 0.623 0.625 0.000 0.000
222 M. A. KABOUDAN

summarize these results. They manifest distinct GP-predictability of prices and not
returns and also suggest rejecting the null hypothesis that prices and returns are
equally predictable. The horizontal axes identify the six stocks. The vertical axes
show averages of estimates. These plots portray 95% confidence intervals of
mean estimates of the six stock prices (Figure 1a) and six returns (Figure 1b). If
predictability estimates of all six stocks are considered together, the overall 95%
confidence intervals of price predictability is 0.618 0.17 and of returns predict-
ability is 0.055 0.032. It is important to realize that these results only suggest that
returns are less predictable than prices when only lagged dependent variables are
used to explain variation in the dependent variable. Intuitively however, if prices are
predictable returns should also be predictable. Since GPs predictive ability relies
upon the appropriate selection of explanatory variables, this test then demonstrates
that one should search for those variables that explain variation in returns. This
issue is currently under investigation, and the results only confirm the difficulty
in finding those variables. Given the discussion above, returns are assumed less
predictable than price levels here.
This difference in predictability has implications. If one is really interested in
predicting prices and if prediction of returns is equally reliable, then one may
predict returns first then compute prices from those predictions. It is therefore ne-
cessary to determine whether computed prices using GPM predicted returns yield
equal or lower prediction errors than those produced by GPM predicted prices.
To accomplish this, the best price and returns equations (i.e., the one with the
lowest SSE) for each stock is used to produce predicted prices and computed price-
predictions. Computed price-predictions are Pt = Pt 1 R t where R t are the best
GPM predicted returns per stock. Given that the two predictions are no longer
statistically independent (since both are dependent on Pt 1 ), for each stock one
then tests the null hypothesis that the mean of the differences between absolute
predicted errors from the two models over the 100 days is not different from zero.
(A description of this test and conditions to use are in Mason et al. (1999), p. 370.)
Using the absolute errors avoids producing biased differences. To demonstrate why
bias may result assume that price prediction error for one period is +1.5 and for the
same period computed-price error is 1.5. The difference is (1.5 + 1.5) = 3. If
the absolute errors are taken instead the difference is (1.5 1.5) = 0. Clearly, the
absolute error method of difference computation is more appropriate since both
forecasts missed the true price by $1.5. A difference of 3 clearly overstates the
performance of one method over the other but taking the errors absolute values
shows that both errors were equally poor. Accordingly, the null hypothesis to test
is as follows: Ho : d = 0 versus Ha : d 6 = 0, where

1X
n
ud = (|e1i | |e2i |) . (18)
n i=1
GENETIC PROGRAMMING PREDICTION OF STOCK PRICES 223

Figure 1. Predictability of (a) price levels, (b) returns.

In equation (18), i is the number of predicted days, and |e1i | and |e2i | are individual
absolute errors of the ith predicted and computed prices, respectively. The test
statistic to use is:
d
t= . (19)
sd / n

where sd is the sample standard deviation of the differences. Table IV has the
resulting t-statistics. It also has the mean square errors (MSE) produced
P by each
equation. (These are the lowest MSE values, where MSE = n1 ni=1 (Yt Yt )2 .)
The table presents the test statistic for all differences together as well as overall
MSE. The information in Table IV clearly suggests rejecting Ho : d = 0 at the
224 M. A. KABOUDAN

Table IV. Testing mean difference between predicted and computed


predicted prices.

n t MSE
Predicted Computed

C 100 2.400 2.327 2.873


CPQ 100 2.895 0.831 1.405
GE 100 4.341 3.162 4.745
MSFT 100 4.097 1.636 2.158
PEP 100 2.611 0.987 1.788
S 100 2.695 1.910 2.707

All 600 6.374 1.809 2.613

5% level of significance. Thus, one should evolve price levels rather than returns
equations to produce price forecasts.

4.2. COMPARISON OF PRICE FORECASTS

Now that GP-prediction of price levels seems more desirable than that of returns, it
is necessary to evaluate GPs performance against at least one other prediction pro-
duced by a different method. Here the comparison is performed for out-of-sample
forecasts instead of in-sample predictions (as in 4.1 above). To complete this com-
parison, the simple time series models used earlier in testing GP-predictability
must be replaced to produce more reasonable forecasts of daily closing prices.
The lagged-dependent variables used earlier may not explain the dynamics of
stock prices very well and other explanatory variables should be tested. In other
words, once stock prices predictability is established, those variables that may
affect a stocks next day price should be identified. Given the importance of this
task, a fairly large list of variables was identified and, after some experimentation
(trial and error), thirty-five variables were selected. They include several lagged
daily closing prices, highs, lows, volume, and changes in the Dow Jones Industrial
Average. To complete the GP runs, the number of equations per population were
increased to 5,000, the number of equations after which the program terminates
was increased to 80,000, and the same operators used earlier were used again.
GP closing price-forecasts are then compared with nave forecasts or Pt = Pt 1 .
Accordingly, and for each stock, twenty consecutive one-day-ahead forecasts (12
October through 16 November) with different starting dates with two weeks non-
overlapping data were produced using the more appropriate GP models (or GPM)
and nave models (or NM). Cs twenty-day price-forecasts comparison starts 21
September. CPQs twenty days starts two weeks later on 28 September, and so on.
The six data sets thusly contain non-overlapping as well as overlapping dates to
GENETIC PROGRAMMING PREDICTION OF STOCK PRICES 225
Table V. Testing mean difference between two closing price
forecasts.

n t MSE
GPM NM

C 20 6.010 1.266 2.706


CPQ 20 2.300 0.225 0.894
GE 20 6.089 1.515 2.782
MSFT 20 4.316 1.033 1.892
PEP 20 3.432 0.811 1.088
S 20 2.733 0.885 1.581

All 120 3.702 0.956 1.824

evaluate forecasts of prices of different stocks only partially affected by the same
exogenous market news.
The fittest evolved equations were all fairly complex with prices mostly
explained by the following ten variables:

Pt = f (Pt 1 , Pt 2 , Pt 3 , HPt 1 , HPt 2 , LPt 1 , LPt 2 , Volt 1 ,


(20)
DJX t 1 , DJX t 2 ) ,

where HP, and LP are the daily highest and lowest stock prices respectively, Vol is
the daily traded volume of that stock, and DJX is the daily change in the Dow Jones
Industrial Average. The resulting equations were nonlinear, fairly complex, had
different structures, and despite their dissimilarity over time and among stock, their
predictive performance for the same day and stock was quite similar. Equations
representing the twenty days per stock had R 2 as low as 0.85 and as high as 0.99.
They differed from one day to the next and from one stock to the other.
Figures 2ac are comparisons of squared forecast errors produced by the two
methods in 20 consecutive days for three stocks. (The other three are quite similar
and therefore are not presented since.) The squared forecast error = (Yt Yt )2 ,
where Y is price forecasts produced by either GPM or NM. These plots suggest
that GPM seems to produce slightly less error than NM. To determine whether
GPM-forecast errors and NM-forecast errors are different, one tests Ho : d = 0
and the test statistic defined in Equation (19) applies since the two populations are
not statistically independent as explained earlier. Here the difference of absolute
forecast errors is averaged as well to avoid bias. Table V reports the resulting
computations of the test statistic for the six stocks. Clearly, the null hypothesis
that the mean difference is zero for all six stocks at the 5% level of significance
is rejected. This means that there is a 95% chance that GPM forecasts are more
accurate than NM forecasts. As shown, the MSEs are also lower for GPM.
226 M. A. KABOUDAN

Figure 2. Squared errors on one-day-ahead closing price forecast of (a) CPQ, (b) MSFT, (c) S.

4.3. A TRADING STRATEGY

If GPs predictive ability is superior to that of nave, its forecast should be of


some benefit. One would hope that GP forecasting using an appropriate strategy
outperforms the general markets rate of return. Over a ten-year period (1988
1997), the average annual rate of return from investing in large-company stocks in
the U.S. was 18.85% (Ibbotson and Sinquefield, 1998). Therefore, an investment
strategy that would produce more than 20% annually is deemed desirable.
There are many factors that affect formulating a successful investment strategy
based on GP forecasting. First, any such strategy must consider the limitations
GENETIC PROGRAMMING PREDICTION OF STOCK PRICES 227

imposed by the current state of the art of genetic programming. GP is a relatively


young science expected to advance. For now and at least within the scope of this
study, attempts to forecast beyond one day were fruitless. Second, financial mar-
kets tend to react to news as it occurs. Short term breaking news introduces short
run uncertainties about market conditions that affect the outcome of a short-term
investment strategy. Third, when market conditions change (for whatever reasons)
from fairly stable to very volatile, deciding what sample size or historical data to
use during a GP-search for a model becomes more difficult. While under normal
stable conditions, it may be possible to use data representing the previous 100
days; these may be far too many for GP to capture market dynamics with when
conditions become volatile. There are other factors that may affect GPs ability
to produce a reasonable forecasting model. However, the ones already mentioned
here suggest that there is no benefit from producing a forecast beyond one day.
Therefore, a trading strategy should be based on attempting to profit from price
forecasts limited to one-day ahead. With these limitations in mind, and given the
speed of price-changes today, it is logical to use GPs forecasting ability to profit
from daily in-out trades. Therefore, a single day-trading strategy (or SDTS for
short) is proposed. It entails taking a long or short position and selling or covering
that position the same day. If one decides to trade CPQ stock for example, then
rather than forecasting daily closing price, one would forecast daily high and low
prices and use them to buy low and sell high, regardless of the order of occurrence.
SDTS has the advantage of avoiding overnight risk during hours when the market
is closed.
There are restrictions when using SDTS. First, if the predicted spread (or dif-
ference between the predicted daily high and low prices) is not sufficiently large,
there is no money to be made even if the forecast is perfect. Thus, there is no
trading when the forecasted spread falls below a specific threshold difference. That
difference should be sufficiently large to justify the risk taken. Second, if the stock
price opens significantly above or below the forecasted high or low, respectively, it
is only logical not to trade. This may occur when unexpected news breaks after the
forecast is completed. (Breaking news during the day becomes a fortunate or unfor-
tunate event if one is already invested. It introduces uncontrollable risk that renders
any forecast useless.) Third, a large volume should be traded (= 1,000 shares) with
a discount brokerage firm to benefit from relatively small price changes without
sacrificing profits in commission. Fourth, since trading is based on a one-day fore-
cast, every position must be closed daily even if sometimes experiencing loss. This
helps avoid greater gambling losses in subsequent days for which no forecast is
available to make prudent decisions. Finally, this trading strategy applies only to
heavily traded stocks. If the selected stock is not heavily traded the probability that
the expected high or low price occurs decreases. Heavy trading is measured by
daily volume of shares transacted. Although subjective, it is logical to use SDTS
to trade stocks that trade a minimum of one millions shares daily. This restriction
is only to reduce the trading risk involved. SDTS mandates closing positions daily,
228 M. A. KABOUDAN

Table VI. SDTS rules.

Spead 1.25 < 1.50 1.5 < 1.75 1.75 < 2.00 2.00

If 0 |FL OP| < 3/8 Long Long Long Long


or if |AL FL| < 3/8

If 3/8 |FL OP| < 1/2 No trade Long Long Long


or 3/8 |AL FL| < 1/2

If 1/2 |FL OP| < 5/8 No trade No trade Long Long


or 1/2 |AL FL| < 5/8

If 5/8 |FL OP| < 3/4 No trade No trade No trade Long


or 5/8 |AL FL| < 3/4

If 3/4 |FL OP| No trade No trade No trade No trade


or 3/4 |AL FL|

If |OP AH| < 3/8 Short Short Short Short


or 0 |FH AH| < 3/8

If 3/8 |OP AH| < 1/2 No trade Short Short Short


or 3/8 |FH AH| < 1/2

If 1/2 |OP AH| < 5/8 No trade No trade Short Short


or 1/2 |FH AH| < 5/8

If 5/8 |OP AH| < 3/4 No trade No trade No trade Short


or 5/8 |FH AH| < 3/4

If 3/4 |OP AH| No trade No trade No trade No trade


or 3/4 |FH AH|

and for less frequently traded stocks, closing may force accepting an undesirable
price.
Rules for using the SDTS system are in Table VI. Here are definitions of the
variables in the table: FL = forecasted low price, FH = forecasted high price, OP =
actual opening price, AL = actual low price that occurred thus far in the trading
day, and AH = actual high price that occurred thus far in the trading day. Following
these rules should minimize trading risk and a trader should use discretion to de-
termine when to close a position quickly once the forecast proves worthless for the
day. As presented, the table is two-dimensional. The minimum spread condition for
trading is one dimension. It is to be determined once a forecast is ready and before
the market opens. If satisfied, the second dimension listed in each of the tables
other rows prescribes a condition that must be satisfied to take position. Minimum
spread is the difference between the forecasted high and forecasted low prices.
GENETIC PROGRAMMING PREDICTION OF STOCK PRICES 229

Determined intuitively and experimentally, a minimum spread of $1.25 must first


occur before any other condition is evaluated. This subjectively defined threshold
level is selected to provide a sufficiently large buffer to absorb forecasting errors.
If this minimum spread is not satisfied, no position in the stock should be taken. If
it is, a long, short, or no trade decision is identified from the intersection of one of
the four spread intervals defined in the first row with any other in the table. This
second dimension has ten groups of mutually exclusive conditions. Each group has
two non-mutually exclusive conditions within it. (|.| is for absolute value of those
differences.) The satisfaction of only one of each pair is a sufficient condition for
a trade to occur (if the spread condition is satisfied). The satisfaction of one of the
pair of conditions occurs only after trading starts.
An example should explain how to use these rules. Assume that the forecasted
spread for a particular stock is predicted to be $1.625 prior to commencement
of trading. This spread > $1.25 and falls within the interval defined in the third
column of the table (1.5 < 1.75). One then takes a long position only if (a) (0
|FL OP| < 3/8), (b) (|AL FL| < 3/8), (c) (3/8 |FL OP| < 1/2), or
(d) (3/8 |AL FL| < 1/2) is satisfied after trading starts. These conditions
may be stated in a simpler manner, but would not be consistent with the table.
Basically, they state that one should take a long position if the absolute difference
between the forecasted low and opening price or if the absolute difference between
the actual low for the elapsed trading period and the forecasted low is less than
$1/2. Alternatively, one takes a short position if the absolute difference between the
forecasted high and opening price or if the absolute difference between the actual
high for the elapsed trading period and the forecasted high is less than $1/2. No
trading should take place otherwise. Like any stock trading, SDTS is not risk free.
Using SDTS imposes two types of risk: one due to incorrect forecast, and the other
due to making incorrect decisions. Following the rules helps minimize both. The
effects of incorrect forecasts are presented in Table VIII below. Here is how SDTS
is (hypothetically) executed to minimize losses. If a days decision is to trade and
an order is placed, as soon as (and if) the order is filled, the order to close it is placed
at a price equal to the forecasted high or low depending on whether the position
taken is long or short. A trader should observe price movements closely until the
position is closed. If the actual price for the day does not match the forecasted high
or low, a decision must be made to close that position, even if sometimes at loss.

4.4. COMPARING FORECASTS

SDTS demands forecasting two variables: the highest and lowest daily prices.
Whether such strategy leads to profitable trading and whether GP forecasting of
these two variables helps increase the investment rate of return or not can only be
decided by experiment. In this experiment, two independent forecasts were gener-
ated and hypothetically used in daily trading. For consistency, GPM and NM were
used to generate the two forecasts for the same fifty consecutive trading days (21
Table VII. Execution of the trading strategy using the two forecast models.

230
Date High Low Predicted Trade Buy at Sell at Cost Revenue Profit %
Actual Predicted Actual Predicted spread returns

GPM:
5/12/98 31.813 32.311 30.500 30.682 1.628 Long 30.750 31.750 15395.00 15855.00 960.00 6.236
5/13/98 32.313 32.305 31.750 30.901 1.405 No execution to buy at $31.125
5/14/98 32.125 32.612 30.750 31.234 1.378 Short 31.250 32.000 15645.00 15980.00 710.00 4.538
5/15/98 31.500 32.131 30.250 30.984 1.147 No trade
5/18/98 30.187 31.032 29.000 29.832 1.200 No trade
5/19/98 30.375 30.202 29.687 28.830 1.372 Short 29.750 30.250 14895.00 15105.00 460.00 3.088
5/20/98 30.687 30.894 29.125 29.546 1.347 Long 29.625 30.500 14832.50 15230.00 835.00 5.630
5/21/98 29.250 30.195 28.250 29.022 1.173 No trade
5/22/98 28.312 29.285 27.188 27.947 1.338 No execution to short at $29
5/26/98 28.438 28.513 27.500 27.258 1.255 Short 27.625 28.500 13832.50 14230.00 835.00 6.037
Total 25.528

NM:
5/12/98 31.813 33.063 30.500 31.375 1.688 Long 31.500 31.750 15770.00 15855.00 210.00 1.332
5/13/98 32.313 31.813 31.750 30.500 1.313 No execution to buy at $30.75
5/14/98 32.125 32.313 30.750 31.750 0.563 No trade
5/15/98 31.500 32.125 30.250 30.750 1.375 Short 30.500 31.375 15270.00 15667.50 835.00 5.468
5/18/98 30.187 31.500 29.000 30.250 1.250 No execution to sell short at $31.25
5/19/98 30.375 30.187 29.687 29.000 1.187 No trade

M. A. KABOUDAN
5/20/98 30.687 30.375 29.125 29.687 0.688 No trade
5/21/98 29.250 30.687 28.250 29.125 1.562 No execution to sell short at $30.5
5/22/98 28.312 29.250 27.188 28.250 1.000 No trade
5/26/98 28.438 28.312 27.500 27.188 1.125 No trade
Total 6.800
GENETIC PROGRAMMING PREDICTION OF STOCK PRICES 231
Table VIII. Comparison of ROI and number of trading days.

C CPQ GE MSFT PEP S

GPM % ROI 195.13 193.30 143.51 104.01 46.62 110.35


NM % ROI 141.16 137.73 92.70 67.37 67.27 80.37
GPM mean ROI 7.50 5.37 4.63 4.00 3.11 4.41
NM mean ROI 6.72 5.74 3.20 4.21 5.61 4.23

Mean high price 42.38 31.21 84.21 53.96 34.26 45.52


Mean low price 40.00 29.79 81.47 52.17 32.99 43.74

Number of trading days:

GPM
Total days 26 36 31 26 15 25
Days spread is 1.251.5 0 26 2 1 13 0
Days spread is 1.51.75 1 10 1 16 2 7
Days spread is 1.752.0 7 0 3 8 0 13
Days spread > 2 18 0 25 1 0 5
Number of losing days 2 2 0 0 1 0
Percent of losing days 7.7 5.6 0 0 6.7 0

NM
Total days 21 24 29 16 12 19
Days spread is 1.251.5 0 6 1 6 2 2
Days spread is 1.51.75 1 9 3 4 5 4
Days spread is 1.752.0 5 4 7 1 4 3
Days spread > 2 15 5 18 5 1 10
Number of losing days 1 2 0 0 0 0
Percent of losing days 4.8 8.3 0 0 0 0

September20 November 1998) for the six stocks. Before completing this exercise
the idea was tested on trading CPQ for ten days in May 1998. It is reported here
instead of trading decisions for all six stocks over the fifty days to conserve space.
Table VII contains execution of the proposed strategy using the two forecasting
methods for those ten days. The forecasted spreads upon which trading decisions
were made are in the sixth column. The decisions are in the column titled Trade.
The upper half of the table shows the results from the GPM forecast, while the
lower half shows those from the NM forecast. Trading cost is assumed negligible
in this example given current trading cost of $0.02 per share. (The NM forecast is
generated by taking todays high (low) and using it as the predictor of tomorrows
high (low).) The daily decision is one of the following:
232 M. A. KABOUDAN

(a) Take a long position identified by Long.


(b) Take a short position identified by Short.
(c) No trade on days when the forecasted spread < $1.25.
(d) No execution to buy or sell when the forecasted low or high deviated
substantially from the actual.
Trading results for the much larger sample with fifty trading days for six stocks
is in Table VIII. It reports ROI resulting from trades based on GPM and NM fore-
casts and the average ROI per day of actual trading. It also reports the number of
trading days grouped by spread between the forecasted high and low prices. They
are included to explain differences among the reported ROIs. These results suggest
the following:
1. Using either forecast method, SDTS yields higher return on investment than
traditional buying and holding a stock for accumulation of capital gains. While
the traditional strategy yields an average annual return of less than 20%, SDTS
using GP or NM forecasting of daily highs and lows may generate much
higher returns. The higher ROI may be attributed to reduced risk associated
with absence of overnight holding of a stock.
2. ROI from trading decisions based on GP forecasting is greater than ROI from
investment decisions based on NM forecasting in five of the six stocks. The
average return per trading day for the two forecasting methods is quite sim-
ilar. These results may first appear inconsistent with expectations. However,
evaluation of three other factors explains some of the inconsistencies. First,
one should evaluate total number of trading days per stock and the number of
trading days per spread group per stock. They are both different among stocks.
Logically, the larger the number of trading days the greater the expected ROI.
The expected ROI should also be greater if the distribution of trading days
is skewed toward the higher spread levels. Second, one should evaluate ROI
keeping relative stock price in perspective. Given that these stocks trade at
different prices (as the reported averages reveal) ROI on trading 1000 shares
at $40 is much higher than trading 1000 shares at $80 for the same spread
group. (There would be no difference if the spread were set as a percentage.
But that would affect total ROI negatively.) Third, one should evaluate the
number of losing trading days since they can affect the individual stocks total
and average ROI. The proportion of losing days reported may be viewed as a
measure of incorrect forecast risk involved. However, while a higher percent-
age of losing days negatively affects profitability, it may not be always true.
As shown in Table VIII, C and CPQ have greater ROI and high percentage
of losing days. Taken together, these factors explain why C yields a much
higher ROI than GE for example. While GE forecasts deliver a higher number
of days with spread > $2, GEs stock price is approximately twice that of C.
These factors also explain why PEP has GPM ROI lower than its NM ROI.
The distribution of trading days under GPM is heavily skewed toward the low
spreads compared with the higher spreads characterizing the NM forecasts for
GENETIC PROGRAMMING PREDICTION OF STOCK PRICES 233

the same stock. Further, PEP was the only stock where the number of losing
trading days using GPM was more than those using NM. Given these obser-
vations, it is logical to deduce that relatively low priced stocks that trade with
a larger daily spread (and should naturally yield similar forecasted spreads)
will provide a respectable ROI using this trading strategy regardless of the
forecasting method used. Using GP forecasting seems to enhance profitability.

5. Concluding Remarks

During this investigation of GP prediction of stock prices, several insights and


assertions emerged. First, GP is capable of evolving reasonable data generating
processes that closely replicate patterns in data produced by deterministic pro-
cesses. It is less capable when those deterministic processes are noisy. Random
processes cannot be predicted using GP (or any other forecasting methodology).
Second, testing whether a series is GP-predictable is a logical and necessary step
to complete before conducting a search for its DGP. Measuring predictability helps
avoid premature decisions that may be erroneously reached because of GPs ran-
dom search mechanism. Third, a new trading strategy was formulated. It employs
forecasts of daily highs and lows in making daily no trade, long, or short trading
decisions without holding any positions overnight. The strategy seems intuitive and
should yield returns on investment much higher than those experienced when an
investor buys and holds stocks for a number of years. Further, when the proposed
trading strategy was applied to different stocks, it was evident that stocks are not
equally profitable. The results suggested that low priced stocks ($50 or less) are
more profitable if their daily spread average is fairly high (say > $1.75).
This paper presented GP forecasts of stock prices. First, GP-predictability of
six stock closing price levels and that of returns were measured. The results clearly
suggested GP-predictability of price levels and not returns. The only logical ex-
planation of such difference is perhaps our natural ability to identify variables that
explain price level variations over time. Such ability is diminished when identifying
variables to explain returns. Second, price forecasts using GP-generated equa-
tions and using a simple nave model where tomorrows price is simply equated
to todays price were developed. This exercise presented evidence that GP may
forecast out-of-sample price levels better.
Undoubtedly, the need for research in applying evolutionary computation
(and especially GP) to financial markets exists. Financial market forecasting can
and surely will benefit from advancements in genetic programming and other
evolutionary computation methods. For example, during this study there were
indications that financial markets variables are interrelated. This was not invest-
igated nor its effects included here because it needs a non-existing GP code that
solves non-recursive simultaneous systems of equations perhaps with an iterative
simulation algorithm. The implications of advances in GP for financial trading are
purely speculative at this stage.
234 M. A. KABOUDAN

References
Andrew, M. and Prager, R. (1994). Genetic programming for the acquisition of double auction market
strategies. In K. Kinnear, Jr. (ed.), Advances in Genetic Programming, 355368. The MIT Press,
Cambridge, MA.
Bhattacharyya, S., Pietet, O. and Zumbach, G. (1998). Representational semantics for genetic
programming based learning in high-frequency financial data. In J. Koza, W. Banzhaf, K. Chel-
lapilla, K. Deb, M. Dorigo, D. Fogel, M. Garzon, D. Goldberg, H. Iba and R. Riolo (eds.), Genetic
Programming 1998: Proceedings of the Third Annual Conference, 1116. Morgan Kaufmann,
San Francisco, CA.
Brock, W., Lakonishok, J. and LeBaron, B. (1992). Simple technical trading rules and the stochastic
properties of stock returns. Journal of Finance, 47, 17311764.
Chen, S.-H. (1996). Genetic programming, predictability, and stock market efficiency. In L. Vlacic,
T. Nguyen and D. Cecez-Kecmanovic (eds.), Modelling and Control of National and Regional
Economies, 283288. Pergamon Press, Oxford, Great Britain.
Chen, S.-H. (1998). Hedging derivative securities with genetic programming. In Application of Ma-
chine Learning and Data Mining in Finance: Workshop at ECML-98. ECML-98 Workshop 6,
Dorint-Parkhotel, Chemnitz, Germany, 24 April 1998.
Chen, S.-H. and Ni, C.-C. (1997). Evolutionary artificial neural networks and genetic programming:
a comparative study based on financial data. In G.D. Smith (ed.), Artificial Neural Networks and
Genetic Algorithms, forthcoming. Springer-Verlag, Vienna.
Chen, S.-H. and Yeh, C.-H. (1995). Predicting stock returns with genetic programming: do the
short-term nonlinear regularities exist? In D. Fisher (ed.), Proceedings of the Fifth International
Workshop on Artificial Intelligence and Statistics, 95101. Ft. Lauderdale, Florida.
Chen, S.-H. and Yeh, C.-H. (1996). Genetic programming and the efficient market hypothesis. In
John Koza, David Goldberg, David Fogel and Rick Riolo (eds.), Genetic Programming 1996:
Proceedings of the First Annual Conference, 4553. The MIT Press, Cambridge, MA.
Chen, S.-H. and Yeh, C.-H. (1997a). Using genetic programming to model volatility in financial time
series. In J. Koza, K. Deb, M. Dorigo, D. Fogel, M. Garzon, H. Iba and R. Riolo (eds.), Genetic
Programming 1997: Proceedings of the Second Annual Conference, 5863. Morgan Kaufmann,
Stanford University, CA.
Chen, S.-H. and Yeh, C.-H. (1997b). Toward a computable approach to the efficient market hypo-
thesis: an application of genetic programming, Journal of Economic Dynamics and Control, 21,
10431063.
Chen, S., Yeh, C. and Lee, W. (1998). Option pricing with genetic programming. In J. Koza, W.
Banzhaf, K. Chellapilla, K. Deb, M. Dorigo, D. Fogel, M. Garzon, D. Goldberg, H. Iba and R.
Riolo (eds.), Genetic Programming 1998: Proceedings of the Third Annual Conference, 3237.
Morgan Kaufmann, San Francisco, CA.
Chidambaran, N., Lee, C. and Trigueros, J. (1998). An adaptive evolutionary approach to option
pricing via genetic programming. In J. Koza, W. Banzhaf, K. Chellapilla, K. Deb, M. Dorigo,
D. Fogel, M. Garzon, D. Goldberg, H. Iba and R. Riolo (eds.), Genetic Programming 1998:
Proceedings of the Third Annual Conference, 187192. Morgan Kaufmann, San Francisco, CA.
Efron, B. (1982). The Jackknife, the Bootstrap, and Other Resampling Plans. Society for Industrial
and Applied Mathematics, Philadelphia.
Eglit, J.T. (1994). Trend prediction in financial time series. In J. Koza (ed.), Genetic Algorithms at
Stanford. Stanford Bookstore, Stanford, CA, pp. 3140.
Fama, E. and French, K.R. (1988). Dividend yields and expected stock returns. Journal of Financial
Economics, 22, 325.
Fogel, D. and Fogel, L. (1996). Preliminary experiments on discriminating between chaotic signals
and noise using evolutionary programming. In John Koza, David Goldberg, David Fogel and Rick
Riolo (eds.), Genetic Programming 1996: Proceedings of the First Annual Conference, 512520.
The MIT Press, Cambridge, MA.
GENETIC PROGRAMMING PREDICTION OF STOCK PRICES 235

Granger, C. and Andersen, A. (1978). An Introduction to Bilinear Time Series Models. Vandenhoek
and Ruprecht, Gottingen.
Greene, W. (1997). Econometric Analysis. Prentice Hall, Upper Saddle River, NJ, 3rd Edition.
Henon, M. (1976). A two-dimensional mapping with a strange attractor. Comm. Math. Phys., 50, 69.
Hsieh, D. (1989). Testing for nonlinear dependence in daily foreign exchange rates. Journal of
Business, 62, 339368.
Hsieh, D. (1991). Chaos and nonlinear dynamics: application to financial markets. The Journal of
Finance, XLVI, 18391877.
Ibbotson, R. and Sinquefield, R. (1998). Stocks, Bonds, Bills and Inflation: 1998 Yearbook.TM
Ibbotson Associates, Chicago.
Jensen, M. (1978). Some anomalous evidence regarding market efficiency, Journal of Financial
Economics, 6, 95101.
Jegadeesh, N. (1990). Evidence of predictable behavior in security returns. The Journal of Finance,
XLV, 881898.
Kaboudan, M. (1998a). Forecasting stock returns using genetic programming in C++. In D. Cook
(ed.), FLAIRS Proceedings of the Eleventh International Florida Artificial Intelligence Research
Symposium Conference, 7377. AAAI Press, Menlo Park, CA.
Kaboudan, M. (1998b). Statistical properties of time-series-complexity measure applied to stock
returns, Computational Economics, 11, 167187.
Kaboudan, M. (1998c). A GP approach to distinguish chaotic from noisy signals. In J. Koza, W.
Banzhaf, K. Chellapilla, K. Deb, M. Dorigo, D. Fogel, M. Garzon, D. Goldberg, H. Iba and R.
Riolo (eds.), Genetic Programming 1998: Proceedings of the Third Annual Conference, 187192.
Morgan Kaufmann, San Francisco, CA.
Kendall, M.G. (1953). The analysis of economic time-series, Part I. Prices. Journal of the Royal
Statistical Society, 96, 1125.
Koza, J. (1992). Genetic Programming. The MIT Press, Cambridge, MA.
Lehman, B. (1990). Fads, martingales, and market efficiency. Quarterly Journal of Economics, CV,
128.
Lo, A. and MacKinlay, C. (1988). Stock prices do not follow random walks: evidence from a simple
specification test. Review of Financial Studies, 1, 4166.
Lo, A. and MacKinlay, C. (1999). A Non-Random Walk Down Wall Street. Princeton University
Press, Princeton, NJ.
Mackey, M. and Glass, L. (1977). Oscillation and chaos in physiological control systems. Science,
197, 287.
Mason, R., Lind, D. and Marchal, W. (1999). Statistical Techniques in Business and Economics.
Irwin-McGraw-Hill, Boston, MA, 10th Edition.
May, R. (1976). Simple mathematical models with very complicated dynamics, Nature 261, 459467.
McDonnell, J. and Waagen, D. (1994). Evolving recurrent perceptrons for time-series modeling.
IEEE Transactions on Neural Networks, 5, 2438.
Mills, T. (1993). The Econometric Modelling of Financial Time Series. Cambridge University Press,
Cambridge.
Mulloy, B., Riolo, R. and Savit, R. (1996). Dynamics of genetic programming and chaotic time
series prediction. In John Koza, David Goldberg, David Fogel and Rick Riolo (eds.), Genetic
Programming 1996: Proceedings of the First Annual Conference, 166174. The MIT Press,
Cambridge, MA.
Neely, C., Weller, P. and Dittmar, R. (1996). Is technical analysis in the foreign exchange market
profitable? A genetic programming approach. Research Division Working Papers, The Federal
Reserve Bank of St. Louis, 96-006B.
Numata, M., Sugawara, K., Yoshihara, I. and Abe, K. (1998). Time series prediction by genetic
programming. In Genetic Programming 1998: Late-Breaking Papers, 176179.
236 M. A. KABOUDAN

Oakley H. (1994). Two scientific applications of genetic programming: stack filters and non-linear
equation fitting to chaotic data, In K.E. Kinnear Jr. (ed.), Advances in Genetic Programming,
369389. MIT Press.
Oakley, H. (1995). Genetic programming as a means of assessing and reflecting chaos. In Genetic
Programming: AAAI-95 Fall Symposium Series, 6872. AAAI Press.
Oakley, H. (1996). Genetic programming, the reflection of chaos, and the bootstrap: toward a use-
ful test for chaos. In John Koza, David Goldberg, David Fogel and Rick Riolo (eds.), Genetic
Programming 1996: Proceedings of the First Annual Conference, 175181. The MIT Press,
Cambridge, MA.
Oussaidene, M., Chopard, B., Pictet, O. and Tomassini, M. (1996). Parallel genetic programming: an
application to trading models evolution. In John Koza, David Goldberg, David Fogel and Rick
Riolo (eds.), Genetic Programming 1996: Proceedings of the First Annual Conference, 357362.
The MIT Press, Cambridge, MA.
Ozaki, T. (1985). Non-linear time series models and dynamical systems. In E. Hannan, P. Krishnaiah
and M. Rao (eds.), Handbook of Statistics, 5, North-Holland, Amsterdam.
Pindyck, R. and Rubinfeld, D. (1998). Econometric Models and Economic Forecasts. Irwin-
McGraw-Hill, Boston, MA, 4th Edition.
Richardson, M. and Smith, T. (1993). A test of multivariate normality of stock returns. Journal of
Business, 66, 295321.
Sathyanarayan, S. and Chellapilla, K. (1996). Evolving reduced parameter bilinear models for time
series prediction using fast evolutionary programming. In John Koza, David Goldberg, David
Fogel and Rick Riolo (eds.), Genetic Programming 1996: Proceedings of the First Annual
Conference, 528535. The MIT Press, Cambridge, MA.
Scheinkman, J. and LeBaron, B. (1989). Nonlinear dynamics and stock returns. Journal of Finance,
62, 311337.
Singleton, A. (1995). Genetic programming with C++, public domain genetic programming package.
Creation Mechanics, Dublin, NH. http://www.cen.uiuc.edu/klipp/research/ssprob.cxx.
Tong, H. (1990). Non-linear Time Series: A Dynamical System Approach. Oxford University Press,
Oxford.
Warren, M.A. (1994). Stock price prediction using genetic programming. In J. Koza (ed.), Genetic
Algorithms at Stanford 1994, 180184. Stanford Bookstore, Stanford, CA.
Wolfe, A. and Vastomous, J. (1986). Intermediate length scale effects in Lyapunov exponent estim-
ation. In G. Mayer-Kress (ed.), Dimensions and Entropies in Chaotic System. Springer-Verlag,
Berlin, Germany.

You might also like