Basic Portfolio Math IV

Any trading strategy can be expressed as a payoff matrix of the form: $\sum_1^n (\mathbf{H} \cdot \Delta \mathbf{P})$. Elements of the price matrix $\mathbf{P}$ are given as: $p_{_{d,\,j}}$ where $d$ is the row designation (time interval) and $j$ the stock's id. The price difference matrix $\Delta \mathbf{P}$ has for elements: $\Delta p = p_{_{d,\,j}} - p_{_{d-1,\,j}}$. Each element, the difference in price from the prior one for each of the stocks.

If you take the S$\&$P500 stocks as your selectable trading universe and set up a 20-year simulation environment, then this price matrix will have some 5,040 rows by 505 listed stocks (2,545,200 prices, based on 252 trading days per year). To accommodate minute pricing, this $\mathbf{P}$ matrix would grow to 992,628,000 price entries.

This makes the price and the price difference matrices the same for everyone. For an on the minute trading strategy basis as available on Quantopian, it would make the S$\&$P500 price matrix an invariant.

No matter what you do or how you intend to trade, you will be faced with the exact same $\mathbf{P}$ and $\Delta \mathbf{P}$ matrices as everyone else should your stock universe be limited to the stocks in the S$\&$P500.

When considering the price matrix, we should not view it as something we can alter, but simply as something that is there, and that we cannot technically change or control. Certainly not its past, that's for sure. And there is, evidently, only one such price matrix on record.

Each day, for a portfolio of 100 stocks, there will be $\displaystyle{\binom {n}{k} = \frac{n!}{k!(n-k)!}}$ combinations available to choose from. Using numbers, we get: $\displaystyle{\binom {505}{100} = \frac{505!}{100!(405)!}} = 6.18^{107}$ combinations. That is over a googol possibilities, lots of zeros. This is every trading day. Doing it at the minute level would certainly put more than a strain on any modern computer to say the least.

Still, it is nothing compared to selecting 500 stocks from a 2,000-stock universe. This would give: $\frac{2000!}{500!(1500)!} = 5.6^{486}$ possible combinations. Any subset of this should almost be looked at as if selected at random. Such a subset is like having taken 1 set out of $5.6^{486}$ other possible choices.

To grasp the magnitude of such a number, let's do a little exercise: $\mathsf{10}^{16}$ operations per second for the fastest machines on the planet $\,\mathsf{x}$ $\,\mathsf{10}^{10}$ such computers $\,\mathsf{x}$ $\,\mathsf{10}^{14}$ seconds over some 10 million years. And this adds up to only: $\,\mathsf{10}^{40}$. So yes, nobody has yet to make an exhaustive search, Monte Carlo style, or otherwise. No even close. Note that 1 million more machines would make it: $\,\mathsf{10}^{46}$ and you would still need 10 million years to do a very small part of the job.

For those thinking that 10 million years would get you almost 10$\%$ of the job done. Think again. It would represent: 10$^{−435}$ and not 10$^{-2}$. Trying to say that whatever stock selection you make might be more than just unique. You would not be able to even classify it beyond it was a possible stock selection.

The words "making the best stock selection" need somewhat to be relativized. However, you can always compare strategy "$a$" to strategy "$b$": $\;$ is $\;(\mathbf{H}_{a} \cdot \Delta \mathbf{P}) > (\mathbf{H}_{b} \cdot \Delta \mathbf{P})$ ?

Whatever your stock selection, it is a single dot on this huge, but really huge, sphere of possibilities. To such an extent that we cannot even consider it as a sampling method. Every combination of 50 or 500 stocks will produce a different payoff matrix. Not only that, but every selection, every day using the possible googols of trading strategies could not even be considered as an exploratory endeavor of the possibilities.

The exception might be for clusters in the vicinity of your stock selection process and for the trading strategy used where we might find similarities. But then, that would be over past data which might have little relevance for what is to come in a few years from now.

A way of saying that the anomalies that you have found, if not based on some fundamental market structure, might not survive going forward. They were just singularities in the googols of other possibilities. The objective becomes finding "stuff" that happened in the past and that is bound to happen again, and often in the future. You will also have to do this facing your own portfolio constraints while under uncertainty.

Whatever you find as a trading strategy is a single occurrence of something. Not even gaining the status of a speck on the tip of an iceberg. What you have is a one in $ 5.6^{486+}$ possible scenarios. Therefore, before claiming that what you have is the best in the world which might be somewhat farfetched, look around, there could be a lot of other claimants with a lot more outlandish claims to offer. So, next time, when you present your stuff, some perspective and modesty might be in order. And when you see someone else's stuff, take it with a grain of salt. You might be able to do even better than what they showed.

Whatever the possibilities, whatever the trading strategy, the payoff matrix remains: $\sum_1^n (\mathbf{H}_{z} \cdot \Delta \mathbf{P})$. It will deal with whatever you throw at it. Already, $\Delta \mathbf{P}$ is set. All that is left to make a difference is $\mathbf{H}$, the trading strategy matrix. It means that to make a difference you will have to slice and dice the price time series of each stock in such a way as to generate more profits than just holding on: $\sum_1^n (\mathbf{H}_a \cdot \Delta \mathbf{P}) > \sum ({h}_{_0} \cdot \mathbf{I} \cdot \Delta \mathbf{P})$. If your trading strategy cannot beat a long-term Buy $\&$ Hold, then you might have nothing worthwhile to show. Unless your trading strategy has other redeeming qualities on which you could put a price tag.

