Xem Tiếng Việt
Chương 6Original (EN)

Chapter 6: Time Series Reversibility as an Algorithmic Trading Indicator


Chapter Overview — 00:00

A time series is statistically reversible if its probabilistic and structural properties remain unchanged when the time arrow is reversed (t→−tt \to -t). While physics and non-linear dynamics frequently utilize time reversibility to identify entropy generation and chaotic regimes, financial markets alternate between near-reversible random walk behavior and highly irreversible, non-linear phases (such as explosive speculative bubbles or cascading liquidations).

Standard technical indicators (RSI, moving averages, Bollinger Bands) suffer from massive mutual multicollinearity. Time series irreversibility provides a fundamentally distinct, non-linear lens to quantify market regime changes:

  1. Relative Asynchronous Index: Measures structural asymmetry in Horizontal Visibility Graphs (HVGs) between forward and time-inverted price series.
  2. Ordinal Pattern Reversibility: Computes the Kullback-Leibler (KL) divergence between the distributions of permutation patterns in the forward versus backward series.
  3. Machine Learning Utility: Because reversibility metrics exhibit virtually zero correlation with conventional technical indicators, they serve as potent orthogonal features in meta-labeling classifiers for strategy filtering.

1. Mathematical Concept: Reversible vs. Irreversible Series — 00:16

1.1 The Reversibility Baseline

  • Sine Wave: A pure harmonic sinusoidal oscillator exhibits identical forward and backward trajectory properties. Evaluated on the Relative Asynchronous Index, a sine wave yields ≈0.003\approx 0.003, indicating near-perfect reversibility.
  • The Logistic Map (Chaotic Benchmark): Defined by the non-linear recurrence relation:

xn+1=r⋅xn(1−xn)x_{n+1} = r \cdot x_n (1 - x_n)

At parameter values driving deterministic chaos, the logistic map generates severe directional irreversibility, yielding an index value of ≈0.15\approx 0.15.

Reversible Series (e.g., Sine Wave, Pure Random Walk)
Forward:  [... 0.2 ──► 0.5 ──► 0.8 ──► 0.5 ──► 0.2 ...]
Backward: [... 0.2 ◄── 0.5 ◄── 0.8 ◄── 0.5 ◄── 0.2 ...]  (Identical dynamics)

Irreversible Series (e.g., Chaotic Dynamics, Asset Bubbles, Panics)
Forward:  Slow gradual accumulation followed by sudden flash crash
Backward: Sudden instant recovery followed by slow gradual decay (Physically implausible)

In financial time series, elevated irreversibility signals the presence of non-linear deterministic drivers, regime shifts, or herd behavior.


2. Measure 1: Relative Asynchronous Index (Visibility Graphs) — 01:19

The first method constructs a Horizontal Visibility Graph (HVG) from price bars and assesses topological asymmetry between the forward and reversed adjacency matrices.

Step 1: Construct Forward & Reverse HVGs

  1. Build the adjacency matrix for the original price array X=[x0,x1,…,xN−1]X = [x_0, x_1, \dots, x_{N-1}].
  2. Invert the price array using np.flip(X) to form XrevX_{\text{rev}}, and construct its separate adjacency matrix.

An outgoing link represents a connection from node ii to a future node jj where j>ij > i.

  • In the adjacency matrix, outgoing links correspond strictly to entries to the right of the main diagonal:

Outgoing(i)=∑j=i+1N−1Ai,j\text{Outgoing}(i) = \sum_{j = i+1}^{N-1} A_{i, j}

Counting outgoing links across all nodes produces two integer vectors:

  • LfwdL_{\text{fwd}}: Outgoing links for the forward series.
  • LrevL_{\text{rev}}: Outgoing links for the time-reversed series.

Step 3: Compute the Asynchronous Index — 02:39

The asynchronous index counts ordering discordances (inversions) between two arrays:

  1. Obtain the permutation indices π\pi that sort array AA in ascending order.
  2. Reorder array BB according to π\pi: B∗=B[π]B^* = B[\pi].
  3. Count how often pairs (i,j)(i, j) with j>ij > i violate monotonicity (Bj∗<Bi∗B^*_j < B^*_i).
  4. Normalize by the total pair combinations N(N−1)/2N(N-1)/2:

InversionCount=∑i<jI(Bj∗<Bi∗)\text{InversionCount} = \sum_{i < j} \mathbb{I}(B^*_j < B^*_i)

AI(A,B)=InversionCountN(N−1)2\text{AI}(A, B) = \frac{\text{InversionCount}}{\frac{N(N-1)}{2}}

Because AI(A,B)≠AI(B,A)\text{AI}(A, B) \ne \text{AI}(B, A), the index is directional and asymmetric.

Step 4: Symmetrizing to the Relative Asynchronous Index — 05:14

To bound the metric between [0,1][0, 1] where 0 is fully reversible:

  1. Compute both directions: v1=AI(Lfwd,Lrev)v_1 = \text{AI}(L_{\text{fwd}}, L_{\text{rev}}) and v2=AI(Lrev,Lfwd)v_2 = \text{AI}(L_{\text{rev}}, L_{\text{fwd}}).
  2. Compute the ratio: R=min⁡(v1,v2)max⁡(v1,v2)≤1R = \frac{\min(v_1, v_2)}{\max(v_1, v_2)} \le 1.
  3. Take the negative natural logarithm:

