Project 3 Market Regime Detection
This tool finds the calm and the wild phases of a market and shows how risk changes between them.
Already bought a plan? Sign in to open this project.
Sign inHow this project is built
The whole project consists of these six steps.
- Volatility and tails, window by windowThe first step shows that calm and wild phases exist at all, because volatility and tails change from window to window.
- Memory in the size of returnsLarge moves tend to follow large moves, and this memory is the reason why past data can reveal the phase.
- A first phase rule, fitted by likelihoodA simple rule then labels each day as calm or wild from past volatility, and a fitted distribution describes each phase.
- Links that changeWith the labels in place, the tool measures how correlation and beta shift between calm and wild days.
- Risk by phaseThe labels pay off here, because value at risk and expected shortfall are measured for each phase on its own.
- A model with two regimesA hidden Markov model comes last as a second way to label the days, and it is compared with the simple rule.
After the last step, all six parts run together in one program,
regime_tool.py. What the finished tool does
What the finished tool does
You give it a price history, and it marks every day as calm or wild, once with a simple rule and once with a hidden Markov model. It then shows how volatility, correlation and the hedge ratio change from one phase to the other.
What you get
- 01The six steps with their code Each step explains its idea, walks through its code piece by piece and names its limits.
- 02The working tool,
regime_tool.pyThe full program in one file, with its settings and experiments to try. - 03Defend it in an interview Typical follow-up questions, each with the reasoning you need to answer it.
- 04Use it with real data Which data the tool needs, how to load it and what to change in the code.