Tuesday, November 13, 2007

Gamble over the weekend

The Man:

So I took a gamble this weekend, and decided to rewrite part of my code. This part was particularly nagging to me because the original code (8.2 and earlier) has two parameters that are used to optimize the back testing. This is a logical connundrum, because it uses prior knowledge of the future as part of the algorithm to fit the answer to a supposedly "future blind" algo. This logical fallacy will lead to optimizations that don't fare well in the "real" future. In other words, my back testing was not pure, and if we relied on it for extended periods of time past a prior optimization run, the parameters may have drifted enough to give bad answers. This is not good, especially if money is involved!

So I rewrote the "energy field" function that determines what days are "buy," "sell," or "wait." Only this time, I didn't just start out at the keyboard. I took the time to write "the algorithm" in my notebook so that I would have a concise path forwards. That helped out tremendously! The code was written in only a few hours, and I found that I could stop at any time. That's because I had already written down what would happen next, and it was easier to put the programming down when I knew what would be written next! This was perhaps to most important lesson that I've learned!

The net effect is that the gamble paid off... I think. The algorithm is now more robust in that it requires minimal optimization. In versions prior, in order to get 30% over buy and hold, I needed to heavily optimize the parameters using an iterated DOE. I didn't have enough computing power to use another ubergenetic optimization algo on top of the 24 hour day-long-with-5-CPU-cluster back test. It would take at least 100 days before my optimization would be complete, and by then, the parameters would have already drifted!

Now I hope that my changes will work, but we'll see if I'll need to add an additional couple lines of daily optimization... I'll need to test it on a few stocks that I know have different optimal values, and each ticker takes one day to complete. If all goes well, we'll roll out version 8.3 to the masses by next weekend!

More later.

No comments: