June 27, 2016

Here is an aspect of trading that I have not seen often discussed in stock trading strategy design. It starts with the concept of line segmentation, or the slicing of stock price time series, and deals with what might be considered stochastic stopping times.

Most aspects of it have been covered before in financial literature, but maybe not in this fashion. Hoping to provide a slightly different perspective.

A completed trade can be characterized by its endpoints: price(out) - price(in) = Δp, resulting in a profit or loss. This can be easily painted on a price chart as line segments as shown in chart #1 below. To obtain the result of multiple trades, you simply add up the price differentials: Ʃ(P&L) = ƩΔp, assuming the quantity traded was constant (q*ƩΔp). 

#1  IBM Price Series (first 500 trading days: ≈ 2 years )

IBM #1

(click to enlarge)

First, a note on how the above chart was constructed. All I wanted was to have an example of a long-term price series. I picked IBM starting in January 1995. It was a good portfolio candidate in the mid-90's, sales were strong, and the immediate future looked promising. So, why not IBM? Back then, how could you go wrong picking IBM, be it in the 70's, 80's or 90's? This demonstration could have been done using a lot of other stocks. One could consider chart #1 as the result of some swing trading system with still unspecified entry and exit rules.

The orange lines were selected not from the chart, but from the numbers in the spreadsheet, as in click here, extend the selection and stop, with no period preselection bias. I just wanted line segments, probable trades, time spans. And that is where the orange lines fell on the chart. This to mean that it was not intentional where they fell, only that they did fall somewhere.

Entry and exit prices are only concerned with the endpoints: price(out) - price(in) = Δp. The path in between seems almost irrelevant since the endpoints alone is all that is needed to completely describe a closed trade. Each exit could be viewed as a trade's stochastic stopping time, whatever the reason behind it.

Chart #1 shows four trades with one having a small loss (call them swing trades or whatever). The total profit from those trades came in at $14.78 per share, on an initial price of $13.88 representing a 43.7% CAGR (compounded annual growth rate). However, just buying and holding the same shares would have produced $15.87, a 46.4% CAGR. This for doing nothing other than sitting on one's hands, except for the initial buy decision, of course.

This to make the point that even if you trade, you might, under some conditions, not produce more than a simple Buy & Hold, or obtain results that might not be that far away from it.

The IBM price series was the same for everyone, and everyone had for mission to extract the most out of it, either by holding the shares for the duration or by slicing the price series in such a way as to generate more profits than just holding.

By looking at the chart, one can see that there were not that many opportunities unless you went for smaller time slices or also allowed shorting. This could have increased the number of trades, with for side effect to reduce the average profit per trade. You faced a trade-off, which might pay off or not depending on the slicing methodology used.

A Buy & Hold has only one line segment: L(1) = L(B&H) = price(T) – price(0), where p(0) is the initial price and p(T) its terminal price. In chart #1, it has for duration 2 years (500 trading days). While at the other extreme, there could be 500 line segments from open to close, one for every single day of the price series. Both extremes add up to the same number. You could do one trade and obtain $15.87, or do 500 trades and get the same $15.87.

But, not quite. With commissions as low as $0.01 a share, it would amount to $10.00 to execute all 500 trades (buy and sell), leaving $5.87 as net profit. This changes the picture considerably.

The Buy & Hold would have $15.86 while still holding on to its shares, and the trader would get $5.87 for all his troubles and constant monitoring. This translates to quite a disadvantage for the trading side. From the 43.7% CAGR stated earlier, the CAGR would now drop to 19.29%. Still a desirable outcome, but when compared to the Buy & Hold, the immediate and more fundamental question could have been:

Why trade in the first place if you could have made more by not trading at all? 

The Trader's Solution

The obvious solution for the trader is: make better line segmentation, make more and/or better trades. Which will necessitate better entries and exits with for objective to have the sum of these segments total more than $15.86.

And, it is here that the trading problem really starts.

The question is: how do I segment those lines such that their total will exceed L(B&H), the length of the Buy & Hold? If I can't do it, then L(B&H) was a better solution since it would have produced more with much less effort.

Not enough segments, just as too many segments might lead to underperformance when frictional costs are accounted for. A trader should not be in the business of designing trading programs for the benefit of his broker, as in the above example, but in the business of trading to make money with the understanding that there are various costs involved which do include commissions. And also, there is a minimum performance level expected from the endeavor: you must perform better than the averages, you must exceed L(B&H).

This is so basic. It can turn out to be not a question of which methods or indicators do you intend to use, but more about "what" will segment those price lines in such a way as to make you profit more than L(B&H)? About any trading method giving you this "edge" might be a desirable and acceptable solution.

