June 4, 2017

What Can an Automated Stock Trading Program Teach You?

Obviously, to program until there are no bugs left. The important word: program, is just that, a program. An understanding of what you want to do is nonetheless required.

A software program that trades stocks live is playing with real money. It is as if it was not enough for you to lose money on your own, you had to program a machine to do it for you. A way of saying: there are prerequisites.

Designing a stock trading strategy will go through the same process as designing about anything else. You need to analyze the data, then extract from it generalities where your program will be able to first detect and then take action. Trading is a very simple process: you buy stuff, and then sell it back. As if a definition.

But then, you add a small requirement: it needs to be done often, and end with a profit. You want to know that you will win before you even start the game. And there, the whole picture changes. It is not simple anymore.

Anybody can flip a coin. It is when you ask: make a profit doing so that the task changes considerably. Then, everyone starts talking about statistics, probabilities, and expectations.

None of the talk will change the outcome which has been known for centuries. We will, however, learn a lot about stochastic processes and randomness. It does not make us win the coin-flipping game. It only explains why we did not win and had a zero expectancy of winning. The more we would play, the more we were asymptotically tending to a zero profit scenario.

Playing the coin tossing game also told us that there were no methods of play that would assure us of ending with a profit. If we did end with a profit, it would be by luck alone. There are no skills that could help us. Nor are there any mathematical tool that can assure us to win. The expectancy will remain zero whatever we do, whatever notion we would want to put on the table as corroborating evidence. None of it would change the zero expectancy.

Borrowing from my book: Building Your Stock Portfolio, chart 14.1 showed 1,000 randomly generated price series with zero expectancy.


 #1 No Drift Scenario
No Drift Scenario


(click to enlarge) 

The chart says that if we want to play as if tossing a coin, then our long term expectancy is zero. We would be playing just for the fun of it. One of the 1,000 lines is the top line. You have 1 chance in a thousand to get it on one trial. Even if we take 50 or more lines, our expectancy remains zero.

Since our expectancy is also to pay commissions and fees, we will be expected to gradually lose money no matter what. As if saying: do not program binary trading systems. We know the outcome even before we start. So, why program any of those?

We change a little thing. We add drift to the random equation and everything changes. There is now a play where we are almost assured of winning if we play long enough. And it will be sufficient to play long enough to win. Again, borrowing from my book:


 #2  With Small Drift Scenario
With Drift Scenario


(click to enlarge)

It should be evident, whatever method we want to play, it should be predominantly to the upside. And the longer we would play the game, the more we would make.

It stops being a game of chance. It becomes a routine we do. We bet for the upside due to the inherent bias. It is like using a biased coin. One should play on the side of the bias. Playing the other side will almost assure us to lose over the long run.

And since we will be playing the small drift scenario, we should design our trading strategies to take advantage of it over the long term.

In July 2012, as a demonstration, I designed an Excel spreadsheet that generated random-like price series with and without drift. Added randomly set trading decisions, meaning that buying was done at random just as selling was. See part 2 of the 3-part article series: Changing the Game

The conclusion was: a relatively small positive drift was sufficient to make almost every simulation win (in the order of 99.9%+). All the prices series were still randomly generated, just as all the trading decisions, and yet, it would end up winning no matter what randomness was thrown at it, as long as there was this small upward drift.

An extrapolation to a real stock market was easy to make.

Created... June 4,  2017 © Guy R. Fleury. All rights reserved. 

Alpha Project