GA Optimisation of Entries and Exits

For the past month I have been coding a genetic algorithm (GA) environment for optimising trading model entries and exits. The resulting program has opened my eyes to a few things. 

I have always known that a trading model optimisation yields many viable models. As to which of them you choose can often be a case of user preference. Even when you are algo-trading you can get frustrated that your model isn't trading enough or isn't yielding enough profit per day.

In the picture below (click to enlarge) you can see a 20 generation GA optimising entries and exits for 2000 race horses. The fittest GA for each generation is displayed on each row of the table. All figures are based on a notional £2 trade with optimised stop-loss or profit-take exits or an auto-exit when the race is due to go off and no limit has been met.


As can be seen clearly, the GA will continue to optimise by choosing fewer and fewer runners in order to maximise return on investment. If it can find just the one runner that has a higher yield than a group of runners then it will find it. Is that a good thing? No, because the model will be unlikely to be generalised for future trading. The fewer trades the more variance in returns. You want a nice smooth increase on your equity curve with as few drawdowns as possible and that are small in size.

Each successive GA increases in fitness and so does the average yield per trade but the number of trades decreases as the population of GAs look for that elusive single high yielding trade. If some of the earlier but less fit GAs hold up to an out-of-sample test then they might be preferable as they give a higher yield.

In the next picture (click to enlarge) you can see an out-of-sample test on 200 runners that were withheld from the original training database. Indeed, some of the earlier GAs have held up, although the Sharpe Ratio has fallen below 2.


Although this GA uses a simple return based fitness function, I have output many other potential fitness measures including; maximum drawdown (this would be minimised rather than maximised), edge (expected value), yield / maximum drawdown and Sharpe Ratio.

I think I have come across a useful trading model but it will need more work. I would like to build a database of about 10,000 training cases with a 1000 runner hold-out so that I can be sure any trading model will hold-up to future trading.