Sponsored by

How Jennifer Aniston’s LolaVie brand grew sales 40% with CTV ads

The DTC beauty category is crowded. To break through, Jennifer Aniston’s brand LolaVie, worked with Roku Ads Manager to easily set up, test, and optimize CTV ad creatives. The campaign helped drive a big lift in sales and customer growth, helping LolaVie break through in the crowded beauty category.

For readers who want to go beyond reading.

7-day free trial of the Elite Quant Plan
— open this week only, closes March 26

No charge upfront. Cancel anytime.
No emails if you leave.

What you unlock immediately:

  • Run every strategy from day one — full code
    from every article including today's notebook

  • Private GitHub repos you can fork and deploy
    in minutes

  • 3–5 premium deep dives per month — strategies
    I don't publish publicly

  • 2 × 1-on-1 calls — I look at your specific
    setup and tell you exactly what to fix

  • One custom bot built or fixed for you
    personally — your idea, my code

This is not a rolling deadline. March 26 is the
last day to claim this.

② One strategy in this book returned 2.3× the S&P 500 on a risk-adjusted basis over 5 years.

Fully coded in Python. Yours to run today.

The 2026 Playbook — 30+ backtested strategies,
full code included, ready to deploy.

20% off until Friday. Use SPRING2026 at checkout.

$79 → $63.20 · Expires March 21.

→ Grab it before Friday

Premium Members – Your Full Notebook Is Ready

The complete Google Colab notebook from today’s article (with live data, full Hidden Markov Model, interactive charts, statistics, and one-click CSV export) is waiting for you.

Preview of what you’ll get:

Inside:

  • Auto-installs all dependencies — one click, no setup needed

  • Live ASML price data pulled directly from Yahoo Finance (fully configurable for any ticker)

  • K-Reversal oscillator calculated from scratch with adjustable period, buy and sell thresholds

  • 4-panel dark-theme chart — candlestick price, K indicator, signal volatility, and a metrics dashboard in one figure

  • Actionable crossover signals — buy/sell markers triggered when K exits oversold/overbought zones, not just enters them (fewer false positives)

  • Instant performance summary — total return, Sharpe ratio, max drawdown and signal count printed automatically on every run

Free readers – you already got the full breakdown and visuals in the article. Paid members – you get the actual tool.

Not upgraded yet? Fix that in 10 seconds here👇

Daily algorithmic trading signals, market insights, and code-ready strategies to sharpen your edge.

Google Collab Notebook With Full Code Is Available In the End Of The Article Behind The Paywall 👇 (For Paid Subs Only)

1. Introduction

Ever tried catching the rhythm of the stock market? If you have, you’d know trends aren’t just about rising and falling arrows on a graph. They’re the pulse of market sentiment, the stories of gains and losses. In such environment, navigating the stock market can be likened to sailing turbulent waters, where understanding currents — or in this case, trends — can be a game changer. But how can we transition from a qualitative understanding to a quantitative measure of these trends? Here’s where the Hurst exponent enters the spotlight.

A concept that’s often reserved for scholarly articles and niche financial discussions, the Hurst exponent offers a robust measure of a stock’s propensity to trend or mean-revert. While typically estimated as a point-in-time metric, what if we could gauge the Hurst exponent on a rolling basis?Using Python, we can implement the Rolling Hurst Exponent to analyze, visualize, and eventually leverage market trends in our decision-making process.

Facts. Without Hyperbole. In One Daily Tech Briefing

Get the AI & tech news that actually matters and stay ahead of updates with one clear, five-minute newsletter.

Forward Future is read by builders, operators, and leaders from NVIDIA, Microsoft, and Salesforce who want signal over noise and context over headlines.

And you get it all for free, every day.

2. Basic of the Hurst Exponent

