March 28, 2020
The making of an automated stock trading strategy is relatively simple. It is made of 3 distinct processes: selecting some stocks on some reasonable quantifiable assumptions, determining the logical trading rules and procedures that will be applied, and executing them. The trading process can be enclosed in a single do-while loop and be executed until reaching the end of the program, that it be up to a past or future date.
There is a simple portfolio matrix equation for the whole process: F(t) = F0 + Σn (H ∙ ΔP)
Any stock trading strategy has this portfolio payoff matrix where H is the on-going holding inventory matrix which is, in fact, the trading strategy. It can be controlled and therefore will control part of the strategy's outcome. A single equation to govern it all. It holds the record of all executed trades, that there be one or a million. As simple as that.
The above is not a big or new equation, but it does apply to all stock trading strategies no matter their composition. Also, the same equation can be used to make estimates of a future outcome or compare the outcome of different strategies. As stated, the above equation depends entirely on the initial capital put to work to which is added the net sum (cumulative result) of all executed trades over the trading interval.
The Stock Selection Process
Evidently, it should start by selecting a number of stocks based on sound economic principles, or on some niche background information you have specialized in and where you know your chances of winning are similar or preferably higher to other participants in your kind of game.
You do not want to pick just about anything that is out there. You are not randomly picking stocks, you have a purpose behind that process. The objective for a trading system is to make as many profitable trades as it can under the portfolio constraint of its available capital. It also implies that you can find these executable trade opportunities, otherwise, what would you be trading on?
What is overwhelming, however, is the sheer number of stock portfolio combinations you could select (≫10400). Each different set giving a different answer. It should be said that no one in history has ever tested all possible combinations, not even close. As a matter of fact, only an extremely infinitesimally small fraction has ever been simulated. And oftentimes, some retest over and over again the same stock selection until they have massaged the data enough to get interesting results which unfortunately do not tend to do as well when applied live going forward.
But this caveat does not stop you from having to make a stock selection nonetheless, even if it is on very limited and imperfect information. The selection you make will have a major impact on your final results, to say the least. However, since you cannot test all possibilities, nor can you know which one will be the best going forward, you will simply have to pick from the ones you found and think are the best and go from there.
The mechanics of the trade could likely dictate how far you can go and how much you can achieve since you can also control part of that process.
Designing A Method Of Play
Whatever will be the nature of the trade decision process, you need to base it on something. It might not matter that much what those principles are as long as it is statistically present in the data and will continue to be. You need the ability to numerically define, detect what you are looking for, and it better be realistic. If you go for passed anomalies, you could almost be assured that going forward those anomalies might be hard to timely detect or might even not reoccur. There is some common sense to apply to the trading process in order to avoid common traps. Things like doubling down on a single dip is quite different from repeatedly doubling down on a falling knife. You need rules to not engage in the latter because sometimes such stocks not only happen, they could also not rebound and take a big chunk of your portfolio with them.
The Trade Triggering Mechanics
It is not enough to have some positive Δps. There are gazillions of ways to get Σ (H ∙ ΔP) > 0. And this, from trading a single stock to thousands at a time for years and years. Nonetheless, there are also a gazillion ways to generate Σ (H ∙ ΔP) < 0. If ever Σ (H ∙ ΔP) < -F(t), you have a big problem, you lost everything and you are out of the game. You have to be ready to accept some drawdowns in this game. There should be a defined acceptable limit. Whatever maximum drawdown you want to set, the market has no obligation whatsoever to respect it. It is a stringent rule you force your program to adhere to with its consequences.
On the other hand, your program could be set up in such a way that it will perform, on average, the same duty as having a variable and adaptable stop-loss in place. You could also design a program override option in case of unprecedented events.
The trading method can also dictate part of the outcome. Say you opted to rebalance your 200-stock portfolio on a monthly basis. This implies that from 50 to 90 percent of your portfolio will execute rebalancing transactions. Therefore, every month, you expect from 100 to 180 trades will be determined by the mechanics of your program and systematic use of your rebalancing procedures. Over a 20-year period, such a program would execute between 24,000 and 43,200 trades just due to the rebalancing operation.
Over any month, prices would have moved, but your program would rebalance those stocks anyway no matter what they did and for whatever reason. Trades would be executed simply because prices moved around.
Rebalancing will force a partial sale of rising stocks while at the same time purchase more shares of the lower performing stocks. That translates to, on average, cutting your profits short and not only letting your losses run but also increasing their respective losses. Not that good a scenario, even if it appears as a reasonable proposition.
The Expected Outcome
It is not the result of a backtest that is important. It is what will happen when going live with that program. The backtest is there to give you an idea of what could have been based on the stock selection made and the applied trading procedures.
You can take it all and convert the results in terms of CAGR. F(t) = F0 + Σn (H ∙ ΔP) = F0 ∙ (1 + CAGR)t. By rearranging the equation, we get: CAGR = (F(t)/F0)(1/t) – 1.
Another formulation for this outcome is: F(t) = F0 + Σn (H ∙ ΔP) = F0 + n ∙ xavg, where n is the number of trades and xavg is the average net profit per trade. And the above equation makes the outcome of a trading system totally dependent on how you will be trading.
Such an equation is technically trade agnostic. It does not know where the average net profit per trade comes from. But it does say that if you want some positive CAGR, the average net profit per trade better be positive. It also implies that if you want to improve your performance level, you have to increase the number of trades and at the same time, if possible, increase over time the average net profit per trade. Just simple math.
March 28, 2020, © Guy R. Fleury. All rights reserved.