Market Regime Trading Strategies: Detection, HMM & Allocation
₹8223 /-₹35750/-
77% OFF
Get for ₹6167 with Course Bundle
- Live Trading
- Learning Track
- Prerequisites
- Syllabus
- About author
- Faqs
What You Will Learn
- Explain why a strategy that backtests well can disappoint live, and define a market regime by the trading decision it changes.
- Label calm and stressed markets with the 200-day rule and volatility, and trade each label between equities and gold, gross and net of costs.
- Fit Markov switching, hidden Markov and change point models, keep look-ahead out with filtered estimates, and score each against the rule.
- Turn a regime into weights across equities, gold, Treasuries and cash, and backtest it net of costs against buy and hold and a 60/40 portfolio.
- Check data and signals before each rebalance, fall back to a set mix when a check fails, and know why reusable code belongs outside the notebook.

Skills Covered
Detecting Regimes
- 200-Day and Volatility Labels
- Markov Switching Models
- Hidden Markov Models from Scratch
- Change Point Detection
Testing Without Look-Ahead
- Avoiding Look-Ahead Bias
- Filtered Versus Smoothed Estimates
- Measuring Detection Lag
- Backtesting Net of Costs
Allocating and Running It
- Regime-Based Asset Allocation
- Benchmarking Against 60/40
- Checks Before Each Rebalance
- Fallback Rules
learning track 8
This course is a part of the Learning Track: Advanced Algorithmic Trading Strategies
Course Fees
Full Learning Track
These courses are specially curated to help you with end-to-end learning of the subject.
Course Features
- Community
Faculty Support on Community
Interactive Coding ExercisesInteractive Coding Practice
Capstone ProjectCapstone Project Using Real Market Data
Trade & Learn TogetherTrade and Learn Together
- Get Certified
Get Certified
Prerequisites
- Working Python at the level of Python for Trading: Basic, enough to read and edit code that runs.
- Familiarity with returns, drawdowns and backtests. A strategy course on momentum, mean reversion or factors helps but isn't required.
- The notebooks run in your browser with nothing to install. Running them on your own machine is optional.
Syllabus
- Introduction to the CourseMeet John, whose momentum strategy looked great in its backtest and then fell flat live. See how the course is laid out, what you need on day one, and what can wait.
One Strategy, Different Markets
A strategy can look great in a backtest and still let you down live. Follow John's momentum strategy year by year, see what's in the data every notebook uses, and find the stretches where one strategy led and the other lagged.Part A Overview: The Problem2m 15sJohn's Momentum Strategy, and What Happened Live2m 40sOne Average, Many Markets3mA Fast Fall and a Fast Recovery3mThe Data Behind Every Notebook2m 27sMomentum and Mean Reversion on the S&P 50030mExercise: Find the Periods Where They Diverge45mSolution: Find the Periods Where They Diverge15mTwo Persuasive Numbers3mWhat a Regime Is, and the Kinds There Are
Learn what a market regime is, and why you can only infer it, never observe it. See how trend, volatility, macro and correlation regimes each change a different trading decision, and why gold behaves differently from stocks.What a Regime Is3m 13sWhich Stretch Is Calm3mThe Monthly Direction Label3mThe Kinds of Regime, and Why Gold Behaves Differently3m 18sWhich Family Fits the Decision3mWhich Kind Changes Which Decision3mRegime Indicators and the Equity-Gold Correlation by State35mExercise: Where the Families Disagree45mSolution: Where the Families Disagree15mA Gap That Held in Both Halves3m- Twenty-Five Years of RegimesWalk through ten big US market moments since 2000 and see how each fall unfolded. Check which strategy held up in each, and when gold failed as a hedge, which matters once you build an allocation.What Happened in Real Market Falls2m 55sThree Stretches, Three VIX Averages3mGold in Two Sell-Offs3mAnnotated History With Episode Statistics30mExercise: Which Strategy Would Have Held Up45mSolution: Which Strategy Would Have Held Up15m
- Part A Review: Regimes, Defined and Seen in HistoryRecap why backtests disappoint and what a regime is, with further reading and answers to common questions. An assessment then checks you can apply it before you start building.Part A Summary, and John's Next Question1m 54sAdditional Reading: Part A5mFrequently Asked Questions: Part A5mAssessment Test: Part A12m
Your First Regime Strategy: The 200-Day Rule
This simple rule is the benchmark every later model must beat. Turn it into a calm or stressed label, trade it between equities and gold, and measure what whipsaw and the lookback choice cost you.Part B Overview: The First Strategies2m 51sThe Rule, and the Strategy It Gives You3m 13sA Mid-Month Break Below the Line3mWhat Faber's Evidence Covers3mA Rough Rally3mTwo Rules, One Day3mLabel and Backtest, Gross and Net25mA Lead Over Twenty-Two Years3mGold or T-Bills, Monthly or Daily25mWhipsaw, and the Standing Challenge to the Rule3m 22sThe Whipsaw Bill3mA Longer Backtest3mBehind in Half the Years3mThree Defences Against Whipsaw3mLookback Sweep25mExercise: Add a Confirmation Buffer35mSolution: Add a Confirmation Buffer15mThe Sweep's Winners3mVolatility Regimes, Traded
How rough the ride is matters as much as direction. Label the market with realised volatility and the VIX, trade each label, and see what a slow, calm decline does to a volatility rule.Volatility as a State Variable3m 31sRealised Against Implied3mVolatility Labels Compared, and Traded35mExercise: Classify a Calm Decline40mSolution: Classify a Calm Decline15mWhere Volatility Adds Information3m- Part B Review: The 200-Day Rule and Volatility LabelsRecap the first two regime strategies and what drove their results, with further reading and answers to common questions. An assessment checks you can read their results critically before models arrive.Part B Summary, and John's Next Question3m 12sAdditional Reading: Part B5mFrequently Asked Questions: Part B5mAssessment Test: Part B12m
Markov Switching Models, Traded
A rule gives a yes or no; a model gives a probability. Fit a two-state Markov switching model, read its transition matrix as how long each regime tends to last, and trade its label against the 200-day rule.Part C Overview: Models That Give a Probability3mFrom a Rule to a Probability3m 16sWell Above the Line3mThe Transition Matrix, Persistence and Expected Duration3m 11sEighteen Days on Average3mFit, Interpret, and Read the Transition Matrix, Part 1: Fit and Read the States25mFit, Interpret, and Read the Transition Matrix, Part 2: The Transition Matrix20mExercise: Convert Persistence to Expected Days1hSolution: Convert Persistence to Expected Days15mA Refit From a New Start3mTrade It, Part 1: Trade the Markov Switching Label25mTrade It, Part 2: Test the Lead Over the Rule30mBefore You Switch From the Rule3mDon't Let the Future In
This is where many good-looking backtests go wrong. Find how future data slips in through smoothed estimates and full-history fits, rerun the trade using only what was known each day, and measure how late each label arrives.How the Future Gets Into a Rule3m 10sCan You Trust This Label?3mRepair a Leaking Label, Part 1: Find and Prove the Leaks25mRepair a Leaking Label, Part 2: Fix It and Count the Cost30mSmoothed Estimates: What John's Model Used3m 21sFiltered Against Smoothed3mRerun the Markov Switching Trade With Filtered Probabilities, Part 125mRerun the Markov Switching Trade With Filtered Probabilities, Part 225mDetection Lag3m 18sNever a Day Late3mMeasure the Detection Lag20mExercise: Audit a Notebook for Smoothed States55mSolution: Audit a Notebook for Smoothed States15mWhat Could Have Been Known3mHidden Markov Models from Scratch
Building the model yourself shows exactly where it can mislead you. Write a two-state hidden Markov model in numpy, fit it with EM, see why its state labels can swap, and trade it using only past data.Hidden States and the Forward Pass3m 21sToday's Filtered Chance3mThe From-Scratch HMM, Fitted by EM, Part 1: Forward and Backward Passes20mThe From-Scratch HMM, Fitted by EM, Part 2: Fit by EM25mDeep Dive: The HMM Worked by Hand (Optional)5mLabel Permutation, and Why Live Systems Invert3m 17sThis Month's Refit3mGaussian Mixture as the Non-Sequential Contrast45mExercise: Map States to Market Conditions55mSolution: Map States to Market Conditions15mTrade It, Filtered, Part 1: Refit Without the Future25mTrade It, Filtered, Part 2: Trade It, Then Test It30mSmoothing Inside EM3m- Change Point Detection, TradedSome methods look for the moment behaviour shifts, rather than fixed states. Try CUSUM, binary segmentation and a Bayesian online detector, tune them against false alarms, and trade what they find.Detecting Shifts Without Fixing States3m 19sChoosing a Detector for the Switch3mThree Detectors on One Series, Part 1: CUSUM and Binary Segmentation30mThree Detectors on One Series, Part 2: BOCPD25mDeep Dive: Change Points Worked by Hand (Optional)5mExercise: Tune Sensitivity Against False Positives1h 10mSolution: Tune Sensitivity Against False Positives15mTrade It, Part 1: Build and Trade the Label20mTrade It, Part 2: Find Where It Went Wrong20mAlarms Against States3m
- Which One Earned Its PlaceMore complex isn't automatically better. Score every detector against the 200-day rule on one scorecard, net of costs, and decide plainly whether each one paid for its extra complexity.Scoring Without Ground Truth3m 14sScoring a New Method3mEvery Strategy on One Scorecard, Part 1: Build and Read the Card25mEvery Strategy on One Scorecard, Part 2: Lag and the Decision Day20mDeploy Both Strategies by Regime30mExercise: Decide Whether the Complexity Paid1h 10mSolution: Decide Whether the Complexity Paid15mA Lead at the Same Worst Fall3m
- Part C Review: Probabilities, Look-Ahead and the ScorecardRecap the models, the look-ahead checks and the scorecard, with further reading and answers to common questions. An assessment then tests whether you can spot a leak and weigh a result.Part C Summary, and John's Next Question3m 23sAdditional Reading: Part C5mFrequently Asked Questions: Part C5mAssessment Test: Part C12m
- Four Assets and the Allocation RuleKnowing the regime only helps if you know what to hold in it. Add Treasuries and cash to equities and gold, see how each behaves by regime, and write a weight mix for every regime before any test, so the test stays fair.Part D Overview: From Two Assets to Four3m 18sFour Assets and What Each One Does3m 1sOne Line per Asset3mAsset Behaviour and Correlation by Regime25mFrom Label to Weights, Built From Reasoning3m 27sChoosing the Mapping3mWeight History and Rebalance Logic25mExercise: State Your Mapping Before You Test It50mSolution: State Your Mapping Before You Test It15mA Two-Month Minimum Hold3m
- Backtesting Net of CostsAn allocation that looks good before costs can disappoint after them. Backtest it against buy and hold and a 60/40 portfolio, charge costs on turnover, and find the cost level at which it stops adding value.Testing the Overlay Properly3m 17sChanging a Test After a Run3mThe Cost Standard, Applied to Turnover3m 2sPricing One Switch3mWhy Flat Costs Mislead for Regime Strategies5mChecking a Colleague's Drag3mBuild the Four-Asset Backtest30mBacktest Against Buy and Hold and 60/4035mCost Sensitivity and the Break-Even Level30mExercise: Sanity Check Your Turnover Drag25mSolution: Sanity Check Your Turnover Drag15mThe Fair Benchmark Claim3m
- Part D Review: Allocation and CostsRecap the four-asset rule and what its test showed, with further reading and answers to common questions. An assessment checks the results make sense to you before you run it each month.Part D Summary, and John's Next Question3m 25sAdditional Reading: Part D5mFrequently Asked Questions: Part D5mAssessment Test: Part D12m
- From Notebook to Running SystemA strategy run by hand each month is easy to get wrong. Build a monitoring view and an end-to-end run that checks the data first, holds a fallback mix when a check fails and logs why, then see why reusable code belongs outside the notebook.Part E Overview: Running It2m 59sWhat to Check Before Each Rebalance2m 58sTonight's Four Lines3mThe Rebalance-Night Dashboard25mData Gates, Fallback and the Run25mA Fallback on Month End3mWhy Notebooks Do Not Belong in Production3m 4sA Function That Passed Its Test3m
- Part E Review: Monitoring and Production DisciplineRecap what to check before each rebalance and how the system behaves when data fails. Further reading, answers to common questions and a final assessment close the last part.Part E Summary, and John's Next Question3m 5sAdditional Reading: Part E5mFrequently Asked Questions: Part E5mAssessment Test: Part E12m
- Capstone ProjectPut the whole process to work on a detector of your own. Fix its allocation before testing, backtest it net of costs, and write up what you found, whether it beats the rule or not. It's practice for you, checked against the rubric.The Capstone Question3m 20sGetting Started5mProblem Statement5mCapstone Notebook2hCapstone Model Solution15m
Run Code Locally on Your Machine
For anyone who wants to run the course on their own computer. Set up your environment, install Python 3.11 and the pinned libraries, run the course repository, and fix the setup problems learners hit most often.Setting Up Your Environment5mInstalling Python and the Dependencies5mCommon Setup Problems5mUsing VS Code with an AI Assistant (optional)10mValidate Against the Reference Dataset25mThree Columns That Fail3m- Downloadable ResourcesEverything you need to work offline, in one place. Download the course repository, the reference dataset and every notebook as a single zip file.Course Download: Code, Data and Notebooks5mCourse Download2m
- Summary of the CourseStep back and see what you can now do: test a regime idea with no future data and after costs. Look at what John built and what you built, what the course didn't cover, and which courses take each thread further.What John Built, and What You Built3m 18sCourse Summary and Next Steps5m
Registered Successfully!
You will receive webinar joining details on your registered email
Would you like to start learning immediately?
about author

