Application of Bi-Directional Grid Constrained Stochastic Processes to Algorithmic Trading

Corresponding Author: Aldo Taranto School of Sciences, University of Southern Queensland, Australia Email: aldo.taranto@usq.edu.au Abstract: Bi-directional Grid Constrained (BGC) Stochastic Processes (BGCSP) become more constrained the further they drift away from the origin or time axis are examined here. As they drift further away from the time axis, then the greater the likelihood of stopping, as if by two hidden reflective barriers. The theory of BGCSP is applied to a trading environment in which long and short trading is available. The stochastic differential equation of the Grid Trading Problem (GTP) is proposed, proved and its solution is simulated to derive new findings that can lead to further research in this area and the reduction of risk in portfolio management.


Introduction
Bi-directional Grid Constrained (BGC) Stochastic Processes (BGCSP) are described as Itô diffusions in which the further they drift from the origin or time axis, then the more they will be reflected back to the origin.
The drift function f(x): ℝ  ℝ and the diffusion function g(x): ℝ  ℝ, x ∈ ℝ, in the limit, they approach the typical constant expressions for the drift and diffusion coefficients: To visualize the impact of the BGC function Ψ(Xt,t) in (1.1), 1000 Itô diffusions were simulated both with and without BGC, with zero drift coefficient µ and unit diffusion coefficient σ, as shown in Fig. 1.
The zero drift in (a) is constrained in (b) the more it deviates from the origin, causing the hidden reflective upper barrier and hidden reflective lower barrier to emerge, together with horizontal bands to form due to the discretization effect of BGC. BGCSP have applications by solving problems involving the constraining of stochastic processes within two reflective barriers (often times hidden and not predefined) and that an event occurs when the barriers are hit. In the context of mathematical, quantitative (quant) and computational finance and algorithmic trading, we define an application of BGCSP by the following definition.

Definition 1.2. [Bi-Directional] Grid Trading (BGT)
BGT is the simultaneous placement of a Long and Short trade at every grid width g level at, above and below the initial price rate R0 and the corresponding taking profit of each trade at the nearest Take Profit level (also of width g) without any predetermined stop losses. This definition is illustrated in Fig. 2.
As the BGCSP evolves over time, it will collect (i.e., close) many winning trades and also hold on to some losing trades, which should become profitable over time. It is remarkable how such a simple trading strategy can generate profits most of the time due to frequent periods of low volatility (i.e., diffusion σ). However, when a strong trend emerges, this strategy accumulates large losses and so the trades need to be closed down before they exceed the account's current capital or balance level. When the losing trades grow too far in terms of either total count or in terms of magnitude, then the trading account can become ruined, inducing a stopping time. We call this the Grid Trading Problem (GTP).

Literature Review
BGC stochastic processes are relatively new (Taranto and Khan, 2020a-d). To the best of the authors' knowledge, there is no additional formal academic definition of BGC stochastic processes nor grid trading available within all the references on the subject matter (Mitchell, 2019;DuPloy, 2008;Harris, 1998;King, 2010;2015;Markets, 2017;Work, 2018). These secondary sources are not rigorous journal papers but instead informal blog posts or software user manuals. Even if there were any academic worthey results found on grid trading, there is a general reluctance for traders to publish any trading innovation that will help other traders and potentially errode their own trading edge.
Despite this, grid trading can be expressed academically as a discrete form of the Dynamic Mean-Variance Hedging and Mean-Variance Potfolio Optimization problem (Schweizer, 2010;Biagini et al., 2000;Thomson, 2005). There are many reasons why a firm would undertake a hedge, ranging from minimizing the market risk of one of its client's trades by trading in the opposite direction, through to minimizing the loss on a wrong trade by correcting the new trade's direction whilst keeping the old trade still open until a more opportune time (Stulz, 2013). In the case of grid trading, it can be considered as a form of hedging of multiple positions simultaneously over time, for the generation of trading profits whilst minimizing the total portfolio loss.

Derivation of Continuous Grid SDE Theorem 3.1
For a Bi-Directional grid trading constrained Itô process with a given grid width g, value ν per grid width, drift (direction) µt and variance (risk) σt, then the change in equity E over time t is:

Proof
In the discrete time framework t ∈  of Fig. 2, one can see that the equity Et at any time t is comprised of the initial equity E0, plus the sum of all the winning trades Wt, minus the sum of any losing trades Lt. We can elaborate how the progression can evolve over time, in the worst case scenario of a strongly trending market, as shown in Fig. 2b.
We can now derive the general formula for Et, where ν is the value per grid width, g >0 is the grid width, giving: where, n is the grid level reached by the price Rt at time t. However, the markets do not trend indefinitely and so Lt in (3.1) needs to be replaced with a stochastic process. In a continuous time stochastic framework t ∈ ℝ+, (3.1) becomes: where, Et = E0 at t = 0 as an initial condition and adopting the simplest of 1-Dimensional Itô Diffusion processes: noting that now we highlight that n is a function of t where:  µt is The drift (or direction) over time  σt is The diffusion (or volatility) over time, which are random and assumed independent of µt over time  Wt is A Wiener Process (or Brownian motion) as We note that (3.2) is essentially a non-standard Geometric Brownian Motion (GBM). The reason why we have not expressed it as a Arithmetic Brownian Motion (ABM) is that we require the equity Itô diffusion to be modelled as products of random factors and not sums of random terms. GBM involves independently and identically distributed ratios between successive factors.
as trading systems seek to exponentially compound E over time and an Et = 0 equates to ruin or bankruptcy. In fact, since our drift and diffusion terms are non-constant over time, then our non-standard GBM is actually a form of a more generalised Itô Processes. Finally, we note that (3.2) does not appear at first glance to be a GBM as it does not exhibit an explicit dWt term, even though it is implied due to (3.3). Substituting (3.3) into (3.2) expands to: completing the proof.
It is worthwhile noting at this stage, setting aside the constants ν and g, that since Γ1(t,µt,σt) and Γ2(σt), then (3.5) is not a standard simple linear SDE and that there is some convolution of 2 t  within the deterministic component dt with the σt within the random component dWt. This means that we would expect to see some relatively complex interactions from the underlying distribution samples. For example, negative σt values becoming positive due to 2 t  , skewing the results towards Et  0 due to the negative sign before 2 t  , which supports to a certain extent why Et has a tendency to almost surely approach 0 over time (subject to certain drift and diffusion conditions set out in the results and discussion sections).