The question being: what will you sacrifice in time, resources and returns to obtain a smoother equity line? How much is it worth to you, or your fund, to have 10$\%$ volatility compared to 15$\%$?

Most are trying to forecast tomorrow, such as in: $\, \hat p_{d+1,\,j} = p_{d,\,j} + \Delta \hat \epsilon$. Hoping that the sequence of predictions will make things alright in the end. But this is the same as requesting $d$ predictions on $j$ stocks for the duration of the trading strategy. On a minute basis, for the S$\&$P500 stocks mentioned above, it would require 992,628,000 such predictions. Doing nothing (holding your position) is also a trading decision.

Each $d$ period you need $j$ predictions, one for each stock in the portfolio. And to gain an edge over the long term, you need to be right more often than you are wrong. Or that your average win is greater than zero: $\bar x > 0$.

The interesting thing about trading is that you can go beyond buying initial shares in each of the $j$ stocks and holding them for years: $ \displaystyle{ \int_{0}^t {h}_{0,\,j} \cdot d \mathbf{P}} = \sum ({h}_{_0} \cdot \mathbf{I} \cdot \Delta \mathbf{P})$. In fact, one could view trading as an enhanced method of play to higher profits. There are a lot of price swings between $p_{_{T,\,j}}$ and $p_{_{0,\,j}}$, even more so if the termination time $T$ is far away.

We could partition and sequence the payoff matrix in numerous parts, each spanning a time interval which when summed would reach termination time $T$. $$ \displaystyle{ \int_{0}^t {h}_{0,\,j} \cdot d \mathbf{P} = \int_{0}^{n - k - m} {h}_{0,\,j} \cdot d \mathbf{P} + \cdots + \int_{k}^T {h}_{k,\,j} \cdot d \mathbf{P} }$$We could do the same for any trading strategy $\mathbf{H}$: $$ \displaystyle{ \sum_{1}^n (\mathbf{H} \cdot \Delta \mathbf{P}) = \sum_{1}^{n-k-m} (\mathbf{H} \cdot \Delta \mathbf{P}) + \cdots + \sum_{k}^n (\mathbf{H} \cdot \Delta \mathbf{P})}$$Each day, each minute, even each microsecond a trader, a trading system, is faced with the set of decisions as to what to do next. It is the only place where it counts. That you do simulations on past data, it is only to give you a feel of what could have happened if. But, there is no profit in playing with past data. All it can give you is the impression that if you had taken such and such steps, it would have generated such and such profits and losses. The sum of all the trading activity would have made your portfolio grow if there were more cumulative profits than losses.

That you have a decision vector of 50 or 500 stocks, the problem is about the same. The number to shares $q_{_{d,\,j}}$ to buy or sell on a particular day for each stock can be determined using whatever available information you have. All you will get is a trade: $q_{d,\,j}$ where $d$ is the time stamp and $q$ the number of shares bought or sold for stock $j$. You could put it all in a holding matrix: $\mathbf{H} = \mathbf{B} - \mathbf{S}\,$ where each appended period would be the result of a holding vector: $h_{d,\,j} = h_{d-1,\,j} + b_{d,\,j} - s_{d,\,j}$ which reads: the stock inventory today is equal to the inventory we had yesterday to which we added all the shares bought today and removed all the shares sold.

A long generates a profit if: $\, h_{d,\,j} \cdot \Delta^i p_{d,\,j} > 0\, $ over that period. Evidently, if on period $d$ the inventory is zero, there is no profit: $\, (h_{d,\,j}=0) \cdot \Delta^i p_{d,\,j} = 0.\, $ And, if $\Delta^i p_{d,\,j} < 0,\,$ then, there is a loss, unless you were short which would make it a profit.

The trader is interested in the result of the next trade:$\, \hat h_{d,\,j} \cdot \Delta^i \hat p_{d,\,j} > 0\, $. He can, at any time, make an estimate, get whatever may be. But, the real question is: will it materialize? Will it happen? Making projections, forecasts, predictions as to where the price might be next is all OK. But technically it has little value if it is not consistent over the whole trading interval. This means, for the S$\&$P500 scenario, one would have to make 5,040 trading decisions for each of the 505 stocks in the index (that is 2,545,200 EOD decisions if trading daily).

We can easily imagine, at this point, that statistics and probability will enter the picture.

We need something on which to base our decision making. It can be complex, sophisticated or as simple as we want. But for sure, we will need some kind of "excuse" to execute a trade whatever the decision process may be. Again, with the S$\&$P500 example, you would need a trade triggering mechanism ready to make 2,545,200 trading decisions sequenced and distributed over its 20-year simulation interval. And that strategy should be able to do the same for the next 20+ years which should start now.

$\underline{\mathsf{Related \; Files}}$:

Basic Portfolio Math I: $\quad \;\,$

Basic Portfolio Math II: $\quad \,$

Basic Portfolio Math III: $\quad$

© June 2018 Guy R. Fleury