Portfolio Manager

Is This Expansion or Slowdown? The Agent Classifies Macro Regimes in Real-Time

8% drawdown avoided via early regime signalFinance & Trading5 min read

Key Takeaway

My AI agent monitors yield curves, PMI, unemployment claims, credit spreads, and ISM data to classify the current macro regime β€” and a regime shift alert helped Hari adjust my allocation before an 8% drawdown.

The Problem

Macro regimes determine everything. In expansion, growth stocks rip. In contraction, cash is king. In recovery, cyclicals lead. In slowdown, bonds outperform.

If you know the regime, asset allocation becomes straightforward. The problem is that nobody agrees on what regime we're in until it's obvious β€” and by then, the trade is over.

I watched my portfolio lose 8% in three weeks during a slowdown that "nobody saw coming." Except the data saw it. The yield curve had been flattening for two months. PMI was trending down. Credit spreads were widening. Unemployment claims were ticking up. Every individual indicator was published, freely available, and completely ignored by me because I wasn't aggregating them into a single picture.

I don't need to predict the future. I need to know what's happening now, classified correctly, with historical context for what usually happens next.

The Solution

The Macro Regime Detector agent on Mr.Chief. It pulls five macro indicators daily, runs a regime classification model, and alerts when the regime transitions. Historical lookback tables show what each asset class did in previous instances of the current regime.

Hari, my investment advisor agent, receives the classification and adjusts portfolio allocation recommendations accordingly.

The Process

yamlShow code
# Macro Regime Detector β€” Daily
name: macro-regime-detector
schedule: "0 14 * * 1-5"  # 2pm UTC (after US data releases)
channel: telegram

task: |
  Classify current macro regime from indicator data.

  INDICATORS:
  1. Yield Curve: 10Y-2Y Treasury spread
  2. PMI: ISM Manufacturing + Services
  3. Unemployment Claims: weekly initial + continuing
  4. Credit Spreads: Investment Grade + High Yield OAS
  5. ISM New Orders vs Inventories ratio

  REGIME DEFINITIONS:
  - EXPANSION: Curve normal, PMI >50 rising, claims falling, spreads tight
  - SLOWDOWN: Curve flattening, PMI >50 but falling, claims flat, spreads widening
  - CONTRACTION: Curve flat/inverted, PMI <50, claims rising, spreads wide
  - RECOVERY: Curve steepening, PMI <50 but rising, claims peaking, spreads tightening

  OUTPUT:
  - Current regime with confidence %
  - Transition probability (if near boundary)
  - Historical asset class performance in this regime
  - Alert on regime change
  - Recommendation for Hari on allocation bias

The classification model:

pythonShow code
class MacroRegimeClassifier:
    def __init__(self):
        self.indicators = {}
        self.history = load_regime_history()

    async def update(self):
        self.indicators = {
            "yield_curve": await fred.get("T10Y2Y"),
            "pmi_mfg": await fred.get("ISM_PMI"),
            "pmi_svc": await fred.get("ISM_SVC_PMI"),
            "claims_initial": await fred.get("ICSA"),
            "claims_continuing": await fred.get("CCSA"),
            "ig_spread": await fred.get("BAMLC0A0CM"),
            "hy_spread": await fred.get("BAMLH0A0HYM2"),
            "new_orders": await fred.get("ISM_NEWORD"),
            "inventories": await fred.get("ISM_INVENT"),
        }

    def classify(self):
        scores = {"expansion": 0, "slowdown": 0,
                  "contraction": 0, "recovery": 0}

        # Yield curve signal
        curve = self.indicators["yield_curve"]
        curve_trend = self.trend(curve, 60)  # 60-day trend
        if curve["value"] > 0.5 and curve_trend > 0:
            scores["expansion"] += 2
        elif curve["value"] > 0 and curve_trend < 0:
            scores["slowdown"] += 2
        elif curve["value"] < 0:
            scores["contraction"] += 2
        elif curve["value"] < 0.5 and curve_trend > 0:
            scores["recovery"] += 2

        # Normalize to percentages
        total = sum(scores.values())
        regime_probs = {k: v/total*100 for k, v in scores.items()}

        primary = max(regime_probs, key=regime_probs.get)
        confidence = regime_probs[primary]

        return primary, confidence, regime_probs

    def get_historical_returns(self, regime):
        """What happened to each asset class in this regime historically."""
        return self.history.query(f"regime == '{regime}'").groupby("asset").agg({
            "return_6m": "mean",
            "return_12m": "mean",
            "max_drawdown": "mean"
        })

The alert that saved me 8%:

View details
⚠️ MACRO REGIME TRANSITION

Previous: EXPANSION (held for 14 months)
Current:  SLOWDOWN β€” Confidence: 72%

INDICATOR BREAKDOWN:
  Yield Curve:   0.18% (was 0.85%) β€” flattening rapidly ⚠️
  PMI Mfg:       51.2 (was 54.8) β€” still >50 but falling ⚠️
  PMI Services:  52.1 (was 55.4) β€” declining ⚠️
  Initial Claims: 242K (was 218K) β€” trending up ⚠️
  Credit Spreads: IG +142bps (was +98bps) β€” widening ⚠️
  New Orders/Inventory: 0.98 (was 1.12) β€” below 1.0 ⚠️

HISTORICAL CONTEXT β€” Previous Slowdowns:
  Asset          Avg 6mo Return   Max Drawdown
  S&P 500        -4.2%            -12.8%
  Nasdaq         -8.1%            -18.4%
  BTC            -15.3%           -32.1%
  Treasury 10Y   +5.2%            -1.8%
  Gold           +8.4%            -3.2%
  USD Index      +2.1%            -1.4%

RECOMMENDATION TO HARI:
  Reduce equity overweight β†’ neutral
  Reduce crypto allocation by 30%
  Increase cash/treasury allocation
  Consider gold exposure

  Estimated drawdown avoided if slowdown confirmed: 8-12%

The Results

3

Regime transitions detected (18 months)

2-4 weeks

Lead time before market priced in

3/3

Correct classifications

Reduced equity 20%, crypto 30%

Portfolio adjustment based on slowdown alert

-4.2% (portfolio) vs -12.1% (S&P)

Drawdown during subsequent slowdown

~€15K

Estimated capital preserved

1 (reverted within 1 week)

False transition alerts

9 (daily)

Indicators tracked

Try It Yourself

  1. Set up FRED API access (free, requires registration)
  2. Define your regime framework β€” the four states above are a good starting point
  3. Calibrate indicator weights based on what's worked historically in your asset classes
  4. Set the alert threshold β€” 65%+ confidence is a good starting point for transitions
  5. Build your historical lookup table β€” what happened to your specific holdings in each regime
  6. Paper-trade the allocation shifts for two regime cycles before committing

Macro regimes are not predictions. They're classifications of the present. And the present is all the data you need to position correctly.


The market doesn't warn you it's shifting. The data does. You just have to be reading it.

macroregime-detectionyield-curvePMIportfolio-management

Want results like these?

Start free with your own AI team. No credit card required.

Is This Expansion or Slowdown? The Agent Classifies Macro Regimes in Real-Time β€” Mr.Chief