1 / 33

A real-time adaptive trading system using Genetic Programming

A real-time adaptive trading system using Genetic Programming. QF5205 : Topics in Quantitative Finance Donny Lee Nadim Mouchonnet. Summary. Introduction Genetic Algorithm and Genetic Programming Trading System Genetic Program Results. Introduction.

xue
Download Presentation

A real-time adaptive trading system using Genetic Programming

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. A real-time adaptive trading system using Genetic Programming QF5205 : Topics in Quantitative Finance Donny Lee Nadim Mouchonnet

  2. Summary • Introduction • Genetic Algorithm and Genetic Programming • Trading System • Genetic Program • Results

  3. Introduction • Many traders use indicator based trading rules • … but they may be loss making (see chart) • Double Objective • Create a system than trades and make profit • Emulate the behavior of a technical trader Motivation: “Can a technical trader consistently make a profit?” and “should a technical trader or trading system adapt to market conditions or is it better to use a static system?”

  4. Introduction(2) • Results using only a single strategy, backtested on historical data. • Stochastic strategy: Buy when indicator crosses the 20% mark from below and sell when it crosses the 70% mark from above. • Simple moving average strategy: Buy when the slow lag (50 day look back) crosses the fast lag (20 day look back) from below and sell when vice versa.

  5. Introduction(3) • Using the stochastic strategy on SIA stock from 02/11/10 to 08/26/10. • Loss is $0.30.

  6. Introduction(4) • Using the SMA strategy on KEP stock from 02/11/10 to 08/26/10. • Loss is $0.27.

  7. Introduction(5) • Using the GBPUSD for a period of 3 months • Bloomberg can summarize a whole bunch of strategies

  8. Introduction(6) • Using the GBPUSD for a period of 3 months • Parabolic SAR

  9. Genetic Algorithm and Genetic Programming (1) • GA is an iterative system • … aiming to find near-optimal solutions • … to multi-extremal problems • … by imitating the process of evolution • Rule is : SURVIVAL OF THE FITTEST

  10. Genetic Algorithm and Genetic Programming (2) • GA representation consists of binary strings of fixed length. • Search space is finite • GA needs to be initialized … • … by random sampling • Difference between GA and GP is that GP allows string length to vary within the solution space.

  11. Trading System : Data • Analysis carried out on spot FX ticks for GBP/USD from CQG Data Factory and Future Source from 1994 to 1997 • CQG : gathered from various FX brokers • Future Source : live feed from the Omega TradeStation utility (major banks FX quotes) • Got bid and ask and transforms them into mid • Data aggregated into OHLC

  12. Trading System : Software • Imitating the technical trader i.e. chooses technical strategies from a range of popular trading rules • GP based rule selection engine choosing combinations of such strategies • Cash management filter exits strategies when losses > user-defined threshold • Each backtested strategy returns : Profit, max drawdown, Modified Stirling ratio, number of trades • Transaction costs are taken into account with various slippage depending on trading time

  13. Trading System : Software

  14. Trading System : Strategies • 6 Rules used : simple moving averages crossover, adaptive moving averages, price channel breakout, stochastic, relative strength index, commodity channel index • 3 Connectors : AND / OR / XOR (00/01/10) • System rules allowed to use different frequencies/lags • Strategies ranked by stirling ratio (when return is positive) or by absolute return when negative.

  15. Genetic Program • Representation of a strategy. • A strategy of ours can be represented graphically.

  16. Genetic Program(2) • From a graphical understanding of a strategy, we can translate to a strategy structure. or a binary string representation.

  17. Genetic Program(3) • Or a binary string representation.

  18. Genetic Program(4) • This is essential as we ultimately need to convert our strategy into a binary string for our GP to work. Each strategy can be written in the form RULE | CONDITION | CONNECTOR | RULE | CONDITION | CONNECTOR | ……… | ACTION

  19. Genetic Program(5) • From there, we can form our binary string representation for our GP. I.e., consider the rule “BUY if AMA TRUE AND CCI FALSE OR RSI TRUE” It would be represented in binary as, 1000011111

  20. Genetic Program(6) • Now with each strategy represented as a binary string, we perform the following in each iteration. • Initialize population • Calculate Fitness • Crossover • Mutate

  21. Genetic Program(7) • We initial the population with a certain number of strings which will represents the strategies we will use. • Assume there are a maximum of k included indicators and a minimum of j. We may construct rules from a total of I indicators. • Generate U uniform pseudo-random integer variables V where 1 <= V <= I. For indicators to be used, we write a ‘1’ in the structure part, otherwise a ‘0’. • Generate U uniform pseudo-random binary variables corresponding to the indictor bit for each indicator. • Assume there are C connectors allowed. For each indicator, we generate a fixed width binary of D(1,C) and write it next to the corresponding indicator bit.

  22. Genetic Program(8) • At each trial over a user-defined period, each of these strategies is tested by simulating their trading performance over historical data. • There are many ways to assess performance. The Stirling ratio – profit divided by maximum drawdown – is often used by traders to assess performance. • For Crossover and Mutation, we would pick a strategies with a certain top % in their Stirling ratio.

  23. Genetic Program(9) • Crossover is the process of cutting strategy string pairs at points and exchanging tails and heads to make a new a pair. • Only the best s% are considered for crossover. For those strings rank i, the probability of selecting this string is • A cut point is selected uniformly pseudo-randomly and ‘head’ and ‘tail’ parts are exchange.

  24. Genetic Program(10) An example of a Crossover, suppose the following two pairs of strings are selected along with a uniformly distributed random number: 1010001010 and 1100111100 and 3 0100100111 and 0001101110and 8 Crossover: 101|0001010 and 110|0111100 becomes 1100001010 and 1010111100 01001001|11and 00011011|10 becomes 0100100110and 0001101111

  25. Genetic Program(11) • Mutation is the process of randomly changing appropriate bits in a strategy string and is executed in a bitwise manner. • Elitist model: top-ranked 5% of strings are not mutated. • Number of strings mutated = Mutation Rate x No. of Strings. • M uniform pseudo-random integer are generated between 1 and B, length of each string, without replacement. • Each corresponding numbered bit is then mutated (‘0’ becomes ‘1’ and ‘1’ becomes ‘0’)

  26. Genetic Program(12) • Example of a mutation. • Strings are of length 10 and four pseudo-random integers are generated and arranged in ascending order – 3, 5, 7, 8. • The following strings are mutated as follows: 1010001010 becomes 1000100110 1100111100 becomes 1110010000 0100100110 becomes 0110001010 0001101110 becomes 0011000010

  27. Genetic Program : Summary

  28. Results : Test • Step 1 : In Sample backtesting using 15-minute data used to determine the 20 best strategies during Q1 1994 • Step 2 : Out Sample trading using the best 20 strategies over the next quarters and assess the performance in live trading conditions

  29. Results : Improvement of solutions (1)

  30. Results : Improvement of solutions (2)

  31. Results : Profit

  32. Results : Further work • Periodic reoptimization as performance decreases as time out of sample increases • Parallel optimization

  33. Our experience • Unsuccessful Programming in the Java framework • 1 solution : using the Technical Analysis tool of Bloomberg’s Excel Add-in

More Related