Using Genetic Algorithms to Find Technical Trading Rules
Franklin Allen, Risto Karjalainen | Journal of Financial Economics 51 (1999)
download paper here
Genetic Programming Review
Solution candidates are represented as hierarchical compositions of functions (not bit strings).
Successors of each node provide the arguments for the function identified with the node.
The terminal nodes correspond to the input data.
The entire tree is evaluated, recursively from the root node, as a function.
Objective
To find out whether optimal rules composed by GA's can be used to forecast future stock returns.
The Search Space And Rule Formation Explained
Logical combinations of simple rules that look at moving averages and maxima and minima of past prices from 1929 - 1980.
S&P 500 is the benchmark.
Algorithm goal is to classify each trading day as being either:
'in' the market: earning the market rate of return.
'out' of the market: earning the risk-free rate of return (this is the one-month T-bill rate of return).
Trading strategy:
if ( ( the current state is 'in' ) && ( the trading rule signals 'sell' ) )
switch to 'out'
if ( ( the current state is 'out') && (the trading rule signals 'buy' ) )
switch to 'in'
else
stick with current state
Functions return either Real or Boolean values:
Crossover is implemented by random selection of parent nodes:
The Fitness Function
Fitness of a rule is computed as the excess return over the buy-and-hold strategy during a training period.
Again, trading rules are applied to each trading day to divide the days into periods of 'in' (market return) or 'out' (risk-free return).
Single trade return
computed as:
where...
P
si
, P
bi
= sell / buy price
c = one - way transaction cost expressed as % of price
r
t
= log P
t
- log P
t - 1
Continuously compounded return
for a trading rule is computed as:
where...
T = number of trading days
I
b
(t), I
s
(t) = buy / sell indicator variables
n = number of trades
Return for the buy-and-hold strategy
is computed as:
Finally, the
fitness of the trading rule
(excess return) is computed as:
The Algorithm
Step 1
Create a random rule.
Compute the fitness of the rule.
Repeat 500 times (initial population).
Step 2
Apply the fittest rule in the population to the selection period and compute the excess return.
Save this rule as the initial best.
Step 3
Pick two parent rules at random using fitness based selection (roulette wheel).
Create a new rule through crossover.
Compute the fitness of the rule.
Replace one of the old rules by the new rule using an inverted fitness based selection.
Repeat 500 times to produce next generation.
Step 4
Apply the fittest rule in the population to the selection period and compute the excess return.
If the excess return improves upon the rule produced in Step 2, save as the new best rule.
Stop if there's no improvement for 25 generations or after a total of 50 generations.
Otherwise, go to Step 3.
Results
*transaction costs of 0.25%
*transaction costs of 0.10%
Conclusions
Not possible to make money after transaction costs using technical trading rules.
Are able to indentify periods to be in the market when returns are high and volatility is low, and out when the reverse is true.