The Hurst Exponent, denoted as H, is a statistical measure that gives us a window into the behavior of time series data. Whether it’s the price of a stock, the flow rate of a river, or even internet traffic, H seeks to determine the nature of its behavior. Put simply, the interpretation of the Hurst Exponent is as follows

  • If H=0.5, the process is akin to a random walk, like the flipping of a coin.

  • If H<0.5, it suggests a series that tends to mean-revert. In the context of stocks, this might hint at an oscillatory behavior where if the stock price rises, it’s likely to fall back to its mean and vice-versa.

  • If H>0.5, it indicates a trending series. This would mean that if a stock price rises, it’s likely to continue on that upward trajectory.

Hurst Exponent Formula

Where:

  • R(t) is the range of cumulative sum deviations. The broad idea behind R(t) is to determine how volatile a time series is

  • S(t) is the standard deviation of the series. It represents the standard deviation of the series, capturing its average dispersion from the mean.

The Rolling Hurst Exponent:

Traditionally, the Hurst exponent offers a snapshot, a point-in-time insight. But markets are dynamic, evolving with news, policies, and global events. Thus, a rolling computation, where the Hurst exponent is continually recalculated over a moving window, offers fresher, more timely insights. It’s akin to watching a movie frame-by-frame, where each frame offers a unique perspective.

The Link with Fractal Dimension:

The fractal dimension is another fascinating concept, rooted in the idea of measuring the ‘roughness’ or complexity of a series. It’s intrinsically tied to the Hurst exponent and can be determined as:

Fractal Dimension Formula

Where D is the fractal dimension. A higher D indicates a more complex, irregular series, whereas a value close to 1 suggests a smoother series.

Contrasting Temporal Patterns: The left plot showcases a relatively smooth time series characterized by a lower fractal dimension, hinting at less complexity. Conversely, the right plot depicts a volatile series with higher complexity, evident from its erratic behavior and indicative of a higher fractal dimension.

A Fractal dimension close to 1 indicates the time series is relatively smooth and simple, suggesting that it can be easily modeled using conventional time series methods. Fractal dimension close to 2 on the contrary indicates that the time series is very rough and complex, suggesting that it has a higher degree of irregularity and may be challenging to model using conventional methods. Just note that the interpretation might vary depending on the context and the financial instrument being analyzed.

3. Rolling Hurst Exponent Python Implementation

Given the inherent dynamism of the stock market, assessing the Hurst Exponent at a single point in time might not provide a comprehensive picture. Instead, evaluating it on a rolling basis offers a frame-by-frame analysis of how a stock’s behavior evolves over time. The same goes for the fractal dimension.

The computation of both the Hurst exponent and the fractal dimension in a rolling fashion demands a blend of time series manipulation and statistical techniques. Thankfully, Python’s vast libraries make this task relatively straightforward.

Feeling off lately? It could be your hormones.

Allara helps women understand the root cause of their hormonal or metabolic symptoms with a comprehensive care team that combines expert medical and nutrition guidance. Whether you're managing PCOS, fertility challenges, perimenopause, thyroid conditions, or unexplained symptoms, you'll get a personalized care plan backed by advanced diagnostic testing and ongoing support. This isn't about quick fixes. It's about getting clarity and feeling like yourself again, with care that's accessible virtually and covered by insurance.

Essential Libraries & Data Acquisition

We commence by importing the necessary libraries:

  • numpy and pandas: Fundamental for numerical and data frame operations.

  • yfinance: Enables us to fetch stock data directly from Yahoo Finance.

  • matplotlib: Our go-to tool for plotting and visualizing data.

The stock data is fetched for the ticker symbol “ASML.AS” within a specific date range.

import numpy as np
import pandas as pd
import yfinance as yf
import matplotlib.pyplot as plt

symbol = "ASML.AS"
start_date = "2018-01-01"
end_date = "2023-12-31"
df = yf.download(symbol, start=start_date, end=end_date)

Hurst and Fractal Dimension Calculations

The heart of our script is the hurst_fd function, which computes both the Hurst Exponent and Fractal Dimension using the log returns of a given price series. The function uses a resampling approach for more robust estimates.

We also have rolling_hurst and rolling_fractal_dimension functions that employ hurst_fd to calculate these metrics on a rolling basis across our dataset.

