Strategy Design Defects

The Payoff Matrix notebook introduced the mathematical backdrop. The Game Inside notebook elaborated on some of the mathematical constraints faced by a trading strategy. While this one: Strategy Design Defects will start to address some of the pitfalls encountered while designing one's trading strategy.

Some trading strategies fail simply due to bad designs, and a lot of them do. I would say "stuff" not usually considered by the strategy designer but that will have a negative impact at the portfolio level. So negative in fact that it could not only reduce a strategy's long term effectiveness, meaning underperform, but goes as far as totally destroy a portfolio.

Notes on The Simulated Example

In the previous two notebooks, I used the output of a trading strategy posted by one of the Quantopian forum members. I just needed an example and was looking at that one at the time, meaning that it could have been an other. It would have served the same purpose.

From the example, I made some projections based on its simulated numbers. For instance, over its first 2-year period, the strategy made $ \$ 1.483$ million making 268,000 trades $n$ with an average profit per trade of: $\,\bar x = \$\, 5.53$, frictional costs included: $\, n \cdot \bar x = 268,000 \cdot \$\, 5.53 = \$\, 1.483 $ million.

First reaction was: I want this trading strategy. Study everything it does, find what makes it tick. A rough estimate extrapolating the first 2 years to 11 years was pretty close to the simulated numbers and suggested that $\bar x$ could have remained relatively stable. If fact, $\bar x$ might be close to a limit as $n$ increases, since: $$\displaystyle \lim_{n \to \infty,\, with \,\,\bar x > 0} \displaystyle{\frac {\sum_{i=1,\,j=1}^{n,\,k}(H\,.^*\Delta{P})}{n}} \to \bar x $$

If $\bar x$ is a limit, then, it better be positive: $\bar x > 0$. And this, for whatever trading strategy $H$ you want to put on the table. It is more than understandable. Should $\bar x$ be negative: $\bar x < 0$, then, your trading strategy would be losing money until the trading account reaches zero.

$$\displaystyle \lim_{n \to \infty,\, with \,\,\bar x < 0} \displaystyle{\frac {\sum_{i=1,\,j=1}^{n,\,k}(H\,.^*\Delta{P})}{n}} \to - \bar x $$

with: $\bar x < 0\,$, it can only mean you lost the entire portfolio since you would have crossed the zero line. It does not say how long it will take, only that if $\bar x < 0\,$, you will get there.

Doing a projection to fill in a 28-year data vacuum provided the following chart where $n$ grew to 4.0 million trades:

Chart #1: A(t) vs CAGR (\$ 1 million scenario)

The trading strategy would not have behaved as smoothly as depicted in the chart, but it would have reached the ending numbers based on the assumption that the trading, and $\bar x$, would be kept at about the same level which is not that far fetched. Already the $11^{th}$ year projection was relatively close to the actual simulated data, even if it was 9 years out. And since $\bar x$ tends to a limit as the number of trades increase, the assumption was only: will the trading strategy continue to trade at about the same pace? And the answer for this particular trading strategy was yes.

Everything looked great. Except, the CAGR line was declining all the time. To the point that if you ran the trading strategy for 30 years, it would have its CAGR fall down to the equivalent of having had an 11% CAGR for the whole trading interval. Something close to what the market as a whole might have provided to a buy & holder (≈10%). So, in all, not that great.

This is symptomatic of many trading strategies, they don't account for the limiting factor of $\bar x$ which tends to make their trading strategy linear, and thereby exhibit diminishing returns as they grow.

You worked hard, making on average over 130,000 trades per year for 30 years (≈520 trades/day) and you get what amounts to 1% more in CAGR. Nonetheless, that 1% extra was still worth more than \$ 500,000 at year 30. Of note, one could have put, at most, $3\%$ more capital at work on a Buy $\&$ Hold scenario and achieved the same results.

One is left with more than an impression that the strategy somehow broke down, since its CAGR, year after year, was declining, being less and less productive to the point of tending to market averages. All the work, but not that great a performance. Still, the strategy came out positive: it would have made $\$\,22,230,000$ in profits when extrapolated over this 30-year timespan.


and there seems to always be a but, the assumptions made were on an initial capital of $\$\,1,000,000$. The real picture is somewhat different.

The test actually used $\$\,10,000,000$ as initial capital. That changed the picture considerably. What appeared as a nice and maybe acceptable picture to some, now seems ordinary and not worth investing in it so much. Here is the output on the $\$\,10$ million scenario.

Chart #2: A(t) vs CAGR (\$ 10 million scenario)

The CAGR seems to have collapsed. It started below market averages to terminate far below it as well. For a long term trading strategy, it did not fare well. Let's say it might not be enough. One thing is sure, it did not scale well.

But, that is not the point I'm interested in. The point is:

The strategy's CAGR is breaking down because the strategy was programmed that way! It was programmed to do so.

