Designing a Trading Machine II ended with the presentation of a simulation test where the objective was to increase the number of profitable trades over the trading interval. The selected script was transformed in order to increase its buying procedures and thereby increase its number of trades (some 40-fold over the original) for the 6 years trading interval.
A Trading Machine III
March 28, 2013
Whatever the trading strategy H used, its payoff matrix was: Σt(H.*ΔP). In this concise and precise representation, all the trading activity over the whole trading interval was accounted for. From the presented chart, it was evident that the payoff was greater than zero: Σt(H.*ΔP) > 0; and also that the modifications made were highly profitable.
That I used the original version of this script or my modified version, in both cases, the common denominator was the price series: ΔP. There was nothing I could do that would have changed the price series, and since both tests would be for the same duration, this meant that only the trading strategy itself would make the difference as in Σt(H(modif).*ΔP) > Σt(H(orig).*ΔP).
The payoff matrix is the shortest notation that I could find to represent the trading activity over the whole portfolio's life. However, some useful information is not seen when using the payoff matrix. And that would be time and trading methodology. The matrix is only concerned with profits or losses over the trading interval. There is a need to extract this other information to better understand the whole process of portfolio growth.
The composition of the payoff matrix has it all; it holds short-mid-long term trade results. They are viewed as inventory changes in the holding matrix H. It should be evident that any change in the inventory is the result of buying and selling. This can be represented using buy and sell matrices of the same size as H:
H = B - S
Both the B and S matrices will be of the sparse type, meaning that most of their entries will be zeroes. All inventory changes will be the result of these buy and sell matrices while the H matrix will be the running total, the ongoing inventory on hand.
All the trading will be the result of a decision process, a decision surrogate resulting in the trading strategy. Whatever its composition, this trading strategy will obey simple math functions. Without looking at a specific trading strategy, we can set what the trading math result should be. There are two types of trades: those that have been closed and those that are still opened. Those that are closed have generated their profit or loss and the payoff matrix will show this in its cumulative process: Σt(H.*ΔP). The same goes for the still opened positions.
Σt(H.*ΔP) = [(ΣtQncl)Pt ncl - Σt(QnclPncl)] + [(ΣtQnop)Pt - Σt(QnopPnop)]
Therefore the generated profit or loss will be the result of all closed positions (ncl) plus the current value of all still opened positions (nop) where n represents the trade number. Another way of expressing realized and unrealized profit or loss. One of the first observation would be for both position types to generate some profits:
(ΣtQncl)Pt ncl - Σt(QnclPncl) > 0 closed positions
(ΣtQnop)Pt - Σt(QnopPnop) > 0 still opened positions
which says that the value of the closed and still opened positions minus their respective cost have for objective to generate a profit. This does not say how it should be done, only that it is a requirement should you want to have an overall profit from your trading operations.
Looking at it in more detail, the realized profits section simply requires an edge: that the "average" share selling price be higher than their cost; and there the number of trades n can really matter. This would suggest averaging in functions, accumulating shares at retail to later resell them wholesale with a profit.
This changes the landscape, from one trade to the next scenario, to scaling in functions. It begs for distributed entries and wholesale exits. The notion of building a position over time has some merit here.
For a trader, a simple ΔP > 0 that can be repeated indefinitely seemed to be the desired goal. But here, the emphasis is changed to an inventory management process. Instead of playing for points, you're playing for averages. And that is exactly what is seen in the simulation chart presented earlier.
It does not say how it is achieved, only that it is the objective. There should be millions of ways of achieving ΔP > 0 on millions of trades if need be. The chart showed that positions were taken over time; it is using time as an averaging process to build up an inventory within its capital constraints to then dump the inventory, hopefully for a profit and then restart the inventory accumulation process. The number of trades over the 6-year simulation shows that this process was done more than once and for a handsome profit.
The next step would be to add stock accumulation procedures in order to also profit from the still opened position side of the equation. This one is most often neglected by traders, but second nature to long-term investors. And being in the process of improving the strategy by adding a stock accumulation process, why not improve on other things as well.
Even in its early stage of development, (less than 2 hours of programming), this simulation showed promise, and one could extrapolate to the creation of entire portfolios of stocks following this particular trading strategy. What can be done for one stock, depending on available capital, can be done for hundreds simultaneously. And if hundreds of stocks are not sufficient, then there are more stock exchanges opened around the world.