# Macro Regimes Analysis (`khnaami/macro-regimes-analysis`) Actor

Macroeconomic regime classification engine identifying economic cycle phases (Reflation, Inflation, Stagflation, Deflation).
Key Capabilities:
Copper / Gold Ratio: Leading global economic growth and industrial demand barometer.
Yield Curve Regimes: US 10-Year and 30-Year Treasury yield dynamics.

- **URL**: https://apify.com/khnaami/macro-regimes-analysis.md
- **Developed by:** [khalid naami](https://apify.com/khnaami) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Cross-Asset Macro Regimes & Yield Premium Intelligence Actor

Institutional-grade quantitative macro model analyzing the **Copper/Gold Growth Proxy Ratio**, **10-Year & 30-Year Treasury Yield Regimes**, **OLS Linear Regression Implied Yields**, **Term-Premium Residuals (Rich vs Cheap $bp$)**, and **Rolling Gold Beta / Correlation Sensitivities**.

***

### 🏛️ Economic Rationale & Institutional Model

1. **Copper / Gold Ratio ($\frac{\text{Copper}}{\text{Gold}} \times 100$):**
   - **Copper (Doctor Copper):** Highly sensitive to global industrial production, manufacturing demand, and capital expenditures.
   - **Gold:** The ultimate monetary store of value and safe-haven asset responding to real yields and debt sustainability risks.
   - **The Ratio:** Represents the global benchmark for macroeconomic expansion vs risk-off deflationary pressure.

2. **10Y Yield OLS Regression & Term Premium:**
   - Linear regression of US 10-Year Benchmark Yields against the Copper/Gold Ratio over 1-Year and 2-Year rolling windows:
     $$\text{Implied } 10\text{Y Yield} = \alpha + \beta \cdot \left(\frac{\text{Copper}}{\text{Gold}} \times 100\right)$$
   - **Residual (Term Premium Spread):**
     $$\text{Residual } (bp) = \left(Y\_{10\text{Y, Actual}} - Y\_{10\text{Y, Implied}}\right) \times 100\text{ bp}$$
     - **Rich / Term Premium Surplus ($> +15\text{ bp}$):** Long-end yields are elevated above growth fundamentals (supply/deficit pressures, fiscal risk, or rate persistence).
     - **Cheap / Growth Discount ($< -15\text{ bp}$):** Yields are depressed relative to commodity growth signals (flight-to-quality or safe-haven demand).
     - **Fundamental Alignment:** Market rates are trading in fair-value equilibrium with global industrial demand.

3. **Gold Beta & Correlation to 30Y Treasury Yields:**
   - Evaluates gold's sensitivity to shifts in long-term discount rates:
     $$\beta\_{\text{Gold}, 60d} = \frac{\text{Cov}(\Delta % \text{Gold}, \Delta bp Y\_{30})}{\text{Var}(\Delta bp Y\_{30})}$$
   - **Rates-Reactor Mode ($\beta < -0.04$):** Standard monetary policy reaction (gold drops when long yields surge).
   - **Stagflation / Fiscal Credibility Hedge ($\beta > +0.02$):** Gold decouples from rates, rising alongside yields as an inflation and debt hedge.

***

### 📥 Input Parameters

| Parameter | Type | Default | Description |
|---|---|---|---|
| `period` | `String` | `"2y"` | Lookback window for regression and Z-score calculations (`1y`, `2y`, `3y`, `5y`, `10y`). |
| `goldSymbol` | `String` | `"GC=F"` | Gold ticker (Futures `GC=F` or ETF `GLD`). |
| `copperSymbol` | `String` | `"HG=F"` | Copper ticker (Futures `HG=F` or ETF `CPER`). |
| `includeHistoricalTimeSeries` | `Boolean` | `true` | Include full daily historical dataset records. |

***

### 📤 Output Structure

#### 1. Default Dataset (Daily Overview)

```json
{
  "date": "2026-09-30",
  "copperGoldRatio": 0.1582,
  "ratioPercentile": 42.5,
  "actual10yYieldPct": 4.15,
  "implied10yYieldPct": 3.92,
  "residualBp": 23.0,
  "termPremiumStatus": "Rich (Surplus)",
  "actual30yYieldPct": 4.48,
  "goldPriceUsd": 2685.50,
  "copperPriceUsd": 4.2485,
  "goldBeta30y": 0.0315,
  "corr60d": 0.18,
  "macroRegimeSignal": "Rich (Surplus) | Gold Beta: +0.032"
}
```

#### 2. Key-Value Store (`OUTPUT`)

Comprehensive JSON report with:

- **`currentRegimeSummary`**: Latest snapshot, ratio percentile, yield spreads, and regime classifications.
- **`regressionModels`**: 1-Year and 2-Year OLS regression formulas, slopes, intercepts, and $R^2$ goodness of fit.
- **`automatedMacroNarrative`**: Dynamic institutional commentary.

***

### 🎯 Institutional Use Cases

- **Asset Allocation & Fixed Income Positioning**: Identify when 10Y/30Y Treasuries are mispriced relative to global physical commodity demand.
- **Commodity & Precious Metals Trading**: Detect regime shifts where Gold transitions from a rates-sensitive asset to a fiscal debasement hedge.
- **Cross-Asset Macro Hedge Funds**: Systematic factor inputs for global macro models and risk parity portfolios.

# Actor input Schema

## `period` (type: `string`):

Historical timeframe for macro regimes analysis and regression fitting.

## `goldSymbol` (type: `string`):

Ticker symbol for Gold prices (COMEX futures 'GC=F' or ETF 'GLD').

## `copperSymbol` (type: `string`):

Ticker symbol for Copper prices (COMEX futures 'HG=F' or ETF 'CPER').

## `includeHistoricalTimeSeries` (type: `boolean`):

Whether to output full historical daily time series of metrics and residuals into the dataset.

## Actor input object example

```json
{
  "period": "2y",
  "goldSymbol": "GC=F",
  "copperSymbol": "HG=F",
  "includeHistoricalTimeSeries": true
}
```

# Actor output Schema

## `results` (type: `string`):

Dataset items and records produced by the Actor

## `overview` (type: `string`):

Summary report stored in Key-Value store

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("khnaami/macro-regimes-analysis").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("khnaami/macro-regimes-analysis").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call khnaami/macro-regimes-analysis --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,khnaami/macro-regimes-analysis"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/hv2iqQKrgVy2dlsxB/builds/tzK0HeGTyk147C7ov/openapi.json
