August 1, 2013

Optimization of a stock trading script over past data is the process of finding optimum procedures, and parameter value sets that can produce the highest possible return over the testing interval. Robustness could be said of a system having wide ranges of values for each of the parameters in the set and still maintaining high-performance levels.

That said, optimization is an attempt to extract the highest output of a particular trading strategy over past data. This optimization process will be entirely dependent on the selected stocks under test. The payoff matrix (the total profit generated) for a portfolio of stocks is Σ(**H**.*Δ**P**), where **H** is the trading strategy matrix and Δ**P** the price differential matrix. The payoff matrix is a simple element-to-element multiplication, which could easily be reproduced in Excel, for instance. In this single expression: Σ(**H**.*Δ**P**), you can analyze the output of, say, 5,000 trading days by 100 stocks, something like all the S&P100 stocks over the past or next 20 years.

**Optimization Process**

The optimization process is trying to find the best trading strategy for a particular stock selection. This should result in:

Σ(**H**(a).*Δ**P**) < Σ(**H**(b).*Δ**P**) < ... < Σ(**H**(z).*Δ**P**) < Σ(**H**(*).*Δ**P**);

where the optimum trading strategy **H**(*) would be producing the highest possible profit from all the tested and testable strategies. When changing the parameter values of a specific trading strategy, you are sure to find one strategy **H**(*) having the highest or most optimal performance level. It might take thousands of tests with varying parameter values to find this optimized strategy **H**(*). Still, this would be applicable only to the specified stock selection matrix Δ**P** over the chosen trading interval.

Change Δ**P** (your stock selection), and your trading strategy might just blow up. Also, applying your optimized trading strategy **H**(*) going forward might result in unexpected, if not unpredictable, results. Even if you maintain the same stock portfolio selection, the way each stock will fluctuate in the future will most certainly be entirely different, rendering your optimized parameter values more than slightly out of whack.

You can backtest thousands upon thousands of trading procedures, include hundreds of variables for each, and run thousands of tests, all to get **H**(*), which technically might not have much value going forward due mostly to the over-optimization process itself taken just to find **H**(*). The more you approach **H**(*) over past data, the more the trading strategy becomes over-fitted to the particular stock selection under test.

So this atlas strategy **H**(*), although easily attainable over past data, will most probably become unattainable going forward. Looking for **H**(*) over past data where all the data is available is not the same problem as looking forward. You might use the same trading strategy, but the payoff matrix has drastically changed: Σ(**H**(*).*Δ**P**(?)) since now all the 100 stocks in the portfolio will have unpredictable price series with unpredictable paths over the next 20+ years. Because Δ**P**(?) remains unknown, the applied trading strategy **H**(*) will be greatly affected and most certainly produce a different outcome than with the Δ**P**, which helped produce **H**(*) in the first place.

That is why I prefer to settle with an enhanced trading strategy **H**(** ^{+}**), meaning that the atlas strategy

**H**(*) has very little interest and is never pursued in my designs. However, I will backtest on 3 different datasets to estimate robustness; and if all 3 groups of stocks produce about the same performance level, generating thousands of trades over an extended testing period, thereby making the strategy sufficiently general in nature, then I think it might survive going forward. In the enhancement process, I will also look for global portfolio procedures and software routines that will increase performance for the whole portfolio going forward. Having reinvestment policies like Σ(

**H**(+)(1+g+T)

^{t}.*Δ

**P**) will reinvest accumulating profits as well as trading profits. This will help accumulate shares for the long term, no matter the enhanced trading strategy

**H**(

**) selected. The real strategy of interest will be Σ(**

^{+}**H**(

^{+})(1+g+T)

^{t}.*Δ

**P**(?)), the one which will be applied going forward.

**Re-Optimization**

Someone will need to re-optimize only when the trading strategy has already broken down, meaning that the portfolio will have already lost much of its value. Re-optimizing will only change the past set values of parameters and, therefore, become a variation on a theme when maybe it was the theme itself that needed replacement. If you need to re-optimize the parameter set of the same strategy all the time, it might mean that that particular trading script might not be worth much and that going back to the drawing board might not be a bad idea.

Re-optimizing all the time going forward is like saying that the previous designs were not so great since they were losing money and needed to be modified in the hope of recuperating. However, by doing this, it also alters the behavior and inventory levels of the previous strategy, making the now re-optimized strategy again a variation on a theme. It's like tweaking the past hoping it will tweak the future when already the future is unknown and will be another variation on a theme. That you do a Monte Carlo test on a strategy **H**(?) cannot give any assurance of how **H**(?) will perform when applied to the selected stock matrix Δ**P**(?) going forward.

Looking backward, you will find one optimum strategy **H**(*); however, looking forward finding this optimum strategy is almost an impossibility. I say almost since it could be possible but the odds are so high against that we are not talking about 1 in a million chance here but more likely in excess of 1 to a googol (1^{100}). My suggestion is don't even buy a ticket for this one.

**Optimization Perspectives**

Any search over past data for the atlas trading strategy **H**(*) will have a localized optimum, which will apply to the selected stocks Δ**P** over the analyzed trading interval. And in probability, you will have found your **H**(*) strategy simply because you stopped looking for a better one. The optimization process would run something like this:

