Using Genetic Algorithms to Find Technical Trading Rules


Franklin Allen, Risto Karjalainen | Journal of Financial Economics 51 (1999)

download paper here



Genetic Programming Review
Objective
The Search Space And Rule Formation Explained
                                            

  • 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...

         Psi, Pbi = sell / buy price
         c          = one - way transaction cost expressed as % of price
 rt         = log Pt - log Pt - 1

  • Continuously compounded return for a trading rule is computed as:

   
    where...

         T             = number of trading days
         Ib(t), Is(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.