Sept. 16, 2020
The automation of a stock trading strategy appears at first glance as a simple process. You program what you think you might have done on a discretionary basis, except your computer can do it much faster and more often. You try to transfer to a program your acquired knowledge, understanding, logic, and trading methods by first simulating the outcome of your procedures over past market data.
That trading logic is not that complicated, stocks only go up, down, or sideways. So, you know what to do: buy what is going up, sell or short what is going down, and do not waste your time on stocks that do not move. On average, stocks tend to go up (see a long-term market index chart), but a lot do go bankrupt. Too many to ignore. The main reason for all the caution.
Designing a trading script based on your way of thinking can turn out to be more elaborate and have much more nuances than anticipated. Things I find important are part of the most basic of all. 1) a trading strategy needs to survive over the long term (say 20+ years). 2) the portfolio must perform better than having bought a low-cost index fund over the same interval. 3) the strategy must be doable, meaning realistically executable. 4) it must also be scalable since your portfolio should grow larger with time. In fact, hopefully, and most probably, compounding over time.
In short, you want to “securely” make the most money you can within your own portfolio constraints and risk tolerance over the given long-term time interval. Your objective is to build a fund, either for others or for yourself. You are ready to take on a certain amount of market risk knowing you cannot eliminate it all. You accept to take those risks but within your limits. So, you spread that risk over the number of stocks in your portfolio.
No matter which trade you do or how you do it, your profit will be from q ∙ Δp > 0 where Δp is the price difference between the selling and buying price, and q the quantity traded. Since you will be doing a lot of trades (the reason why you automate, otherwise you might still trade discretionarily), you will need the net sum of profits and losses over all the performed trades (n) to be greater than zero Σn(qi ∙ Δipi) > 0. However, just being positive is not enough. You should aim for Σn(qi ∙ Δipi) >= X your long-term objective, whatever that amount is.
Your job, if you accept it, is not to win a trade here and there, it is to win the long-term game! View the series of trades that will be taken as: F0 + Σn(qi ∙ Δipi) = F0 ∙ (1+r1) ∙ (1+r2) ∙ (1+r3) ∙∙∙ (1+rn-1) ∙ (1+rn) = F0 ∙ (1+ravg)t. In that equation, if ever, one of the rn returns equals minus one (∃ r <= -1), your portfolio just went to zero or less, meaning it went bankrupt, you lost it all. Game over. Again, the reason for all the caution and not putting all your eggs in the same basket.
Common Sense Prevails
It is not because you are to automate your trading procedures that common sense should fail to prevail. One should plan where he/she wants to go and remain consistent with their objectives even in the face of future uncertainties. That's the whole point, to grow your fund securely over the long-term and make sure you succeed even if you do not know this future.
There is a lot of money to be made and/or lost playing the stock market that the trading be automated or not. The market does not care how you play the game or how often, nor does it care if you played at all. However, should you decide to play the game, why not play it wisely? Why not delimit in your own way how you are going to play that game? And, in order to find your way, you need to understand the rules of the game and the impact the millions of other players have. You need to average things out, to keep a statistical viewpoint of what is happening.
Your Strategy Design
With time, you will figure out that reality is a lot more complex than your trading program had anticipated. Nonetheless, you can design any kind of trading strategy using whatever you want. So, it is not the market that is playing tricks on you. It is you not doing your homework, designing misconstrued programs, or not fully understanding the nature of the game. There are trillions and trillions of ways to design your trading script, each with a different outcome. And, whichever program you finally choose, it will execute its commands on this future and unknown price data even if the final results are presently unknown to you.
Technically, you are interested in stock prices that only go up or down, a binary choice, almost the flip of a coin. You need to follow logic and trading methods that adhere to your way of thinking of the markets. You opted to automate grand scale. You know that what you designed is made to deal with hundreds of stocks at a time if need be. And you know you cannot type fast enough to do all those trades by hand. Automation almost becomes an obligation in order to reach the next level.
If the outcome of a payoff matrix equation for a rebalancing portfolio's
is enough to explain its long-term performance, shouldn't your own
program also comply?
Your Payoff Matrix
The portfolio payoff matrix applies to any stock portfolio. In fact, it could apply to most assets that can appreciate in time and that you can trade in some way.
Here is your portfolio's payoff matrix: F(t) = F0 + Σ (H ∙ ΔP) where H is the trading strategy. You have the price differential (ΔP) of your trading universe (P) whatever it is, and, you have an ongoing stock inventory H. Each time period, you add a row to matrices H, P, and ΔP. These matrices can grow quite large since each row is dependent on the time interval chosen. A 20-year price matrix P for 500 stocks would have 2.52 million data entries. The same would hold for the H and ΔP matrices. However, no matter the size of these matrices, the payoff matrix equation will still hold.
That you do thousands or hundreds of thousands of trades, it is the same problem: you want to maximize a positive outcome of the payoff matrix: Σ (H ∙ ΔP) >= 0, but also make it high enough to outperform a low-cost index fund. Based on the equation, all you have to work with is the trading strategy H and your stock selection matrix P.
Sept. 16, 2020, © Guy R. Fleury. All rights reserved.