WorkOctober 19, 2025

Julia Mandelbrot: a market regime analysis toolkit

Financial markets do not behave the same way all the time. A strategy that works in a quiet uptrend can fail badly in a volatile reversal, and the difference between those states is not always obvious while you are inside one. The usual tools either assume returns are normally distributed — they are not — or they reduce the market to a single binary, bull or bear, that hides most of what matters. I wanted a way to characterise the current state of a series along more than one axis, with an honest measure of how confident that characterisation is. The toolkit classifies a series into six regimes — bull, bear, and sideways, each either quiet or volatile — from a set of complementary indicators:
  • Trend and volatility analysis to place the series on the two primary axes.
  • Hurst exponent and fractal features to distinguish persistent trending behaviour from mean reversion. This is where the name comes from: Julia and Mandelbrot both studied self-similarity, and market behaviour repeats across timeframes in a way that bell curves do not capture.
  • Tail-risk diagnostics — CVaR, VaR, Hill tail index, kurtosis, and drawdown — because the interesting failures live in the tails.
  • Fuzzy membership rather than hard cutoffs, so a series sitting on the boundary between two regimes is reported as genuinely ambiguous instead of being forced into one.
  • Markov transition matrices to measure how regimes persist and what they tend to become.
It ships as a proper Python package with a CLI that auto-detects the data source, a warmup and valid-signal column set so startup rows can be filtered cleanly, and visualisations of price alongside indicator and regime evolution. The library produces indicator columns. It does not define trading entries, exits, position sizing, or risk limits, and it makes no claim to predict returns. That boundary is intentional: regime classification is an input to a decision process, not the decision itself, and tools that blur the two tend to be trusted more than they deserve. The project is open source and actively maintained, with a test suite and a documented CLI. The forward-returns analysis is research diagnostics — a way to check how regimes actually behaved historically, rather than a backtest dressed up as a result. View the source on GitHub

Related projects

Finding intervention targets in organic waste behaviour

Clustering and classification on survey data about organic waste disposal, identifying a specific subgroup where intervention would have measurable effect.

Automating lead research with the Google Maps API

A Python pipeline that replaced manual prospect research, resolving business addresses and enriching them with contact and rating data at scale.