RAI=−ln⁡(R)\text{RAI} = -\ln(R)

Step 5: Rolling Window & Smoothing — 06:07

Applying RAI on daily Bitcoin with a 1-year lookback generates a volatile series. Applying a 7-period Exponential Moving Average (EMA) reveals prominent macro structural shifts:

  • 2021 Bull Run / Bubble: RAI surged to historic highs, reflecting extreme non-linear asymmetric price shocks.
  • 2022 Bear Market: RAI contracted to near-zero levels as price action decayed into grinding, reversible chop.

3. Measure 2: Ordinal Pattern Reversibility (KL Divergence) — 07:10

A computationally smoother alternative compares the probability distributions of permutation patterns (ordinal patterns) between the forward and backward series.

Step 1: Ordinal Symbolization

Given a sliding embedding dimension D=3D = 3, each 3-bar sequence [xt,xt+1,xt+2][x_t, x_{t+1}, x_{t+2}] maps to one of 3!=63! = 6 unique ordinal permutations (e.g., [0,1,2][0, 1, 2] for strictly ascending, [2,1,0][2, 1, 0] for strictly descending).

[!NOTE] An embedding dimension of D=3D = 3 is optimal for rolling windows. Larger dimensions (D≥4D \ge 4) produce 4!=244! = 24 states, demanding impractically large lookback windows (≫500\gg 500 bars) to avoid zero-count sampling errors.

Step 2: Distribution Comparison via Relative Entropy

  1. Symbolize the forward series into ordinal pattern frequencies and normalize to probability vector PP.
  2. Symbolize the time-inverted series into ordinal probability vector QQ.
  3. Compute the Kullback-Leibler (KL) Divergence (Relative Entropy):

DKL(P∥Q)=∑i=1D!P(i)ln⁡(P(i)Q(i))D_{\text{KL}}(P \parallel Q) = \sum_{i=1}^{D!} P(i) \ln\left(\frac{P(i)}{Q(i)}\right)

Step 3: Rolling Window Implementation & NaN Handling — 08:52

  • If any pattern has zero occurrences in either distribution, ln⁡(0)\ln(0) evaluates to −∞-\infty or NaN.
  • Minimum Window Constraint: Requires a window of at least 60 bars (preferably 100+).
  • Fallback Rule: If an unrepresented pattern produces NaN, forward-fill the previous valid reversibility value. If streaks of identical values appear, increase the lookback window.

Unlike the Visibility Graph metric, the Ordinal Pattern Reversibility metric is naturally smooth and requires no secondary moving average filter.


4. Algorithmic Trading Applications — 09:55

        High Irreversibility Regime                 Low Irreversibility Regime
   (Speculative Bubbles / Liquidations)          (Grinding Range / Bear Consolidation)
   ────────────────────────────────────          ────────────────────────────────────
   • Strong non-linear drift                     • Symmetric, reversible price action
   • Directional momentum dominates              • Mean-reversion systems thrive
   • Filter out mean-reversion fades             • Trend-following systems suffer whipsaws

4.1 Regime Filtering for Mean-Reversion Systems

When measured on an hourly timeframe with a 168-hour (1-week) lookback:

  • Low Reversibility Readings: Signal that price is behaving in a symmetric, mean-reverting regime. In testing on Bitcoin across 2022, mean-reversion strategies achieved their highest profit factor during sustained low-reversibility intervals.
  • High Reversibility Readings: Signal directional cascade dynamics. Mean-reversion systems should pause trading or widen stop-losses to avoid catching falling knives.

4.2 The Uncorrelated Alpha Advantage in Machine Learning — 10:12

In quantitative feature stores, most indicators share 70%–90% correlation (e.g., RSI vs. Stochastics vs. MACD).

  • Permutation reversibility and HVG asynchronous indices exhibit virtually zero correlation with standard price-based momentum or volatility indicators.
  • Adding reversibility to a meta-labeling feature matrix provides genuine orthogonal information, improving tree split quality without increasing dimensionality redundancy.

5. Key Takeaways & Practical Implementation Rules

  1. Reversibility Distinguishes Chaos from Random Walk: A pure random walk is statistically reversible, while real market panics and speculative bubbles break time symmetry.
  2. Dimension Selection (D=3D = 3): Keep ordinal pattern embedding dimension at 3 for rolling intraday calculations; larger dimensions cause zero-frequency division errors.
  3. Handle KL Divergence Zeroes: Always enforce minimum lookback lengths (≥60\ge 60 bars) and implement forward-fill fallbacks for zero probability bins.
  4. Use as a Strategy Selector: Deploy high irreversibility to enable trend/breakout strategies, and low irreversibility to gate mean-reversion execution.
  5. Orthogonal Feature Value: Reversibility metrics provide high information gain in machine learning pipelines because they do not duplicate conventional technical indicator signals.

Nguồn duy nhất: Kênh YouTube chính thức của neurotrader. Nội dung được hệ thống hóa phục vụ học tập & tra cứu — bấm các mốc thời gian trong bài để xem trực tiếp video gốc của tác giả.