Σ(**H**(a).*Δ**P**) < Σ(**H**(b).*Δ**P**) < ... < Σ(**H**(B&H).*Δ**P**) < ... < Σ(**H**(+).*Δ**P**) < ... < Σ(**H**(*).*Δ**P**)

where even the enhanced trading strategy **H**(** ^{+}**) is just one step of the search process. Sure, you want your selected enhanced strategy to perform better than the Buy & Hold; otherwise, why even bother to implement a trading strategy when you can do better just by sitting on your hands. This goes as well for any trading strategy that does not even beat the Buy & Hold like

**H**(a) or

**H**(b) above or any other

**H**(?) that failed to outperform the most basic and least time-consuming strategy of all: the Buy & Hold.

Looking to optimize past data still needs to be done, and the search should be for generalities. As I've expressed before: changing the selected stocks Δ**P** or changing the trading interval Δt under consideration and your localized optima might just disappear. Looking forward, what can be seen is a new unknown payoff matrix: Σ(**H**(?).*Δ**P**(?)).

Academic financial research literature, when talking about the Growth Optimal Portfolio, often refers to an atlas trading strategy **H**(*) as the most probable outcome over the long term. This is not the same as what I present here, which is more related to the ultimate trading strategy.

However, when you look at their atlas strategy closely, all you see is the long-term average expected market return, which corresponds to a Buy & Hold trading strategy (index buying). Academics, with the full force of mathematical demonstration, will show that long-term alpha generation tends to zero. Meaning that the most likely long-term outcome going forward is to perform at the same level as the market averages.

To generate some alpha, one has to look elsewhere.

I can express a Buy & Hold strategy with Σ(**H**(B&H).*Δ**P**) = Σ(ho**I**.*Δ**P**) = Σ(h_{o}**I**.*Δ**P**(S&P100)), where an initial weighted quantity in each of the 100 stocks in the S&P100 is held over the next 20 years. With no intervention, my outcome is expected to be the Growth Optimal Portfolio, with no significant alpha generation. The "optimized" backtesting might have shown interesting results having been done on past data, and the localized optima might have generated some alpha, but the market reality, going forward, could show that future alpha generation might still tend to zero.

This is why one has to change the perception of the task at hand. I like to use the payoff matrix representation for a portfolio's life. In a single expression, I can view 20+ years of history of all the inventory and price movements with, at any stopping time, the value of it all. In the case of the S&P100 scenario operating on EOD data, I would have 500,000 decision points where I can add or subtract a still undetermined quantity of shares in any of the stocks in the index. The EMH will advance that it might not matter what those 500,000 decisions may be since the ultimate expectation is still the long-term market return, which again translates back to the Buy & Hold, which over 75% of professionals still fail to beat. Thereby giving some credence to the Growth Optimal Portfolio scenario.

It's the same as saying that the odds of developing an enhanced trading strategy **H**(^{+}) that could outperform the Buy & Hold will be below average since **H**(^{+}) would really require alpha generation. No alpha, no enhanced strategy, and this could be stated as:

Σ(**H**(^{+}).*Δ**P**) → Σ(h_{o}**I**.*Δ**P**(S&P100)) which is again going full circle.

The point I am making in my writings is that: yes, we can design enhanced trading strategies **H**(** ^{+}**) in such a way as to blow away the conventions of those academic papers. The simple fact of generating some alpha would be sufficient to make the point.

My solution is to use administrative procedures and reinvestment policies; just like one can reinvest dividends, one could also reinvest accumulating profits and, since being on the subject, also reinvest the proceeds from trading over a stock accumulation process.

This would result in Σ(**H**(+)(1+g+T)^{t}.*Δ**P**), which would have four sources of alpha generation, including (g) and (T). For those who have looked at some of my simulations, it should be evident that (g) and (T) do not tend to zero.

And again, the real strategy of interest will be Σ(**H**(+)(1+g+T)^{t}.*Δ**P**(?)), the one which will be applied going forward. This is why I look for trading procedures and software routines that can push performance to a much higher level over past data in order to still have something significant left should I miss the mark. But notwithstanding, it would appear that the reinvestment policies in their own right might be sufficient to generate some alpha.

In my **Old Routines** articles, I showed the results of using a trading script (ADD3), which had been tested over a 6-year period. But this time, it was over a 25-year trading interval. Some 17 years of unseen data prior to the testing interval and almost 2 years after. Most would advance that there was no need to test such a scenario. The trading script should have simply broken down right after its 6-year prior test and proven worthless over its prior unseen 17 years of data. This was not the case; the ADD3 strategy performed as well over seen or unseen data over the 25-year trading interval. It showed that a trading script might not necessarily break down as soon as it is confronted with new data. It also showed that re-optimization was not used over the 25-year test.

Logic would dictate that if you do what everybody else is doing, then you should not expect to do any better than anyone else. If you design a trading script to play averages, one should not be surprised at achieving their goals. If you design a strategy to mimic indexes, then you should expect average index returns. To generate alpha, you have to go a step further, and it can be as easy as using administrative procedures. A kind of Buffett-like variation on a theme.

Created... August 1, 2013, © Guy R. Fleury. All rights reserved.