I’m not dead, although I haven’t been blogging. I am feeling well enough to revisit some old unfinished computer projects: Genetic Algorithms/Genetic Programming for Market Timing models.
For those that are new to this blog, I’ve been running a market timing system since 1997 or 1998 or somewhere around that time. Everyday the system gets prices and market information and outputs a buy or sell signal. FYI, it’s called the Timing4 model of Perfect Market Timing System (PMTS). Except it’s far from perfect. It sucks. It does provide some insight that is sort-of useful so I keep running it. That makes my PMTS similar to the UN IPCC climate models. They both fail and I don’t want my money or your money guided by a failed model.
Back in 2005 or so, I wrote some code that would apply genetic programming techniques. Basically it generates and series of models, tests them and then evolves them using selection, crossover and mutation operations into a new generation of models. The genetic algorithms do work. They do create a model that whups ass on my timing4 model and stomps Buy and Hold into dust. It’s also a lot of fun watching the models evolve. Do the generated models make sense? Mostly, no. And they leave money on the table (hillclimbing problem). I stopped playing with it.
That’s a technical challenge I’d like to take up again. That old Java program still runs and I’ve still got the historical backtest data to 1980 (PMTS uses 1993 to current). I also had to replace my old computer a few weeks ago and the new ones has lots of memory and a fast processor. Time to play around.
First lets run the numbers for Buy and Hold. All the following simulations results use data from Jan 4, 1993 through Oct 29, 2013, w/o commission costs. You start with $50,000 (50K). Buying the S&P 500 Index (SPX) then you’d have 114.842 shares of SPX, now worth $203,494.64 or a CAGR of 7.04%.
But Cecil, that doesn’t include dividends! Too true. Also, you couldn’t buy the S&P500 either. SPY didn’t exist until a month later. There is a dividend adjusted SPY price series and using it would be close to reality. You’d also have $300,900.13 for a CAGR if 9.09%. That’s pretty decent and shows the value of dividends and compounding them.
But But Cecil, you’re cherry picking start and end dates!! Nobody made 9% per year after the dotcom bust and the Great Recession. Sorry, they did. At the time I write this, the SPY just hit a new high, so yes the end date does matter.
Lets say you used the Timing4 (PMTS) system instead. You would have bought 115.117 shares of SPX and at the end, you would have 92.727 shares. I said it sucked. That’s $164,308.02 for a CAGR of 5.94% .
If you bought dividend adjusted SPY (which normal people would do), Timing4 would have produced $220,345.81 or a 7.45% CAGR. Better than 5.94% but pretty sucky compared to the 9% CAGR of buy and hold.
That’s the baseline for this data set. 9.09% year after year. I’ve shown I can curve fit and do worse.How about curve fitting and doing better? Let the fun begin. I put the Genetic Programming algorithms to the problem. 100 individuals generated/bred/mutated models per generation. At generation 160 (2 minutes later, best of 200 generations). How much mo’ better best?
$929,250.63 — 15.22% CAGR on the dividend adjusted SPY. In real life it might be slightly smaller since the dividend adjustments in the data are a little wonky. Then again, that model was mostly long so it would have captured most of the dividends. It also left money on the table – it could have done better. For completeness, w/o dividends it was $665,188.41 (13.37% CAGR) It also fails on the 1980 to 1999 backtest . Oh Well. that’s why we have backtests.
That’s fun and a lot more realistic than Climate Models.
Posted in Uncategorized.