def hurst_fd(price_series, min_window=10, max_window=100, num_windows=20, num_samples=100):
    log_returns = np.diff(np.log(price_series))
    window_sizes = np.linspace(min_window, max_window, num_windows, dtype=int)
    R_S = []

    for w in window_sizes:
        R, S = [], []
        for _ in range(num_samples):
            start = np.random.randint(0, len(log_returns) - w)
            seq = log_returns[start:start + w]
            R.append(np.max(seq) - np.min(seq))
            S.append(np.std(seq))

        R_S.append(np.mean(R) / np.mean(S))

    log_window_sizes = np.log(window_sizes)
    log_R_S = np.log(R_S)
    coeffs = np.polyfit(log_window_sizes, log_R_S, 1)
    hurst_exponent = coeffs[0]
    fractal_dimension = 2 - hurst_exponent

    return hurst_exponent, fractal_dimension

def rolling_hurst(price_series, window, min_window=10, max_window=100, num_windows=20, num_samples=100):
    return price_series.rolling(window=window).apply(lambda x: hurst_fd(x, min_window, max_window, num_windows, num_samples)[0], raw=True)

def rolling_fractal_dimension(price_series, window, min_window=10, max_window=100, num_windows=20, num_samples=100):
    return price_series.rolling(window=window).apply(lambda x: hurst_fd(x, min_window, max_window, num_windows, num_samples)[1], raw=True)

Visualization & Insights

With our metrics in hand, the next step is visualization. We aim to render three plots:

  1. Stock Price & SMA: The stock price plotted alongside its Simple Moving Average and mean price.

  2. Rolling Hurst Exponent: Offers a dynamic view of the Hurst exponent over time.

  3. Rolling Fractal Dimension: Reveals the changing fractal nature of the stock price.

This series of plots paints a holistic picture, illustrating the relationship between price movements, market trends, and fractal characteristics.

Putting it all together, we get:

# Essential Libraries Importimport numpy as npimport pandas as pdimport yfinance as yfimport matplotlib.pyplot as pltfrom datetime import datetime, timedelta
# Function to calculate Hurst Exponent and Fractal Dimensiondef hurst_fd(price_series, min_window=10, max_window=100, num_windows=20, num_samples=100):
    # Calculate logarithmic returns
    log_returns = np.diff(np.log(price_series))
    
    # Define window sizes for the resampling approach
    window_sizes = np.linspace(min_window, max_window, num_windows, dtype=int)
    R_S = []

    # For each window size, calculate R/S values
    for w in window_sizes:
        R, S = [], []
        
        # Resample multiple sequences for a more robust estimate
        for _ in range(num_samples):
            start = np.random.randint(0, len(log_returns) - w)
            seq = log_returns[start:start + w]
            R.append(np.max(seq) - np.min(seq))
            S.append(np.std(seq))

        R_S.append(np.mean(R) / np.mean(S))

    # Calculate the slope (Hurst Exponent) in a log-log plot
    log_window_sizes = np.log(window_sizes)
    log_R_S = np.log(R_S)
    coeffs = np.polyfit(log_window_sizes, log_R_S, 1)

    # Extract Hurst Exponent and derive Fractal Dimension
    hurst_exponent = coeffs[0]
    fractal_dimension = 2 - hurst_exponent

    return hurst_exponent, fractal_dimension
# Function to calculate rolling Hurst Exponentdef rolling_hurst(price_series, window, min_window=10, max_window=100, num_windows=20, num_samples=100):
    return price_series.rolling(window=window).apply(lambda x: hurst_fd(x, min_window, max_window, num_windows, num_samples)[0], raw=True)
# Function to calculate rolling Fractal Dimensiondef rolling_fractal_dimension(price_series, window, min_window=10, max_window=100, num_windows=20, num_samples=100):
    return price_series.rolling(window=window).apply(lambda x: hurst_fd(x, min_window, max_window, num_windows, num_samples)[1], raw=True)
