Professional Documents
Culture Documents
207
2001 Kluwer Academic Publishers. Printed in the Netherlands.
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
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
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
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
Yt = 4 Yt 1(1 Yt 1 ) . (7)
216 M. A. KABOUDAN
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)
Yt = a Yt 1 + b t Yt 1 + t , (14)
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 ,
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
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
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
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
n t MSE
Predicted Computed
5% level of significance. Thus, one should evolve price levels rather than returns
equations to produce 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
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:
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.
Spead 1.25 < 1.50 1.5 < 1.75 1.75 < 2.00 2.00
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
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.
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
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
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.