It was part of its trading methodology. It was not an outside factor clobbering the trading strategy due to changes in "regimes", or anything like that. The market stayed what it was, the strategy developer should have seen it coming, but...

Year after year the CAGR would decline. A built-in feature of the trading strategy itself. The reason for the decline: there is no compensation for the "normal" CAGR degradation in this program. It plays a linear game.

You don't see many trading programs compensate for this deficiency. I have some 2,000+ on my machines, and rarely do I observe some direct or indirect compensation measure. Even portfolio management literature seldom cover the subject. As if preferring to say: all trading strategy fails in the long term, than do the work and compensate this "normally" decaying CAGR.

Nonetheless, one can, and should, compensate for this structual deficiency.

It is the main reason why so many trading strategies seem to stop working with time. No one addresses within their code the CAGR degradation over time. And, naturally, not having coded compensation factors, the trading strategy's performance simply fails in long term CAGR terms. It still made money, in fact, it made the exact same amount as in chart #1. It is just that in chart #2, it is not that significant anymore. It would have been discouraging to see the CAGR decline, year after year, for 30 years, never seeing it go back up to what it once was.

The Game is Hard

It is not just write a program, pass go, and collect $\$\,200$. You have to work at it. For instance, compensation for the CAGR degradation in the above example will require either of 3 things: increasing $n$, $\bar x$ or both. To compensate, I need a quadratic function in $n$, and this, just to maintain the CAGR flat.

The equation for this was given in The Game Inside notebook: $$ \,\, n = \displaystyle \frac {A_0 \cdot \lbrace (1+r)^t - 1\rbrace}{\bar x}$$

$n$ needs to increase in step with $(1+r)^t$. Not doing so will generate chart #2. The following chart shows a compensated CAGR curve, making it constant over the trading interval:

Chart #3: A(t) vs flat CAGR (\$ 10 million scenario)

The chart says: it is expensive not to compensate. In time, just keeping the CAGR flat would have generated more than double the scenario without (see the A(t) line). This also tends to put an opportunity cost on what is being missed.

This compensation is gradual, as shown in the equation above. And it involves only $n$ in this preliminary look at the compensation problem. Nonetheless, it was sufficient to correct the problem.

Who Pays the Compensation Process?

Well, the market, of course. During the first two years, the system traded 268,000 times at an average profit per trade of: $\$\, 5.53$, generating $\$\, 1.4$ million in profits. That is where the money comes from, from the market itself. It will finance the operation and you will still have extra reserves that could be used elsewhere to be even more productively.

Also, as you will be trading more, you will generate more cash going into the account which can then be used to make even more trades. You are starting a positive feedback loop. It appears to have only one requirement: $\bar x > 0$.

The task becomes to find more trades of the same nature as those you have already executed. Some will say, I can not find more of those trades, my system is not built that way. All it does is make so many trades and that is it. I do not know how many trades will be done, nor do I know how to generate more.

Such a simple problem in fact. During the first 2 years, as was said, the program did 268,000 trades. You could take anyone of those and double the bet size for a fraction of them and voilà. No need to find more, you already have them on hand. Just duplicate the number you need to maintain your CAGR flat.

And based on chart #3, it should more than double your performance in total return, in dollars that is, where it counts.

The $\bar x$ Solution

The above problem could also be solved using $\bar x$. Its equation is similar to the $n$ equation above.

$$ \,\, \bar x = \displaystyle \frac {A_0 \cdot \lbrace (1+r)^t - 1\rbrace}{n}$$

Here too, one would need to increase $\bar x$ by a factor proportional to $(1+r)^t$. This could be considered a more difficult problem than just increase $n$. Increasing $\bar x$ involves increasing the average spread for all the trades, or increasing it enough on a subgroup of trades such as it could have an impact on the overall average itself. Also, as shown above, as $n$ increases, $\bar x$ tends to a limit. Moving it becomes more and more difficult. And still, it has to be done.

This puts you right back to the trading methods used. How flexible are they if requested to increase $\bar x$?

I use some of these techniques in my own programs, so I think I will be able to do those in Quantopian as well.

The Reason You Build a Stock Trading Strategy

You build a trading strategy so that your portfolio can grow. You want a positive CAGR solution to this CAGR game. And you want it to exceed the averages.

A direct consequence of building positive CAGR portfolios is that, as they will grow, you will get diminishing returns for the same effort. When you look at $A(t) = A_0\, + n \cdot \bar x \,$, the payoff is not some sophisticated function but a simple multiplication. And as $n$ grows, $\bar x$ tends asymptotically to a limit. Meaning that the search for a "profit" has changed.

It is not as much a search for the hihgest $\,\Delta p\,$ anymore, it appears more like a search for which trading method will give the highest $n\,$? It changes the search for profits, it literally changes the game.

Having set $\bar x$ as a limiting factor as $n$ increases has made the portfolio's appreciation almost linear. The millionth and one trade will not have a tremendous impact on $\bar x$. It will already have settled down. However, one should note that the millionth and one trade is increasing $n$ which was already a way to increase profits.

