Stopping Times

This notion is rarely discussed in Quantopian forums, yet, it can have some dramatic effects when carried out in an automated stock trading strategy.

A stopping time in a stochastic process is when a predetermined value or limit is reached for the first time. Say you buy some stock and set a one-sigma exit from your entry price. That will be a random-like stopping time. In a timed-out exit, you would know when it would take place. Whereas when using a price target, for instance, you would not know when but you would know at what price the target would be reached. The exit will be executed using either method at the time or price specified and signal the end of the ongoing trade.

In automated trading, the first stopping time should be considered a little short-sighted, and at times a lot. You are interested in the profit generated by your target move. And, getting out of your trade before reaching that target should be viewed as underscoring since your program would break its stopping time even though you would have profited from that early exit. But, that, in general, is less productive than another alternative. The real problem I see is that most often the first stopping time is not the last.

Your trading program should be looking for the last stopping time, or at least, try getting closer to it. You must have noticed that when you set a price target and it is hit, the price, on average, keeps on going up, but without you. This says that your price target, even if it made you money, was not the best price target. It could have been higher since most of the time your original price target will be exceeded, and all you would have had to do was to wait some more.

Exceed the First Stopping Time

What could be done to improve performance would be to move your original price target up as the stock price is approaching it. It goes on the premise that there will be more than just one higher price above your target. In fact, you might have a series of higher highs following your exit. But, if you were not there, there is no way you could profit from them.

In a lot of trading strategies on Quantopian, it is what I see. The equivalent of exiting on the first stopping time reached. And even more often below it. The below target thing is done as a side effect to the trading methodology used, the same as for the first stopping time.

We can express a price series as follows: $p(t) = p_0 + \sum_1^T \Delta p \,$ where $\sum_1^T \Delta p \,$ is the sum of all price variations after its initial price $p_0$ up to termination time $T$. The expression could be used for any trade $n$: $\;p_n(t) \cdot q_{0,\,n} = q_{0,\,n} \cdot (p_{0,\,n} + \sum_1^t \Delta p_n) $ where is somewhere between entry and exit $0 < t \le T $. And the stopping time is the exit of that n$^{th}$ trade.

What we are trying to predict is: $\Delta p = p_{t + \tau} - p_t $ representing a time-limited segment of the price series for a particular trade. Here $\tau$ represents a random time variable of undetermined length. Depending on how we slice and dice a price series, it is by adding all the pieces that we get our final result. In a timed-out exit, $\tau$ will have a fixed value (say a fixed number of days), whereas, in a price target scenario, $\tau$ will be a quasi-random variable of still undetermined length.

We could see trades as having a first hitting time at $t_0 $ following whatever code triggered its entry. And some time later, a stopping time $t_0 + \tau $ as we exit the trade.

A Critical Component

This makes it a critical component of any trading system. But, and this is a serious but, we are less than good at determining those hitting times and stopping times, especially if we trade in bulk like a hundred or more stocks at a time.

Answer the question: who many times in your last 1000 trades have you exited a trade at its highest (long) or lowest (short) price with a profit? If you did this exercise, you might find out that only a small number of trades would have qualified out of that 1000. And since you know that you will be wrong most of the time, why not push those hitting and stopping times further out of reach in order to profit even more from your trading decisions?

Some wonder, apparently not many, how could such high CAGR as presented in the first post be possible? The answer is relatively simple. It was by pushing on those self-imposed hitting and stopping time delimiters. Moving price targets higher as prices got closer. And at the same time, increasing the number of trades while raising the average net profit per trade. Also, two critical numbers in any trading strategy.

The task is especially difficult if you choose an optimizer like CVXOPT to do the trading since its main task is to flatten out volatility, seek a compromise for its set of weights, and thereby, often accepting involuntarily the below price target figures. To counterbalance this, I forced the optimizer to accept my weighing scheme which allowed share accumulation financed by continuously reinvesting trading profits in order to raise the overall CAGR.

The Need to Innovate

As trading strategy designers, it is our job to be innovative and force our strategies to do more, even if it requires strategy reengineering to do so. In the above-cited strategy, I pushed even further by adding delayed gratification. This pushed the equation toward: $\Delta p = p_{t + \tau +\kappa} - p_t $ where $\,\kappa$ represent some added time beyond the first stopping time. It means that even though your trade qualified for an exit at the first stopping time, the exit is delayed further with the average expectation that $\Delta p$ will be larger and thereby generate more profits for that trade. Notice that the shorts in that scenario were also profitable where they were mostly used for protection and capital preservation.

This is the same technique I used in my DEVX8 program, which was long-only, to raise the average net profit per trade. And raising the average net profit per trade while increasing the number of round_trip trades will result in a higher payoff matrix. Which was my goal from the start. It made $\kappa$ quite valuable.

Again, we are all faced with choices. It is up to us to design the best trading strategies we can.