Classify ISM PMI Macro Scenarios in 10 Lines of Python
Every first business day of the month, the Institute for Supply Management releases Manufacturing PMI. Traders scramble to interpret three numbers — headline PMI, New Orders, Prices Paid — into a macro posture: risk-on or risk-off?
I built a free REST API that does this classification for you. It takes the PMI triple and returns a scenario (Goldilocks, Moderate, Soft Landing, or Contraction) with a confidence score and concrete trading actions across SPY, US10Y, BTC, and CRDO.
No pip install. No API key for the demo. Copy-paste and run.
The 10-Line Version
import urllib.request, json
url = "https://macro-scenario-api.onrender.com/classify_scenario"
payload = {"headline_pmi": 52.8, "new_orders": 54.1, "prices_paid": 48.5}
req = urllib.request.Request(url, data=json.dumps(payload).encode(),
headers={"Content-Type": "application/json"})
with urllib.request.urlopen(req, timeout=30) as resp:
result = json.loads(resp.read())
print(json.dumps(result, indent=2))
Output:
{
"scenario": "GOLDILOCKS",
"confidence": 0.87,
"label": "Growth above 52, prices contained — risk-on",
"actions": [
{"asset": "SPY", "direction": "LONG", "priority": "HIGH"},
{"asset": "US10Y","direction": "SHORT", "priority": "MEDIUM"},
{"asset": "BTC", "direction": "LONG", "priority": "MEDIUM"}
]
}
That's it. The API is live, hosted on Render with a keep-alive cron so the free-tier cold start stays warm.
🚀 Production-ready on RapidAPI — rate limits, Swagger docs, marketplace reliability. Get your API key → (free tier: 100 calls/mo, no credit card)
The Four Scenarios
| Scenario | Trigger | Posture |
|---|---|---|
| 🍯 Goldilocks | PMI > 52, prices contained | Risk-on |
| ⚖️ Moderate | Solid growth, mild price pressure | Risk-on (selective) |
| 🪂 Soft Landing | Growth cooling toward 50, prices easing | Neutral |
| 📉 Contraction | Sub-50 headline, falling new orders | Risk-off |
Full Markdown Report Endpoint
Want a human-readable report you can paste into a trading journal? Hit the second endpoint:
url = "https://macro-scenario-api.onrender.com/ism_report"
payload = {"headline_pmi": 48.2, "new_orders": 46.1, "prices_paid": 55.0}
req = urllib.request.Request(url, data=json.dumps(payload).encode(),
headers={"Content-Type": "application/json"})
with urllib.request.urlopen(req, timeout=30) as resp:
print(json.loads(resp.read())["report"])
This returns a formatted Markdown reaction report with the scenario, confidence, and a prioritized action table — ready for Notion, Obsidian, or any markdown journal.
Batch Processing (CSV → Scenarios)
Processing a year of historical PMI data? Loop it:
import csv, urllib.request, json
API = "https://macro-scenario-api.onrender.com/classify_scenario"
with open("ism_history.csv") as f:
for row in csv.DictReader(f):
payload = {
"headline_pmi": float(row["pmi"]),
"new_orders": float(row["new_orders"]),
"prices_paid": float(row["prices_paid"]),
}
req = urllib.request.Request(API, data=json.dumps(payload).encode(),
headers={"Content-Type": "application/json"})
with urllib.request.urlopen(req, timeout=30) as resp:
r = json.loads(resp.read())
print(f"{row['date']}: {r['scenario']} (conf={r['confidence']})")
Get the API on RapidAPI
The demo above hits the public Render instance directly. For production usage with rate limits, Swagger docs, and marketplace reliability, the API is also published on RapidAPI:
👉 Macro Scenario Analysis API on RapidAPI
Free tier: 100 calls/month. Paid tier: $0.01/call — pay only for what you use.
Try It Now
# Health check — confirms the API is awake
import urllib.request
with urllib.request.urlopen("https://macro-scenario-api.onrender.com/health", timeout=30) as r:
print(r.read().decode()) # {"status":"ok","version":"1.0.0"}
If you build something with this, drop a comment — I'd love to see what scenarios you're tracking.
Honest Note on "Edge"
I ran a real event study on this classification: 72 ISM PMI releases mapped to actual S&P 500 returns. Result: the classification does NOT predict 5-day returns (GOLDILOCKS +0.80% vs CONTRACTION +1.13%, p=0.643, direction backwards at 5/10/21/42-day horizons).
So what's this API good for? Organization and journaling, not alpha. It gives you a consistent, reproducible framework to log your macro reactions and build a personal dataset over time. The edge — if you find one — comes from your reaction to the scenario, not the scenario label itself. Use it as a decision journal, not a crystal ball.
The API is open and documented at 473185670.github.io/macro-scenario-api. Source on GitHub. Built as a macro decision journal, not financial advice.
Top comments (0)