Regimes — Purpose & Design (Planned)
regime_master (the definition table) already exists — see Overview — but it
starts empty, and computing/storing actual regime values is a separate pipeline that has not
been built yet. This page captures the plan for that pipeline as currently scoped, based on the
user's notes on 2026-09-06. Nothing below is implemented; treat it as design intent, not a
description of running code.
What a regime is for
A regime is a classification of "what kind of market condition is this period in" — used two ways:
- Filtering trades for a specific trading strategy. A strategy can be told to only fire (or only be evaluated) during certain regimes — e.g. a breakout strategy might only be tracked during a "trending" regime, not a "range-bound" one.
- Defining allocation periods for Asset Allocation. A retired prototype (the TAA Regime Dashboard, replaced by the Asset Allocation module) did this client-side on synthetic data for one regime (monthly RSI bands on Nifty) — the plan here is the general, DB-backed version of that idea, covering many regime types at once.
Regimes are not specific to one holding period — the same regime-definition mechanism is meant to serve Intraday, Swing, and long-term investment strategies, not just Asset Allocation.
Definition vs. computed values — two different things
- Definition (WHAT a regime is): lives in Postgres, table
regime_master(backend/strategies/models.py). One row per regime concept — e.g. "RSI Regime (Nifty, monthly)" or "PE Ratio Regime (Nifty 50)". See the Overview page for the current column list. ThecategoryCHECK constraint today only allows'gap','openrange','trend','volatility','calendar'— the regime types below (RSI bands, PE ratio bands, Elliott Wave, Fibonacci retracement, ...) aren't representable yet, so widening that constraint (or replacing it with an open lookup) is part of this plan, not yet done. - Computed values (the regime's actual historical classification per period, e.g. "March
2019 = Bullish"): not stored in Postgres. Calculated once when a regime is created/backfilled,
then written to Parquet files, planned under a
data/regimes/folder (same top-leveldata/convention asdata/nseieod/— see the rootCLAUDE.mdfor that layout). This mirrors the existing IEOD design: Postgres holds the small, slow-changing definition metadata; the (potentially large, append-only) time series of computed values lives in Parquet.
Example regime types
| Regime | Bands | Notes |
|---|---|---|
| RSI Regime | Bullish / Range-bound / Bearish | 3-way split on an RSI reading — this is the one that was prototyped in the retired TAA Regime Dashboard (monthly RSI on Nifty, configurable thresholds) |
| PE Ratio Regime | Oversold (PE < 15) / Normal (15–30) / Overbought (PE > 30) | Valuation-based, not momentum-based |
More regime types are planned to be added over time, not limited to the two above — explicitly
mentioned as candidates: Elliott Wave Projection and Fibonacci Retracement. Expect the
category list (and however categories are represented once widened) to keep growing as each is
scoped and inserted.
Timeframe / period
Every regime definition carries a timeframe it's evaluated on (regime_master.timeframe already
has a column for this). In the Asset Allocation context specifically, each regime is planned
to operate on a monthly period — matching the retired TAA dashboard prototype's monthly-rebalance
design. Intraday/Swing usage of the same regime
concept would run on shorter timeframes instead; the table's per-row timeframe column is what
makes one definition mechanism serve both.
Open questions / not yet decided
- Exact shape of the widened
category(or replacement) column/constraint onregime_masterto accommodate RSI/PE-ratio/Elliott-wave/Fibonacci and whatever comes after — an open lookup table might fit better than an ever-growingCHECK IN (...)list. - Exact Parquet schema/partitioning under
data/regimes/(per-regime file? per-symbol? column layout for a 3-band vs. a continuous score?). - Which backend package owns the computation pipeline that writes those Parquet files — a new
module, or an extension of
backend/strategies/orbackend/AA/.