Solution of Continuous Grid SDE Theorem 3.2
For a Bi-Directional grid trading constrained Itô process with a given grid width g, value ν per grid width, drift (direction) µt and variance (risk) σt, then the equity

Proof
Recall that (3.5) is a GBM whose well known (Oksendal, 1995) general solution is of the form: We are now in a position to solve the bi-directional grid trading SDE (3.5) by substituting Γ1 and Γ2. Making use of a change of variable s, substituting the expressions for Γ1 and Γ2, we know that the solution of a standard GBM is: which completes the proof.

Profitable Path Analysis
Undertaking a sensitivity analysis of the parameters µt, σt, ν and g as shown in Fig. 3, one finds that the model for Et is more sensitive to µt and σt than it is to ν and g, noting that µt, σt, ν, g ∈ ℝ.
We also note that most of the simulations resulted in a positive profit in Et due to the impact of grid trading on the imput Rt, one such typical scenario plotted in Fig. 5 using the MT4 trading platform which supports the theoretical model, in the first half where Et grows almost linearly. Specifically, the values ν > 1, g > 1 results in most simulations producing positive Et. Hence, we choose ν = 1 = g, simplifying (3.6) to: Plotting (4.1) in Fig. 3 shows the general theoretical nature of grid trading's potential if it is stopped early enough and restarted to minimize the risk of the losing trades. We see that the greatest Et value not only occurs when Rt is range bound (having low volatility or diffusion σt), but also when Rt is trending with relatively small drift µt and relatively high diffusion σt values.

Ruin Path Analysis and Stopping Times
Having presented scenarios that show that grid trading can be very profitable, it is now beneficial to present scenarios that show that grid trading can also lead to ruin. As the trades are accumulated, one will begin to collect profitable trades as the Balance grows linearly, whilst the Equity dips down, highlighting the existence of losing trades that are carried and not closed. Ruin occurs when an investor's account Equity Et at time t, which is the difference between the Balance Bt and Profit Pt at time t (Et = Bt-Pt) is reduced to zero or if their equity is too low (close to zero) to prevent any new trades to be placed due to brokerage rules.
We know that the grid loss accumulation process that grows via the triangular number series, grows faster with smaller and smaller values of the grid width g. A sensitivity analysis was undertaken for g ∈ (0,1) and is shown in Fig.  4, showing the transition from ruin to profitability, highlighting the importance of having g sufficiently large.
This risk of ruin occurs in grid trading systems in the long term if and when it becomes 'too grid-locked' with too many losing trades. To break a grid-lock, the underlying Itô diffusion Rt needs to have range bound movement for an extended period of time so that the winning trade total can be greater than the losing trade total. If this doesn't occur, such as during strong trends with low volatility, then the Itô diffusion's equity will eventually become 'ruined', which we relate to a stopping time, as shown in the second half of Fig. 5. This scenario in MT4 also supports the theoretical model. Fig. 3: Sensitivity analysis of various values of µt, v and g the stochastic model for Et is relatively insensitive to v and g is more influenced by the drift µt and the diffusion t and specifically their interrelationship. Most simulations resulted in exponential growth of Et, noting that Rt = f (µt, t) whilst Et = f (Rt, v, g) for some function f. + open profit if the system that is in profit ans is not closed down early enough (such as halg way over the time above), then there will be numerous losing trades accumulated that will lead to ruin (unless the favour able conditions arlse that detailed in Fig. 4.)

Conclusion
A SDE was proposed as the novel theorem of Bi-Directional Grid Constrained Trading stochastic processes and its solution was provided as the proof. From this theoretical model, a number of important properties of grid trading were uncovered through Monte Carlo simulation of the SDE and accompanying sensitivity analysis. It was shown that the grid width g and the profit P per grid width have a relatively minor impact on the equity over time Et and that the drift µt and diffusion σt have the most impact. This research has shown that it is the interrelationship between µt and σt of the underlying price rate Rt that determines whether Et is profitable at any point in time t. It has also been shown that whilst strong trends either up or down are the enemy of Bi-Directional grid trading strategies, so long as σt is relatively large, then there will be sufficient counter-trend fluctuations that better ensure that the system can grow in Et, albeit not eliminating the risk of ruin. This research also paves the way for future work on the stochastic optimization of these SDEs. This forms a rich framework to further study such stochastic processes in their own right, but can also lead to applications in quantitative finance, funds management, investment analysis and banking risk management. This paper will be leveraged in future research as we focus on deeper mathematical and statistical properties and the potential benefits of grid trading.