May 1, 2021


Of the published automated stock trading strategies, you are presented with a diamond in the rough once in a while. You either ignore it or recognize it as such and try to find out if indeed it will have some real value after being cut and polished. It is a choice you have to make. You will still have to work to extract that gem and then enhance its value. To your credit, this is a very simple strategy.

You might not see what I see in this strategy, but, just as I did, you can study it to ascertain what it does. Most importantly, understanding why it operates the way it does. There is so much to be said, I will try to convey some of it.

You want to build something for the long term, say a retirement fund or something, then you might consider this strategy. Not all published versions of it, mind you. This strategy first evolved on Quantopian to be modified and transformed on QuantConnect where you can get a copy for free, clone it, and further modify it at will. You should fix its flaws, weaknesses, and enhance its strengths, all to your benefit.

You can no longer trust who is saying what these days. Therefore, the alternative is to prove that stuff to yourself using the tools at your disposal. For instance, whatever claims are made about this trading strategy, you can verify them on your own by cloning the program code and studying every aspect of it in detail. Only then could you make up your own mind as to its worthiness.

I am not the original designer of this strategy and am not involved with it in any way. Only bringing to your attention this potential gem that I consider in the public domain. Meaning that anyone can copy this code and do whatever they want with it. You have to show yourself that the strategy could meet your long-term objectives, otherwise, really, why even bother?

In my previous article: The In & Out Trading Strategy - Analysis, I tried to show that the portfolio rebalancing method had a major role to play in the final results. In fact, it controlled most of the trading activity.

It was also shown that it was not the composite signal that was adapted or optimized to market gyrations that controlled the trading activity since it was often wrong with its 85% of misses which technically were unnecessary moves. Yet, the strategy traded based on this signal and prospered.

When the trend was declared up, it went in stocks, as it should, and moved to bonds otherwise. Switching to cash would also have been an acceptable protective measure for when stocks, on average, were in a decline. I have not yet tried using shorts for when the trend was declared down. We all have to make probabilistic choices when facing uncertainty.

One of those choices is simply this rebalancing. In my simulations, rebalancing was done on a daily basis for over 10 years on a 100-stock portfolio. The highest momentum stocks of the previous year were selected for the job. Every time the trend switched to positive, a new portfolio was selected. We can not say the selection process was complicated.


Let The Signal Stay Long

Consider the case where the signal is declared as up for the duration (always positive). You would have, in effect, a Buy \& Hold scenario with minor adjustments along the way due to the daily rebalancing. There would be no switching to bonds since the signal would remain continuously positive.

All the stocks selected at the start of the simulation would still be in the portfolio at its end, except for bankrupted companies. You could replace any of them at any time anyway. View the selected stocks as your long-term core positions over which you will trade as long as they stay in your portfolio. It does not change the scheduling, nor its general behavior.

The holding quantity of each core position would oscillate around their preset 0.01 weights. But this would have been in an upward trending market since, as a stated premise, the signal remained long for the duration. It should be noted that the market was in a general uptrend for the most part of the past 12 years. Such a strategy would have had to be profitable over the period, and that, not by choice. Imagine, being long in a rising market... How could you possibly miss?

What would be the trading activity over the period with this hypothetical rebalancing Buy \& Hold scenario? Even if all the stocks might see some adjustments, up or down, on any given day, it does not mean that they all generated profits. Based on the sorted return chart provided in the previous article, only the stocks above the zero line (showing actual positive returns) would qualify for partial sales, whereas those below that line would have shares added to their current holdings, using differential buys to make their weights 0.01 again.

The process, as seen at this point, could translate into some kind of market folklore: sell shares on the way up, and buy the dips. I would prefer simply, sell higher.

Evidently, there is a problem with this approach. Not all your selected stocks keep going up. True. Nonetheless, risk is minimized since each position can at most have a 0.01 weight. So, even if a stock goes bankrupt, your loss is limited to only 1% of your portfolio. Evidently again, not all your selected stocks will go bankrupt tomorrow, and note that you started this process with the best performers of the year before. Furthermore, you should be able to get rid of these a long time before they even got close to bankruptcy. It is not because you automate your trading that you should lose your common sense.

I view this trading strategy as almost trade agnostic, meaning we do not know which side the stocks will trade on or in what quantities at any given time. Only that they start with a weight of 0.01 and end with the same. The rebalancing will force each stock to return to 0.01 after any price variation. Under such circumstances, even if stocks moved almost randomly, you would be getting the same trades. Now, this is important. You have here a trading strategy that would win even if all the price gyrations of its selected universe were almost randomly generated. Not that many programs could make that claim.

Regardless, we can still make rough estimates as to the number of trades returning a profit to the trading account of this simple rebalancing Buy \& Hold strategy. We need to understand the trading dynamics of this thing.