How Do They Miss the Mark?

Why is pratically no one compensating for the misgivings of their trading strategies? I really don't know. I see it as so evident that it has to be done, that I can't understand why someone would not do it.

It is not as if someone really had a choice. You are just talking math, nothing esoteric. But math of consequence nonetheless.

How can they operate as if linear?

Simple, one answer is: they use fixed profit targets and stop losses. Whatever the trading system they use, as the number of trades increases, these limits will converge to their respective inherent values, just as $\bar x$ does. Some trading methods faster than others. For example, if you take a 10% profit target, over the long term with a lot of trades, your system will tend to generate that 10% return on all the trades that reached their targets. Almost by definition.

Profit Degradation

Another source of profit degradation often built-in a trading strategy is based on fixed trading barriers. This too involves profit targets and stop losses. In this case usually same percentage limits, like a 10% profit target and 10% stop loss.

It is as if the developer does not realize that having a trading system that will trade a lot, like the example mentioned, will see its portfolio degrade simply due to the trading itself. Meaning that the trading strategy will degrade simply because $n$ is increasing. And yet, like in many programs, no form of compensation for this phenomenon was designed or visible in the example used.

How pervasive is it? Here is the equation that governs this:

$$ A(t) = A_0 \cdot (1 + f)^W \cdot (1-f)^L \to 0 \quad$$

even with a 52% edge when $(W+L) \to 5,000\,$. In such a case, a $\$\,10$ million scenario, with a $10\%$ profit target and stop loss, would see the portfolio value drop to $\$\,63,534$, and that is with the given edge.

$f$ is the profit target and stop loss percentage, with $W$ the number of trades won while $L$ is the number of trades lost. You will find this equation very sensitive as $f$ increases, and as $(W+L)\,$ the total number of bets increases.

This degradation, if not taken care of, can ruin a porfolio even if it has a positive edge. It will need an edge of sufficient magnitude to compensate.

Or, one could neutralize this degradation from within, as in:

$$ A(t) = A_0 \cdot (1 + \frac{f}{1-f})^W \cdot (1-f)^L = A_0$$

it says request more as profit target than for your stop loss by a factor of at least $\frac{1}{1-f}$. A more detailed explanation of this phenomena is available in my paper on Fixed Fractions. For the $10\%$ profit target case: $ \frac{0.10}{1-0.10} = 0.1111$. To compensate, it is sufficient to increase the profit target compared to the stop loss to 11.11% instead of using 10.00%. Not that big a move, and this would be sufficient to protect one's portfolio as the equation above states.

Still, a trading strategy using equal profit targets or stop losses should compensate for profit deterioration. It should come with any trading system that intends to trade a lot, as in the example provided. It is something that a strategy has to battle, but that can be easily corrected, or compensated for.

Strategy Design Defects

If $\, \bf {n \cdot \bar x}\,$ is all there is to generate all the profits, then it has to explain what you do, or at least show the end result of what you did.

Can trading strategies have other defects? Yes. Some of which are related to a misrepresentation of what the game really is, if you want to treat it as a game.

Is a moving average predictive? Well, it might if you made a profit, and might not if you lost. The point being: no, not really. But, it does not mean the moving average should be ignored, however, maybe not used as a predictive tool. But, again, anyone can design the trading strategy they want. It certainly is not my money.

I see what has been presented up to now as strategy structural defects. All built-in the programs we make, if we want to. I guess everyone has to do their homework, everyone has to make their choices.

Improving Performance

It is a game of money. You make bets on stocks, collect your winnings and pay for expenses and losses. You expect that overall, over the long term, you will end up a winner. But is that enough? This whole presentation was to show some of the pitfalls, some even disastrous, powerful enough to obliterate one's portfolio. But your mission, if you accept it, is to design trading strategies that will not only be protected against these defects but having the ability to thrive and outperform averages.


If you retain a single idea from this notebook, it would have to be to compensate for the CAGR growth degradation of your portfolio. Charts #1 and #2 give examples.

Then, if you use percent profit targets or stop losses, you should compensate, preferably over-compensate, for the deficiency in your betting system. Otherwise, again, the price for not doing so, in a high trade volume environment, is your portfolio. It is not a probability that your trading strategy might break down, it is a guaranteed outcome unless you can provide a sufficiently high overall positive edge that can be maintained and that can afford to pay for these deficiencies.

Oftentimes, it might not be that your trading strategy is breaking down, but only not compensating for the time, trade volume, or profit degradation among other things. When you do out-of-sample tests, live or simulated, it might not be that your trading strategy breaks down due to a structural change in the market, but more likely for not compensating for what are structural defects in your trading program.

So, the conclusion is, whatever trading system you devise, do not build these structural defects right in and condemn your trading strategy from the start. And this, before it even starts trading.

© 2016, September 12th. Guy R. Fleury