So, somewhere within all the possible combinations of line segments C(n, ..., k), there should be at least one solution, but most probably, not just many, but an infinity of solutions, with L(C(n, ..., k)) > L(B&H), meaning that the selected or executed combination of line segments exceed the Buy & Hold. Even though it is not demonstrated, we can intuitively see it on the chart as acceptable and realizable.

Furthermore, even doing an exhaustive search for all possible combinations of line segments satisfying the condition: L(C(n, ..., k)) > L(B&H), it would not help in determining which combination could be the best going forward, nor would we have enough computing power on the planet in our lifetime to do all the possible scenarios. But we could go for general trade behavior that could be tested over past data knowing that it would still apply going forward even if we don't know the actual path of the future price series.

You could go at it from a statistical standpoint of what determined a trade's entry triggering mechanism, and separately, its exit for each of those line segments.

This requires some kind of order within all the chaos, meaning that there are explicit and discernible trading rules governing entries and exits spanning the duration of the entire time series.

This is the same as saying you have an explicit trading system with predefined trading rules that will generate x number of trades, on average, with $y average profit per trade. It is not a search for anomalies, but for trade triggering mechanisms that will be such that the selected combination (a) will generate: L(C(n, ..., k) = C(a)) > L(B&H) almost assuredly.

That is where the stopping time comes in. You can start a trade from any point, but it is completed only on its exit, at its stopping time. And it is from there that you do the bean counting. The where, in fact, you return more, or less, than your original bet to your trading account.

Referring to chart #1, one could not predict the entry or exit points shown on the chart. There were no preset rules, no preset order. They were as if selected out of the blue. If you were on January 3, you could not have known that the 3rd trade would have started a year later, and might not have had any justification to take the trade. But that is of no consequence.

By extending chart #1 using the same selection technique, I got:

#2  IBM Price Series (first 1,00 trading days: ≈ 4 years )

IBM #2

(click to enlarge)

This time, the Buy & Hold generated: $50.46 per share. While the line segmentation technique produced: $43.33, again below the Buy & Hold. It could have been more positive, but just came out that way.

Both techniques were profitable with impressive performance results in their own rights. The Buy & Hold had a 46.74% CAGR while the line slicing came in with a more than respectable 42.39% CAGR over those 4 years. I think anybody would say yes to both scenarios. But still, the Buy & Hold did produce more. It should be noted that IBM kept on going up even if its pace has slowed down since.

Chart #3 tries to illustrate the slowing down. Still, overall, IBM continued to rise. Over the 21.3 years, it achieved an 11.77% CAGR which is relatively close to the market's secular average of about 10% including dividends.

#3  IBM Price Series (5,365 trading days: ≈ 21.3 years)

IBM #3

(click to enlarge)

The upper blue line is the dividend and split-adjusted closing price over the 21.3 years, while the bottom line (pink) is the corresponding detrended price series. What is remarkable in this chart is the polynomial regression line with an r-squared at 0.9513 which greatly explains the overall price movement. It is understandable, IBM is a big organization and it moves ever so slightly in time. It progressed till the year 2000, then almost went to sleep for the next 10 years to re-emerge after the financial crisis to again get into some growing pains after 2013.

The point that I'd like to make is that even if there is a lot of stochastic movement in that price series, overall from all the chaos emerges a kind of structure to this quasi-randomness with longer than expected effects.

Even though on a day to day basis, it is difficult to determine the price orientation, when looked at with some perspective, one can see trends that can last for years as the polynomial regression shows. One could bias his/her trading methodology in the same direction as the polynomial regression, and all that would be necessary would be to monitor the ongoing prospects of the company. This only requires to answer the question: are IBM's overall corporate actions, and the market in general, conducive to higher IBM stock prices?

The linear regression line has a 2.78 cents per trading day uptrend (y = 0.0278x + 19.04), while one standard deviation stands at $1.56. Therefore, 99.7% of data points (3σ) will be within ±$4.69 from the mean price. We can see in chart #3 that a 3σ channel has been exceeded by more than 0.3% of the data points.

My interpretation of the top polynomial regression in chart #3 would be that it is the best estimate of the perceived intrinsic value of IBM shares with prices fluctuating around this mean in search of its actual value.

The polynomial's value changes slowly as for any big organization, and one could trace the major trends by studying IBM's history and corporate decision making. For instance, it should be no surprise that between 1995-2000 major market forces were at work: increasing PC sales, more powerful machines, Window 95, the Internet, the year 2000 bug. All contributing to increased sales and profitability which then was reflected in higher stock prices.

After 2000, sales dropped dramatically. Everyone that feared the 2000 bug had purchased new machines and verified their software programs to assure themselves to survive any difficulty that might have arisen. Almost everyone was now equipped with new machines with no need to replace them over the next few years, and running validated software that would also not need to be changed for years as well. The market saw the decrease in profitability, and as a whole kept the stock price in check for the next decade, and saw the share price fall by more than 50% during the period.