Making Trade Estimates

Over the simulation's duration, about 30 of the 100 stocks may qualify for positive partial sales on an average day. You do not know how much a trade will be, only that, in all probability, it will be positive. This strategy made only one decision, which could have easily been administrative in nature. It declared the trend as up from start to finish.

That rebalancing operation alone, over 10 years, would generate: 10y ∙ 252d ∙ 30t = 75,600 trades. All those trades would have been caused by the rebalancing procedure and almost all of them would have been profitable as they were executed over the premise that the underlying stock price went up before the partial sale (weights were higher than 0.01).

The funny thing is, you could change the composition of the portfolio on the fly and it would still make about the same amount of trades simply due to price gyrations. The price variance alone is sufficient to explain the trade execution. For whatever reason, if the stock price moved up, a partial sell was executed. No skills or expertise of any kind required.

As prices moved up, some shares were sold at a profit to return their weights back to 0.01. The rebalancing does not need a reason to execute, only a date and time, which is given by the following line of code: (self.Schedule.On(self.DateRules, self.TimeRules). That is the driving force of this strategy, a scheduled administrative decision to rebalance the entire portfolio at a specific time every trading day.

The rebalancing will return weights to 0.01 for all the stocks in the portfolio no matter what happened or what caused the change in price. Furthermore, what will control the number of partial trades will be the rebalancing participation rate. More volatility, more partial trades.

Depending on the stock selection and the time interval selected, the participation rate could range between say 20% and 40%. This would make your positive trade estimate go from: 10 ∙ 252 ∙ 20 = 50,400 to 10 ∙ 252 ∙ 40 = 100,800 trades over a 10-year period with no fault of your own. All of it caused by the rebalancing operation simply responding to market volatility. The excuse for it: ...the price moved.

If you consider being right most of the time the way to win this game, then this might not be your kind of strategy since its signal is wrong most of the time. However, if making numerous small profits is your thing, then this strategy shows itself to be right most of the time.


Introduce A Flusher

Allow the signal to change from one side to the other. At which time, the whole portfolio is flushed, no matter what. This makes it a global decision, not a selective one. As such, as the signal turns down, all shares are sold at the then-current price. No exceptions. It acts as if a global stop-loss was executed, a stop-profit and a stop-loss combined. The outcome will depend on the state of the portfolio at the time. But since the market, in general, was in an uptrend prior to showing some weakness, you might have more stocks showing a profit than registering a loss. This changes the game being played.

The rebalancer does not care how or why the price moved, only that it moved. All it will do is return the stocks to their planned weights (0.01). Whatever the reason might have been for the price change, that you forecasted it or not, that you followed the trend or not, that you had machine or deep learning on the task, used clustering, wavelets, moon cycles, astrology, or even a coin flip, the rebalancing does not take any of it into consideration.

You could have any and whatever reasoning you want, the rebalancing would still do the same thing, that is put the weights back to 0.01. That is not good news for someone hoping to design a highly productive trading strategy and be compensated for it. The rebalancing says he/she is not needed and one line of code did the job. A machine can do all the work and feed your trading account. The scheduled trading is taking precedent, it is running the game. It is the elephant in the room.

The high hit rate is no fault of the program. It is again due to the scheduled rebalancing itself. As I have said, I preferred the 100-stock portfolio with daily rebalancing. The composite signal (using ETFs) is outside the selected stocks which are the highest momentum stocks at the time over the past year. The signal is very erratic, it can flip on the tenth decimal. Some 60 flips of the 70 or so were technically overly cautious and might not have been required. The side effect was this flusher actually limited drawdowns and therefore proved to be of benefit.

You do not want something that will work just some of the time, you just want it to work going forward. Going backward (simulation) is only to give you an indication that at least it proved to be operating relatively well over past market data. But that is not enough, you want this market timer to work for when your program version will be trading live. The rest are just simulations but still needed to show your program will not blow up in your face at the wrong time. Simulations are just simulations, but nonetheless, useful, if not necessary.

There are actually two trading strategies at play in the In & Out strategy. One for when the trading signal classifies the trend as up and one for when it says the market is going down. If the signal is wrong, well, it is very simple, in general, you lose money. However, there is more that is at play here.

It is the scheduled rebalancing that is running the show. The trade signal is acting like a Granger causality thing. Using a somewhat correlated composite signal as a proxy for market timing. If the signal was right most of the time, we could justify the word "overfitted". But, that is not what I see. In my simulations, the signal flipped some 70 times, of which about 60 could have been considered unnecessary (read wrong). This is like saying that the signal was wrong about 85% of the time. If it is not the signal that is generating the money, then what is? What is at this party?

May 1, 2021, © Guy R. Fleury. All rights reserved.