Structure of a Stock Trading Strategy

As I understand it, Quantopian's objectives can all be expressed in broad lines of thought. Their prime objective is to maximize their multi-strategy portfolio(s). I view it as a short-term operation like trying to predict some alpha over the short-term (a few weeks to a few months) where long-term visibility is greatly reduced. As if adopting a "we will see what turns out attitude" with a high probability of long-term uncertainty.

I would prefer to view their optimization problem first as a long-term endeavor where their portfolio of strategies will have to contend with the Law of diminishing returns (alpha decay) that they like it or not. And this, that their strategies compensate for this alpha decay or not. It is a matter of finding whatever trading techniques are needed or could be found to sustain the exponential growth of their "anticipated" growing portfolio.

A trading portfolio can be expressed by the outcome of its payoff matrix:$\;$ Total Profits $\,$ = $\displaystyle{\int_{t=0}^{t=T}H(t) \cdot dP}$

The integral of this payoff matrix gives the total profit generated over the trading interval (up to terminal time T) whatever its trading methods and whatever its size. The formula will give the proper answer no matter the number of stocks considered and over whatever trading interval no matter how long it might be (read over years and years even if the trading itself might be done daily, weekly, minutely, or whatever).

The strategy $H_{mine}$ becomes the major concern since $\Delta P$ is not something you can control, it is just part of the historical record. However, $H_{mine}$, will fix the price at which all the trades are recorded. All those trading prices becoming part of the recorded price matrix $P$.

We can identify any strategy as $H_{k}$ for $k \subset {1, \dots, k} $. And if you want to treat multiple strategies at the same time, you can use the first equation as a 3-dimensional array where $H_{k}$ is the first axis. Knowing the state of this 3-dimensional payoff matrix is easy: all entry are time-stamped and identified by $h_{k,d,j}$ thereby giving the quantity held in each traded stock $j$ within each strategy $k$ at any time $t$.

How much did a strategy $H_{k}$ contribute to the overall portfolio is also easy to answer:

$\quad \quad \displaystyle{w_k = \frac{\int_{0}^{T} H_{k} \cdot dP}{ \sum_1^k \int_{t=0}^{t=T}H_k \cdot dP}}$

Portfolio holdings are time functions which can be evaluated at any time. The same goes for strategy weights $w_{k}$. Nothing in there says that $w_{k}$ will be positive. For instance, according to Quantopian's contest procedures, a negatively performing strategy ($\int_{0}^{T} H_{k} \cdot dP < 0 $) is simply eliminated.

Understandably, each strategy $H_{k}$ can be unique or a variation on whatever theme. You can force your trading strategy to be whatever you want within the limits of the possible, evidently. But, nonetheless, whatever you want your trading strategy to do, you can make it do it. And that is where your strategy design skills need to shine.

Quantopian can re-order the strategy weights $w_{k}$ by re-weighing them on whatever criteria they like, just as in the contest with their scoring mechanism and declare these new weights as some alpha generation "factor" with $\sum_1^k b_k \cdot w_{k}$. And this will hold within their positive strategies contest rules: $ \forall \, w_k > 0$.

Again, under the restriction of $\, w_k > 0$, they could add leveraging scalers based on other criteria and still have an operational multi-strategy portfolio: $\sum_1^k l_k \cdot b_k \cdot w_{k}$. The leveraging might have more impact if ordered by their expected weighing and leveraging mechanism: $\; \mathsf{E} \left [ l_k \cdot b_k \cdot w_{k} \right ] \succ l_{k-1} \cdot b_{k-1} \cdot w_{k-1} $. But, this might require that their own weighing factors $\, b_k $ offer some predictability. But, I have no data on their weighing mechanism.

Naturally, any strategy $H_{k}$ can use as many internal factors as it wants or needs. It does not change the overall objective which is having $\, w_k > 0$ to be considered not only in the contest but to have it high enough in the rankings to be considered for an allocation.

Quantopian can add any criteria it wants to its list including operational restrictions like market-neutrality or whatever. These become added conditions that strategy $H_{k}$ needs to comply with, otherwise, again it might not be considered for an allocation.

The allocation is the real prize. The contest reward tokens should be viewed as such, a small for "waiting reward" for the best 10 strategies in the rankings: $ H_{k=1, \dots, 10}\,$ out of the $ H_{k=1 \, , \dots, \, \approx 300}$ participating.

Your Trading Strategy Or Mine

From what preceded, all the attention should be put on strategy $H_{mine}$ or $H_{yours}$ depending. I will use its generic format $H_k$ for whatever it might be in the gazillions of choices. The task is to design a trading strategy that will exceed average long-term market expectation and then some as an added reward for all the work done and the skills brought to the game.

What should be the nature of this trading strategy since it can be anything we want?

The ultimate goal is still to have strategy $H_k$ outperform its benchmark by a wide margin: $\int_0^T H_k \cdot dP \gg \int_0^T H_{spy} \cdot dP $. It will not be instantaneous, evidently. Building a portfolio is really a long-term endeavor. One thing you do not want to see is "crash and burn".

Delegating Trading To A Black Box

A major constraining strategy design element might be the requirement of using an optimizer to do the trading. That it be Quantopian's Optimizer API (used in Quantopian's contest) or the CVXOPT optimizer (the one I used), both delegate the trading activity to a "black box" where you have no control of what is going on inside. It is the optimizer that will determine how many shares will be traded in which stock at what price and at what time.

