July 23rd, 2015

Still More DEVX V6

In my previous article: More DEVX V6 was shown a simulation of the program over 10 stocks over durations of 10 and 20 years. The point was to show that this particular stock trading strategy would easily survive not only over its first 10-year trading interval, but also over a 20 year period, and this including one year of walk forward.

Over the past weeks, I tried to visualize more improvements to that program. Still more ways to enhance its long term performance. After struggling with the matter for a while, I finally figured out how to code some of these new procedures. It took only 10 to 20 minutes to code and debug the routine.

In all, two lines of code were added to a program that already stood at over 2,000 lines. Talk about an incremental improvement. Like in everything else related to strategy design, a new procedure should be able to show its merits in a backtest.

Testing a trading strategy against another is easy. It can be written in payoff matrix notation as: Σ(H(strat_B).*ΔP) >? Σ(H(strat_A).*ΔP)? It reads: is the improved strategy B better than strategy A? Using the same stocks over the same time span (20 years) should prove sufficient to show if, at the portfolio level, one strategy is better than the other.

Here are the charts of the 20 year scenario on the same stocks as in the previous article:

    ABT – 20 years


    ALL – 20 years


    BIIB – 20 years


    CVS – 20 years


    FDX – 20 years


    GD – 20 years


    GILD – 20 years


    HD – 20 years


    LMT – 20 years


    LOW – 20 years


The impact of the two added lines of code can be extracted:

Σ(H(strat_B).*ΔP) – Σ(H(strat_A).*ΔP) = ?

Here is a summary of the above charts in numbers:


    Trade Summary – 20 years
Trade Summary


The last line, in the above table, shows the difference between the net liquidating values of the last table in the previous article and this one. This would imply that the 2 added lines of code would be worth more than $250M. Impressive. The added lines were procedural in nature, designed to apply to stocks in general which also explains why all 10 stocks were positively impacted.

Why do a test like this?

To show that at times, even some limited code change can have quite an impact on overall portfolio performance. The payoff matrix still has for governing equation:

A(t) = A(0) + Σ(H(1 + g)t.*ΔP).

Increasing the feedback loop had for result to increase g which in turn increased overall performance. You won't be able to predict where the improvements will have the most impact or which stock will benefit the most, but still improvements will be seen in most of the metrics. In this case, it meant ending with more cash, more shares, more positions, and more profits.

It took some time to figure out how to do this code modification, and much less time to program and debug it (only 2 lines of code after all). It also demonstrates that anyone can look to improve on his/her strategy design as if there was almost always some improvements to be made as long as they are sufficiently general in nature.

Hope this can be of help to some.

Created... July 23rd, 2015 © Guy R. Fleury. All rights reserved.  

Alpha Project