# Define symbol and fetch its historical data
symbol = "ASML.AS"
start_date = "2018-01-01"
end_date = "2026-12-27"
df = yf.download(symbol, start=start_date, end=end_date)
# Calculate rolling Hurst Exponent and Fractal Dimension for the stock data
rolling_window = 120
df['hurst_exponent'] = rolling_hurst(df['Close'], rolling_window)
df['fractal_dimension'] = rolling_fractal_dimension(df['Close'], rolling_window)
df.dropna(inplace=True)
# Calculate 30-day Simple Moving Average for visualization purposes
sma_window = 30
df['sma'] = df['Close'].rolling(window=sma_window).mean()
# Calculate mean price for visualization purposes
mean_price = df['Close'].mean()

Visual representation of ASML.AS stock data from 2018 to 2023, showcasing its price movement, the rolling Hurst Exponent, and the rolling Fractal Dimension. The price graph also overlays a 30-day simple moving average for better trend clarity, highlighting the stock’s deviations from its mean price.

Understanding the Results:

Visualizing the stock price alongside its rolling Hurst Exponent and Fractal Dimension provides valuable insights:

  • Rolling Hurst Exponent: A value close to 0.5 suggests a random walk (Brownian motion). Values below 0.5 indicate a series that tends to mean revert, while those above 0.5 signify a trending series.

  • Rolling Fractal Dimension: A lower value suggests the series is more straightforward or “smooth”, while higher values point to increased complexity or “roughness”.

Trading Strategy (Optional):

Based on insights drawn from the Hurst exponent and fractal dimension, devise trading signals. For instance:

  • Buy when the Hurst exponent crosses above 0.5, indicating a trending behavior, i.e. the current stock price will persist.

  • Sell/short when the Hurst exponent drops below 0.5, hinting at potential mean-reversion.

Remember, these signals are merely starting points. Refinement based on other technical indicators, fundamental data, or macroeconomic signals would be essential for a holistic strategy.

4. Further Application Insights

The rolling Hurst Exponent and Fractal Dimension can be leveraged in various financial and trading contexts. Here are some potential applications and insights:

Trend Detection and Strength

  • Trending Markets: If the rolling Hurst Exponent consistently stays above 0.5 for a prolonged period, it may indicate a strong trending market. This can be a cue for trend-following strategies, where traders may consider entering long in an upward trend or short in a downward one.

  • Mean-Reverting Markets: A Hurst Exponent value consistently below 0.5 signifies potential mean-reverting behavior. In these scenarios, pairs trading or statistical arbitrage strategies can be explored.

Volatility Analysis

  • The Fractal Dimension can serve as an indicator of market volatility. A higher fractal dimension suggests a more complex and volatile market, potentially calling for caution or different risk management techniques.

Portfolio Diversification

  • Assessing the Hurst Exponent of various assets can aid in portfolio construction. For instance, combining assets that exhibit different behaviors (trending vs. mean-reverting) can help in achieving better portfolio diversification.

Risk Management

  • Recognizing phases when the market is transitioning from a trending to a mean-reverting state (or vice-versa) can be invaluable for adjusting risk levels. This could involve reducing position sizes or tightening stop losses.

5. Limitations and Considerations

While the Hurst Exponent and Fractal Dimension provide valuable insights, they aren’t without limitations:

  1. Lagging Indicators: Like many technical tools, they tend to be lagging indicators. By the time a strong trend is identified, it may be nearing its end.

  2. Signal Noise: Short-term fluctuations can introduce noise into the metrics, leading to potential misinterpretations.

  3. Market Anomalies: Unprecedented events or black swan incidents can drastically change the behavior of financial time series, making prior analyses less relevant.

6. Conclusion

The world of financial markets is intricate and ever-evolving, and tools like the Hurst Exponent and Fractal Dimension offer unique insights into market dynamics. By observing these metrics on a rolling basis, traders can get a better grasp of how market trends evolve and change over time. The use of the Hurst Exponent and Fractal Dimension should be complemented with a holistic understanding of the market and other analytic tools.

logo

Subscribe to our premium content to read the rest.

Become a paying subscriber to get access to this post and other subscriber-only content.

Upgrade

Keep Reading