November 3, 2017
A Game You Can Play
Imagine proposing to buy stocks in an upmarket. For over 6 years, my website has had a simple message: accumulate shares for the long term and trade over the process. Using trading profits as a source of added capital to accumulate more shares. A kind of self-financing proposition. Over a dozen different stock trading strategies have demonstrated how it could be done.
Out of this group, my favorite has been DEVX8 (Deviation X, version 8). I have more articles on it over the past 3 years than on any other. Its latest iteration has already had two walk-forward simulations. I thought it was time to do another, this time with almost a year of out-of-sample data. The last test was done using November 16th, 2016 price data. This strategy was last modified in November of 2015. This is making it a two-year walk forward as if paper trading for two years.
This test will run for 21.62 years. It will deal with the same selected stocks. This enables comparing the strategy on its own merits and seeing what one more year would have done to the portfolio based on running the same program. The only added ingredient will be time.
Evidently, the program will have to prove itself, meaning do what it was programmed to do or show that it failed to meet its design objectives. One objective is to show that a strategy does not inevitably break down over the long haul. A stock trading strategy can be designed to last and prosper.
In a simulation like this, the program has total control. This is like having the code set in stone from the beginning and for the duration. While going forward, we can adapt our trading strategies to the prevailing circumstances if needed. Whereas here, the program stays the same for the entire testing period. Notwithstanding, DEVX8 is designed to be controllable from the outside. It even has a retirement fund option where one can contribute over some years to then extract a yearly income. But that is not the purpose of this test.
Regardless, over the years, returns are still expected to slow down a bit due to the increasing portfolio size. It is hard to sustain higher-than-average compounded returns. But, there are ways to compensate for this long-term performance degradation. It is by planning what you want your trading strategy to do over time that it might just do it. Without this understanding of your trading strategy, where do you think you will end up in some 20 years?
So, let's dig in.
This new test will go from June 1995 to the present, 21.62 years. In all, 5,622 trading days. This will add 235 trading days out of an expected 252 (excluding holidays). A new random seed will be used. The purpose is twofold. One, to have the ability to replicate any part of the test, and second, to show that even if all trades are the results of random-like functions, the total outcome is not, even though all the numbers will be different. I estimated that DEVX8 made over 5,000,000 calls to the random function (random()) over this test.
A trading program using quasi-random-like entries and exits is not the same as another program not using any. Non-random programs, under the same testing conditions, will give the same answers test after test, whereas a program like DEVX8, without a seed, will give a different answer every time.
The original version of this public script dates back to something like 2002-04. It had no random functions to begin with. I started modifying it in 2011. My latest version is dated November 29, 2015. Meaning that since then, no change has been made to its code. Also, this means that any data after November 2015 is unseen data and evidently out-of-sample data by definition.
Having designed this trading strategy, I knew before doing the test what would be the outcome. Not that I would know the numbers, but I knew what the general behavior of the program would be. That is: accumulate more shares since it had more time and still trade more over the process. Therefore, it should end this test by generating more profits.
DEVX8 has a strong tendency to accumulate cash over the long term. As a consequence, I do expect that the overall return might somewhat slow down a bit due to all the cash held which could impede the portfolio's progression since the cash held in this model is not carrying any interest. Nonetheless, the strategy will have added profits and an increase in stock inventory unless prices go up too much. The strategy does sell on the way up. This, in turn, reduces inventory and adds to cash reserves.
In an upmarket, the strategy's general behavior will be to sell as prices rise all the way to the top. Thereby converting its stock holdings to cash at what could be considered an opportune time. The program itself has no notion of what a top or bottom is. It simply executes its code.
DEVX8 is a strange creature. It trades entirely using quasi-random-like functions. Whether it be entering a trade or exiting one. It is a random function that determines if a trade is taken or not. It is also a controllable program by design. In the sense that its behavior can be set from outside the program using its 6 slider-like functions to dictate its behavior: do a little more of this and/or a little less of that. Those controls are seen at the top of Chart #1. Should one wish to reduce the strategy's outcome, simply reduce those numbers and job done. DEVX8 will trade less, accumulate less cash and shares, and generate fewer profits. See The Deviation X Strategy for an example.
The strategy has an elaborate randomly generated delayed gratification function, which can impact a trade's stopping time, which often results in getting a better execution price. It is a funny concept: a trade needs to win a local lottery to exit, which will delay the exit by bumping it to the next day, where a new lottery is taken. The effect is to have a trade wait and earn its exit, which, in probability, might occur at a higher price.
I view the program as a hybrid trading system with unique properties. It has a Buy & Hold side to it, which allows for the continuous holding and accumulation of shares in building its portfolio core. It trades over this process, accumulating profits that will either go into acquiring additional shares should a random function trigger one or will build its cash reserves waiting for other random-like opportunities.
Whatever the strategy's future over those 2 years (since November 2015), the program had no means of knowing beforehand what was coming its way. It would have to survive and thrive with what was to come.
The Test Result
The following chart is a resumé of the present test. Each stock used the same trading script. Portfolio metrics were recorded, and time-stamped screen snapshots were taken of all those numbers as a validation process and a verification tool of the outcome of every stock under test.
This test was performed only once, with its output recorded. It resulted in the chart below:
#1 DEVX8 – Summary Test Results (November 3rd, 2017)
(click to enlarge)
From the above chart, each stock was allocated $500k with a $10k trading unit. Meaning that each individual bet was what $10k could buy at any one time. Not enough to make an impact on the prevailing prices. And since trades were executed as market orders at the open the next day on high-volume stocks, there was no question as to whether the trade would be taken or not.
Overall, the strategy did 109,986 trades. It is more than sufficient to declare this as a sizable sample for statistical purposes. The average number of trades per stock was 10,999. This is more than needed to make it statistically significant.
Due to the trading process over the accumulation of shares, we do have a large number of closed trades. All of which were at a profit. The reason is very simple: stocks could only exit a trade if profitable and exceed their randomly changing price targets. Therefore, whenever a trade was closed, it was a profitable one. Sale proceeds, including profits, were added to cash reserves.
Profits are broken down by origination: profits come from closed and still-opened positions. All the stocks are showing profits. Closed positions (69,118) generated profits of $1,672,415,016, while another $200,037,817 is still in open positions. Liquidating everything on November 3rd would have resulted in a total portfolio profit of $1,872,452,833.
Starting with $5,000,000, this portfolio grew at an average 31.54% CAGR over those 21.62 years. I would say quite a remarkable feat.
The Trading Thing
Trading alone could not have generated these results. Neither would a Buy & Hold strategy.
Look at the trading side of things. For one, there is no way that anyone could achieve a 100% winning rate unless they held on long enough. And this would mean years and years, in itself defeating the whole idea of trading since you would be holding on to your positions. In turn, this would greatly reduce the potential number of trades. And making it hard to even outperform the averages. Not only that, but as one would progress in time, and as the portfolio would grow, it would require flipping more and more of one's portfolio all the time.
It might be considered relatively easy to flip a $5,000,000 portfolio on a regular basis, but flipping a $1,000,000,000 one is another matter entirely. Yet, that is what would be required and more based on the above chart.
As for the Buy & Hold side, even though each stock managed at least an 11.45% CAGR, the portfolio average came in at a 21.67% CAGR. Which in itself is remarkable. Way above average, it could be considered in the same circles as Mr. Buffett's own 20% long-term performance level. But, and this is a serious but, the Buy & Hold would be really hard-pressed to generate a higher CAGR. If we look at the most expected long-term market averages, it is less than 10%. Of note also is that most of the Buy & Hold scenario's added return is coming from 2 stocks (BIIB and GILD). Without those 2 stocks, the Buy & Hold portfolio return would fall to a 13.14% CAGR.
So, one would have to conclude that trading alone cannot do it. Buy & Hold alone cannot do it either.
However, combining them could do it, as demonstrated in this simulation. As if a way to outperform is simply to mix both worlds and take advantage of their inherent properties.
DEVX8 is relatively easy to understand. Its trading rules have been described in prior articles and simulations. Nonetheless, here are what I consider its main attributes. DEVX8 does not know the future and does not make a prediction on it, except it does make this long-term bet that, on average, stock prices will rise. In this sense, it does make Mr. Buffett's bet on America.
DEVX8 is necessarily a trend-following strategy. Its primary intention is to accumulate and hold on to shares for the long term. It wants to build a portfolio. However, it does have a weak hold on things. For a profit, it will let go of some shares and recycle the profits into its trading system. It becomes its own provider of trading funds. It is this feedback loop that increases its performance to above average. It is understandable. You get the benefits of a long-term Buy & Hold, to which you add the profits from trading, which are then used to accumulate even more shares.
Trades are the result of quasi-random-like functions. You do not know when and how many shares will be traded, but you know the general behavior. This statistical cloud of quasi-randomly moving stock prices will fluctuate with this underlying upward bias which empowers this long-term betting system. In reality, the whole program is just one bet: it is Mr. Buffett's bet on America. The program expects that, over the long term, the average stock price will go up. Especially the selected ones since, from the start, they were big names and market leaders with positive prospects.
Comparing Results
We need to compare results. What did the added year bring? First, let's redisplay last year's results:
#2 DEVX8 – Summary Test Results (November 16th, 2016)
(click to enlarge)
The differences between chart #1 and chart #2 are as follows:
#3 DEVX8 – Differences From Last Year
(click to enlarge)
Overall, for the year, the strategy generated $218,705,432 in added profits. It made 10,928 new trades. Very close to its portfolio average of 10,999 in chart #1. Therefore, it remained consistent with itself. The strategy closed more positions, especially in the stocks that rose the most, resulting in 10,727 closed positions. Almost as much as it opened during the year. The average percentage of winning trades went up by 2.34%.
The total profit increased for every stock in the portfolio except one (CVS). However, it increased its holdings by adding 293,027 shares to its number of shares held. Nonetheless, it still managed a 29.03% CAGR over the testing interval with a cash reserve of $77 million.
What appears to have happened during the year is that as some stocks rose, profitable shares were liquidated in the highest rising stocks (FDX, GD, HD, LMT), generating the bulk of the profits. Consequently, these liquidations reduced still-opened positions. Net, for the year, 1,094,623 shares were sold, all at a profit.
As expected, the average CAGR declined a little. But by less than one point (-0.79%) to 31.54%. A more than respectable long-term performance level.
Of note, it was said that the strategy would also accumulate cash as it evolved. Last year's test had 60.13% of its ending portfolio value in cash. This increased to 67.74% in the current test resulting in cash reserve of $1.268 billion. More than enough to do a lot of stuff.
A Game You Can Play
This new walk-forward and out-of-sample test is again a demonstration that not all trading strategies fail. If the underlying principles are sound, a trading strategy can keep on doing what it was designed to do.
The strategy was liquidating positions as prices went up when the market as a whole was reaching new highs. That is what the strategy is designed to do. The objective of trading is to try to sell at a profit, and there, the program does that without fail. At what will be the next market top, it will be mostly in cash as it will continue to sell on the rise.
Chart #1 confirms DEVX8's inherent trading philosophy. It also shows that a well-planned strategy with a bent on accumulating shares for the long haul can perform better than either a Buy & Hold strategy or a stock trading strategy alone.
Combining these two strategies helps accelerate capital appreciation, not because you are predicting future prices, but by taking advantage that stock prices do fluctuate all the time. And just making sure that what you sell is at a profit on the way up to be purchased back at a discount later on will be sufficient to outpace market averages. You will be making the money of the Buy & Hold side and the trading side. And by reinvesting those ongoing profits, you have those profits also gain profits. The best of both worlds.
Sure, you have a program, a machine, out there, doing its thing. But was it not the whole purpose of designing an automated stock trading strategy? To have your program do better than what you could have ever done by yourself.
In the end, that program is you. It is your trading philosophy, your perception of the markets, your strategy design, and your view of the game. A game you can play the way you want and win!
Screenshots
Follows the screenshots for the stocks in this portfolio. The printed numbers on each chart confirm the numbers on Chart #1. For Chart #2, see The Weak Buy & Hold article.
#4 DEVX8 - ABT
(click to enlarge)
#5 DEVX8 - ALL
(click to enlarge)
#6 DEVX8 - BIIB
(click to enlarge)
#7 DEVX8 - CVS
(click to enlarge)
#8 DEVX8 - FDX
(click to enlarge)
#9 DEVX8 - GD
(click to enlarge)
#10 DEVX8 - GILD
(click to enlarge)
#11 DEVX8 - HD
(click to enlarge)
#12 DEVX8 - LMT
(click to enlarge)
#13 DEVX8 - LOW
(click to enlarge)
Created... November 3, 2017, © Guy R. Fleury. All rights reserved