Price dynamics can alternate between chaotic and orderly phases. When a system’s largest Lyapunov exponent drops and the correlation dimension compresses, trajectories become more predictable—often coinciding with trendable structure. Pairing this with a simple trend filter and Hurst exponent provides a compact framework to trade regime transitions rather than raw noise.
def next(self):
if self.order is not None:
return
# accumulate rolling returns
if not np.isnan(self.returns[0]):
self.returns_history.append(self.returns[0])
if len(self.returns_history) > self.p.lookback * 2:
self.returns_history = self.returns_history[-self.p.lookback * 2:]
# need enough history
if len(self.returns_history) < self.p.lookback:
return
# compute chaos metrics on the latest window
recent = np.array(self.returns_history[-self.p.lookback:])
lyap, corr_dim, hurst = self.analyze_strange_attractor(recent)
# track previous regime state
prev_lyap = self.lyapunov_exponent
self.lyapunov_exponent = lyap
self.correlation_dimension = corr_dim
self.hurst_exponent = hurst
# trade only on transitions into "order" with trend alignment
long_setup = (lyap < self.p.lyap_threshold and prev_lyap >= self.p.lyap_threshold
and corr_dim < self.p.corr_dim_threshold
and self.data.close[0] > self.trend_ma[0])
short_setup = (lyap < self.p.lyap_threshold and prev_lyap >= self.p.lyap_threshold
and corr_dim < self.p.corr_dim_threshold
and self.data.close[0] < self.trend_ma[0])
# exits on renewed chaos
chaos_exit = (lyap > self.p.lyap_threshold * 2 and self.position)
# alternative thrust: Hurst persistence gates with trend
hurst_long = (hurst > 0.6 and self.data.close[0] > self.trend_ma[0] and not self.position)
hurst_short = (hurst < 0.4 and self.data.close[0] < self.trend_ma[0] and not self.position)
# execute
if long_setup:
if self.position.size < 0 and self.stop_order: self.cancel(self.stop_order)
self.order = self.close() if self.position.size < 0 else self.buy()
elif short_setup:
if self.position.size > 0 and self.stop_order: self.cancel(self.stop_order)
self.order = self.close() if self.position.size > 0 else self.sell()
elif chaos_exit:
if self.stop_order: self.cancel(self.stop_order)
self.order = self.close()
elif hurst_long:
self.order = self.buy()
elif hurst_short:
self.order = self.sell()lyap_threshold to demand cleaner order and fewer
trades in choppy assets.corr_dim_threshold to isolate simpler
attractors; loosen to participate more.trend_period to match the instrument’s dominant
cycle.strategy = load_strategy("ChaosStrategy")
ticker = "DOGE-USD"
start = "2018-01-01"
end = "2025-01-01"
window_months = 12
df = run_rolling_backtest(ticker=ticker, start=start, end=end, window_months=window_months)Interpretation: The chaos–order regime framework achieved high total returns with a strong win rate and modest drawdowns relative to crypto’s inherent volatility. The strategy excelled in strong trending regimes (175% peak window gain) but also showed periods of muted performance when regime shifts were less distinct. This suggests the model’s edge is concentrated in high-persistence structural transitions—exactly where chaos theory predicts the largest predictability boost.