Why quantra®?
- More in Less Time
Gain more in less time
- Expert Faculty
Get taught by practitioners
- Self-paced
Learn at your own pace
- Data & Strategy Models
Get data & strategy models to practice on your own
Faqs
- When will I have access to the course content, including videos and strategies?
You will gain access to the entire course content including videos and strategies, as soon as you complete the payment and successfully enroll in the course.
- Will I get a certificate at the completion of the course?
Yes, you will be awarded with a certification from QuantInsti after successfully completing the online learning units.
- Are there any webinars, live or classroom sessions available in the course?
No, there are no live or classroom sessions in the course. You can ask your queries on community and get responses from fellow learners and faculty members.
- Is there any support available after I purchase the course?
Yes, you can ask your queries related to the course on the community: https://quantra.quantinsti.com/community
- What are the system requirements to do this course?
Fast-speed internet connection and a browser application are required for this course. For best experience, use Chrome.
- What is the admission criteria?
There is no admission criterion. You are recommended to go through the prerequisites section and be aware of skill sets gained and required to learn most from the course.
- Is there a refund available?
We respect your time, and hence, we offer concise but effective short-term courses created under professional guidance. We try to offer the most value within the shortest time. There are a few courses on Quantra which are free of cost. Please check the price of the course before enrolling in it. Once a purchase is made, we offer complete course content. For paid courses, we follow a 'no refund' policy.
- Is the course downloadable?
Some of the course material is downloadable such as Python notebooks with strategy codes. We also guide you how to use these codes on your own system to practice further.
- Can the python strategies provided in the course be immediately used for trading?
We focus on teaching these quantitative and machine learning techniques and how learners can use them for developing their own strategies. You may or may not be able to directly use them in your own system. Please do note that we are not advising or offering any trading/investment services. The strategies are used for learning & understanding purposes and we don't take any responsibility for the performance or any profit or losses that using these techniques results in.
- I want to develop my own algorithmic trading strategy. Can I use a Quantra course notebook for the same?
Quantra environment is a zero-installation solution to get beginners to start off with coding in Python. While learning you won't have to download or install anything! However, if you wish to later implement the learning on your system, you can definitely do that. All the notebooks in the Quantra portal are available for download at the end of each course and they can be run in the local system just the same as they run in the portal. The user can modify/tweak/rework all such code files as per his need. We encourage you to implement different concepts learnt from different learning tracks into your trading strategy to make it more suited to the real-world scenario.
- If I plug in the Quantra code to my trading system, am I sure to make money?
No. We provide you guidance on how to create strategy using different techniques and indicators, but no strategy is plug and play. A lot of effort is required to backtest any strategy, after which we fine-tune the strategy parameters and see the performance on paper trading before we finally implement the live execution of trades.
- What does "lifetime access" mean?
Lifetime access means that once you enroll in the course, you will have unlimited access to all course materials, including videos, resources, readings, and other learning materials for as long as the course remains available online. There are no time limits or expiration dates on your access, allowing you to learn at your own pace and revisit the content whenever you need it, even after you've completed the course. It's important to note that "lifetime" refers to the lifetime of the course itself—if the platform or course is discontinued for any reason, we will inform you in advance. This will allow you enough time to download or access any course materials you need for future use.
- What should I know before I start?
The course assumes the Python taught in Python for Trading: Basic, a free Quantra course. A strategy course on momentum, mean reversion or factors helps, but it isn't required, because the course explains its two teaching strategies step by step early on.
- Will the strategies in this course make money?
The course makes no such promise. Every result is historical, set against a benchmark over the same dates, and shown before and after trading costs. The strategies are teaching examples, and nothing in the course is financial advice.
- Does each new model beat the one before it?
Not necessarily. Models come in the order of what each one adds, not by returns. Where a model doesn't beat the simple 200-day rule, the course says so plainly and treats it as a finding.
- What will I be able to do by the end?
You'll label the regime with rules and with models that give a probability, trade each label, and score every method against the rule. Then you'll test a four-asset allocation net of costs and write the checks a monthly run makes before each rebalance, with a fallback mix when the data fails one. The capstone has you build and test a detector of your own.
- Which markets and data does the course use?
US markets. SPY, and gold (GLD) from its first day in November 2004, with TLT and cash joining when the portfolio grows to four assets, and the S&P 500 index from 1990 for the long view. The course ships one reference dataset, so there's no data to buy and no API key to set up.
- I trade outside the US. Is the course still useful to me?
Yes. Nothing in the method depends on the US market. In the capstone you can detect the regime on your own index while trading the course's four US assets, though your numbers will differ from the course's.
- Do I need Claude Code or another AI assistant?
No. Nothing in the course needs one, and every notebook runs in your browser with nothing to install. An optional unit near the end shows one way to ask an AI assistant about a notebook from VS Code. If you use one, read every line it writes before you run it.
- How is the course delivered, and how long does it take?
It's self-paced: short videos, quizzes, documents, exercises and notebooks that run in your browser, organised into five parts and a capstone. Allow about 24 hours for the lessons, and about 40 with every exercise and the capstone.



