1 / 24

An Example of the use of Genetic Algorithms in Finance

An Example of the use of Genetic Algorithms in Finance. Chris Riley March 8, 2007. Using Genetic Algorithms to Find Technical Trading Rules Journal of Financial Economics 51 (1999) 245-271. Franklin Allen The Wharton School, University of Pennsylvania Risto Karjalainen

Download Presentation

An Example of the use of Genetic Algorithms in Finance

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. An Example of the use of Genetic Algorithms in Finance Chris Riley March 8, 2007

  2. Using Genetic Algorithms to Find Technical Trading RulesJournal of Financial Economics 51 (1999) 245-271 Franklin Allen The Wharton School, University of Pennsylvania Risto Karjalainen Merrill Lynch & Co., Inc., Mercury Asset Managent

  3. Technical Analysis • Technical factors: price, volume, open interest • Use indicators to determine state of the market • Used to time entry and exit

  4. Genetic Algorithm Use - Motivation • Technical trading rules are specified in an ad hoc manner • Accusations of data snooping – trading rules specified ex post • GA can derive trading rules that are optimal in some sense and are not ad hoc • Rules are chosen by a GA using price data available before the start of the test period

  5. Genetic Programming • An extension of GA developed by Koza (1992) • Traditional GA represent genetic structures as fixed length character strings, which is restrictive if the size or form of the solution cannot be assessed beforehand

  6. Genetic Programming • Solutions in GP are represented as hierarchical compositions of functions • These are tree-like structures • Successors of each node provide the arguments for the function identified with the node • Terminal nodes are the input data • The entire tree is a function evaluated recursively by evaluating the root node of the tree

  7. Genetic Programming • Solution structure is not specified a priori • A set of building block functions are defined that are recombined by the GA • Initial population is composed of random trees • Root node is chosen at random among functions of the same type as the desired composite function • Each argument of that function is selected functions of the appropriate type • This continues down each branch of the tree until a function with no arguments is reached

  8. Genetic Programming • Crossover – two solution candidates are recombined by replacing a randomly selected subtree in the first parent with a subtree from the second parent • If different types of functions are used within a tree, the crossover node from the first parent is chosen randomly, then the crossover node from the second parent is chosen from nodes of the same type • GP allows trading rules to be represented in a natural way

  9. Building Block Functions • Simple functions of past price data • Numerical and logical constants • Functions are either real or Boolean • Root is always a Boolean function • Real functions include average, max, min, arithmetic operators, absolute value • Boolean functions include if-then-else, and, or, not, >, <

  10. Trading Rules • Each genetic structure is a particular technical trading rule • The goal is to find decision rules that divide days into in the market (earning the market rate of return) or out of the market (earning the risk free rate) • Each rule returns either a buy or sell signal for any given price history • The signal specifies the position to take the following day

  11. Trading Strategy • If the current state is ‘in’ and the trading rule signals ‘sell’ then move out of the market; if the current state is ‘out’ and the trading rule signals ‘buy’ then move into the market. • In the other states then no change • This strategy does not consider the possibility of short selling

  12. Sample Trading Rules • Left: 50-day moving average • if moving average over past 50 days < then buy, else sell • Right: 30-day trading range break rule • if closing price > max of last 30 days then buy, else sell

  13. Crossover

  14. Crossover

  15. Fitness Measure • Based on the excess return over the buy-and-hold strategy • Simple return from a single trade • Continuously compounded return fro a trading rule

  16. Fitness Measure • Return for the buy-and-hold strategy (buy the first day, sell the last day) • Excess return

  17. Constraints • Population size: 500 • Maximum nodes: 100 • Stopping criteria: 50 generations or until no improvement after 25 generations • Trials: 100

  18. Data • S&P 500 index daily return data for January 3, 1928 to December 29, 1995 • One-month risk-free rates corresponding to Treasury bills from • CRSP for 1929 to 1991 • Datastream for 1992 to 1995 • Since the index is nonstationary, data is transformed by dividing each day’s price by a 250-day moving average

  19. Example Trading Rule Formed by the Genetic Algorithm Price x minimum(price) – 0.0688 x price > 0.8943

  20. Example Trading Rule Formed by the Genetic Algorithm lag(price,1) > average(price / abs(price - 1.1727))

  21. Conclusions • Rules do not earn excess returns out of sample • Rules take long positions when returns are positive and daily volatility is low • Rules stay out of market when returns are negative and volatility is high • One day lag removes most forecasting ability, indicating the rules exploit positive low-order serial correlation

  22. Results • From each of the 100 trials, one trading rule is saved • Find 89 trading rules in the 100 trials(no rules are saved if excess returns are not positive in selection period)

  23. Yearly Excess Returns

More Related