The more constraints we put on this black box, the more it will fail to produce higher returns. As if saying that because we are using an optimizer, our trading strategies might produce lower returns over the long haul as if by default, or more appropriately, viewing it as: it is all it could do. A trading strategy has a structure, even if it is fuzzy and chaotic. However, its general behavior can be averaged out when you have a high enough number of trades. You can say things like: on average...

What Can an Optimizer See?

Either cited optimizers will only detect what they can see. Should there be no trends (short or mid-term), the optimizer will answer with a flat zero. If the data is totally random, it will answer with zero. And, that is not a way to generate profits, no matter what anyone might say. Also, the optimizer will not see beyond the data's rolling lookback period. That mathematical contraption cannot extract blood from a stone or a flat line, no matter how much you try, neither can I. It is only if you can supply them with trending data that these optimizers can see and do something.

Nonetheless, the two optimizers, especially when target weights are used, can be shoved or pushed around. It can be done by feeding them a special diet of your concoction, with these altered weights you can force them to behave differently. In a way, forcing in your own objectives, your own agenda, even in an uncertain stochastic and chaotic trading environment.

Forcing The Optimizer

For instance, one of my high-flying strategies highlighted in my latest book (Reengineering Your Stock Portfolio: https://www.amazon.com/dp/B07R4Q7SZF) used the CVXOPT optimizer for its trading. The strategy demonstrated returns way above market averages, not only over a couple of years but over a 14-year period. The outcome was not a random occurrence or some luck factor. The strategy was simply feeding the optimizer with "prepackaged" weights. I used the word simply because it was exactly that. An overview of this can be seen in the following forum: https://www.quantopian.com/posts/reengineering-for-more.

There were no real factors per se in the above trading strategy, but price was at the center of it all. I wanted my equations to follow the general directive: $\,$Total Profits$\,$ = $\int_0^T H_k \cdot (1+g(t))^{t} \cdot dP$. This implied that the bet size would grow exponentially. And, as a "side effect", it would compensate for the alpha decay due to the Law of diminishing returns. In fact, I made the strategy overcompensate which gave it its exponential equity curve. Part of this is illustrated graphically in the following post: https://www.quantopian.com/posts/quality-factors-composite-feedback-requested-please#5d67dad066ea457e47eb5342.

What was "required" was finding some "excuse" that would trigger more trades more often and to increase the average net profit per trade as the portfolio grew in size. Both these task were relatively easy. It was all part of the inner workings of the above equation. The trading profits were continuously re-invested to generate even more profits creating this self-funding positive feedback loop.

The NET Average Profit Thing

Your trading strategy $H_k$, whatever it is, will have an average net profit per trade at termination time. This is illustrated in the following chart (from one of my books) as a normal distribution (blue line) with its average return $\mu$. In reality, it is not a normal distribution (it will have fat tails, high kurtosis, and skewness) but for illustrative purposes, it is close enough.

The task is to move the whole distribution to the right as a block by changing its center of mass, and at the same time give it a higher density. This means having the trading strategy do more trades with a higher average net profit per trade. Gradually moving the center of mass to the right will compensate for return degradation. The farther right you move the distribution the better, evidently within all the portfolio constraints. As a side note, by my estimates, the Law of diminishing returns will slowly catch up and kick back in after some 20 to 25 years. It gives me ample time to figure out ways to give the strategy more upward momentum.

It is not that you are predicting where the market is going (except maybe in a general sense), it is predicting what your trading behavior to market changes will be. And putting your strategy on steroids: $\,$Total Profits$\,$ = $\;(1+g(t))^t \cdot \int_0^T H_k \cdot dP\;$ will do just that.

Expressed in this fashion, it makes it explicit that you are the one providing the upward thrust to your existing trading strategy by making it trade more for a higher average profit. Slowly at first, but increasing the pressure over time. The scaling function: $(1+g(t))^t$ can be internally or externally controlled. For instance, setting $g(t) = 0$ will eliminate its influence.

You want to outperform your peers, then you will definitely have to do more than they do. It is not by doing the same thing or some variant thereof that you will do better. Note that all this might require that you view this long-term trading problem with a different mindset.

Trading on an Excuse

In Reengineering For More (https://www.quantopian.com/posts/reengineering-for-more), the strategy used the AverageDollarVolume over the past 4 months as a factor. The rationale appears simple enough: if a stock trades a lot with a high AverageDollarVolume, then it is liquid and most probably part of the higher capitalization stocks.

However, the AverageDollarVolume has very little predictive powers. First, it was at least 2 months out of date, meaning that trades would be taken based on what was a baseline average 2 months prior. Under these circumstances, the AverageDollarVolume should be considered as almost a random number. It goes like this: how can the AverageDollarVolume of 2 months ago able to tell you what the price of a stock will be tomorrow, next week, or next month for that matter?

The last expression above has moved the responsibility of enhancing your trading strategy directly into your hands. It is also giving you some control over your trading strategy $H_k$. I use pressure points to enhance performance, but I think there are many other techniques available to do an equivalent or better job.

Should you go that route too? I am not the one to answer that question. Regardless, we all have to make choices.