The point being made is that the estimated intrinsic market value of IBM shares changed slowly, more along the polynomial regression line than the actual price itself which was the investor's perception of what the value really was, and which was subject to erratic interpretations from one day to the next.

Tools to approximate the intrinsic value would have guided a trader as to which action to take as the price gyrated over time. An envelope, or channel, over this estimated value could have given numerous entry and exit points. Just waiting for extremes and taking advantage of every price swing of significance.

Would be left to find ways to formulate trading procedures that not only could be applied to past price data but that when applied to future prices would retain their programmed behavior. These procedures would not give the same answers going forward, but they would behave about the same, under similar circumstances. And this should be the whole idea behind backtesting.

The Stock Trading Strategy Experiment started by showing that there was nothing powerful in a MACD indicator based system when used in a long-term trading strategy. Even though it was profitable, it was not enough, it did not beat the Buy & Hold.

From there, trading procedures were added to increase the number of trades, to increase the number of line segments.

This first part of a 5-part article ended showing a more than significant increase in performance, close to 400 times better than the original MACD test, outpacing the Buy & Hold by a wide margin and generating positive alpha. Compare chart #4 to chart #10 in the Experiment article.

Part II of the trading experiment showed the application of enhanced trading methods at the portfolio level over the 20-year period. To improve performance further, more line segments were added. In chart #1 (Part II), the portfolio summary showed that making $200k available to each stock and playing $10k at a time ended with an average 25.97% portfolio CAGR. 9 of the stocks had not seen the strategy before the portfolio test since only ABT was used in the debugging process making that simulation more than just out of sample.

Part III also emphasized the need to increase the number of line segments in order to increase performance further. Note that the operation was done not by extending the time period but by simply increasing the number of trades over the same trading interval as in the previous tests, meaning finding more trade opportunities, more line segments.

Since the strategy presented in the Stock Trading Strategy Experiment used trading units, it made it totally scalable, up or down, as was demonstrated in Part IV.

Part V tries to explain some of it. Giving reasons as to why it all behaved that way. There is, I think, much to learn from the whole process of this "experiment" which was conducted live, adding procedure after procedure in accord with my trading methods.

It also made all this accessible to anyone, either wishing to duplicate the effort or go even further.

Price Variations

There is always this big debate on price movement randomness. Does chart #3 above exhibit price randomness or not? In hindsight, and looking at chart #3, the regression line doesn't seem to say randomness, but it does translate some major fundamental shifts in IBM's valuation. Over the 21-year period, there were only four major changes in price direction, each lasting for years at a time.

The intrinsic value could be considered as a pretty good approximation of the actual valuation when considering the regression's coefficient of determination (R2 = 0.9513).

Here is a curiosity, found chart #4 in my older files. What is interesting is its similarity to chart #3. Yet, chart #4 is a randomly generated price series. As if randomness could have long-term structures too, even if they remain unpredictable, meaning that you will be able to see these structures only after completion, and not before.

#4  Random Price Series 

Random Price Series

(click to enlarge)

One could use stochastic differential equations to describe the price movement of either chart #3 or #4. Both equations would stand as a suitable representation for their respective price series. One being totally unpredictable, whatever you did, while the other had for price movement some underlying fundamental reasons to behave as it did. A strange coincidence which also raises questions of its own. Of the gazillions of gazillions possibilities, I had on my machine a randomly generated facsimile of the real thing and behaving in about the same manner.

You get the same kind of long-term structure in both of these charts. One you could profit from using a set of trading rules, and the other, not at all except by chance alone. And yet, the same program could effectively win on both.

You add an upward drift to chart #4 and you get something that is very similar to chart #3.
The same trading program could be applied to both charts and be similarly profitable. But there is this nagging concept, one of the charts was totally unpredictable! The program might have worked on chart #4 but there is no reasonable explanation of why it could have!

There is much randomness in stock price series, but, as chart #3 can show, there is also this underlying notion that stock prices do fluctuate around their intrinsic valuations, and what we see is just an expression, an averaging process done by all participants of all future expectations synthesized into a single number: the actual share price. If you can determine what a listed company will to do in the next few years in the pursuit of their long-term objectives, then you can design worthwhile trading strategies. Whereas, in chart #4, even if you tried, there would be no underlying explanation. You could still win or lose, but it would all be by coincidence or by luck alone.

Now, can I not raise the question that the IBM price history for the last 21 years looks a lot like a price series in chart #4 which has been randomly generated!


Created... June 27, 2016,    © Guy R. Fleury. All rights reserved