Call GET /api/v1/pairs/{symbol}?compact=1 before submitting any order. Check stale == False and prop_safe_to_trade == True (enforcing T-5m PRE_NEWS, 5m post-news prop rules, and all 4 VETO shields).
Python Forex & Gold News API: Copy-Paste Fail-Closed Prop-Firm VETO Filter
Run immediately on EUR/USD for $0 forever (zero API key, zero pip installs). Add a deterministic 15-line fail-closed prop-firm macro news gate to your Python MetaTrader5, cTrader, OANDA, or IBKR bot using https://forexnewsradar.com/api/v1/pairs/EURUSD?compact=1—plus native Streamable HTTP MCP for LangGraph and OpenAI Agents.
Cache responses locally for 15 seconds per symbol so high-frequency tick loops stay well below rate limits while receiving fresh macro status updates within seconds of every CPI or NFP print.
Building with OpenAI Agents SDK, Anthropic SDK, or LangGraph? Connect directly to POST https://forexnewsradar.com/mcp (free live EUR/USD with zero key) and call check_prop_trade_gate natively.
# Zero-dependency Python 3 prop-firm macro news gate
# Works immediately with NO API key on EURUSD ($0 free forever):
# https://forexnewsradar.com/api/v1/pairs/EURUSD?compact=1
import json
import os
import time
import urllib.error
import urllib.request
_CACHE = {}
def check_prop_gate(symbol: str = "EURUSD", ttl_sec: int = 15) -> dict:
now = time.monotonic()
cached = _CACHE.get(symbol)
if cached and (now - cached["ts"]) < ttl_sec:
return cached["val"]
api_key = os.getenv("FNR_API_KEY", "").strip()
headers = {"Accept": "application/json", "User-Agent": "fnr-python-bot/1.0"}
if api_key:
headers["Authorization"] = f"Bearer {api_key}"
url = f"https://forexnewsradar.com/api/v1/pairs/{symbol}?compact=1"
req = urllib.request.Request(url, headers=headers)
try:
with urllib.request.urlopen(req, timeout=5) as resp:
payload = json.loads(resp.read().decode("utf-8"))
allowed = (not payload.get("stale", True)) and bool(payload.get("prop_safe_to_trade", False))
out = {
"allowed": allowed,
"status": payload.get("status", "UNKNOWN"),
"wait_sec": int(payload.get("prop_wait_sec") or 0),
"surprise_z": payload.get("surprise_z"),
}
_CACHE[symbol] = {"ts": now, "val": out}
return out
except urllib.error.HTTPError as exc:
# Fail-closed on 402 (locked pair — unlock at https://forexnewsradar.com/?unlock=ALL) or 429/5xx
return {"allowed": False, "status": f"HTTP_{exc.code}", "wait_sec": 60, "surprise_z": None}
except Exception:
return {"allowed": False, "status": "NETWORK_ERROR", "wait_sec": 30, "surprise_z": None}
if __name__ == "__main__":
print(check_prop_gate("EURUSD"))
Python Forex News Filtering Options Compared
| Data Source | Dependencies | Prop-Firm T-5m + VETO Booleans | HTTP 429 Risk | Free Live Endpoint |
|---|---|---|---|---|
| HTML/XML Calendar Scraping | requests + BeautifulSoup/lxml | No (manual timezone parsing) | High on cloud IPs | Fragile DOM breaks |
| ForexNewsRadar ?compact=1 | Python stdlib urllib (0 deps) | Yes (prop_safe_to_trade + wait_sec) | 120–240 req/min SLA | EUR/USD $0 Forever |
| ForexNewsRadar Remote MCP | Any MCP SDK / JSON-RPC | Yes (5 typed tools + outputSchema) | 30 free / 240 Pro | EUR/USD $0 Forever |
Fix MQL5 Suffix Bugs (XAUUSD.pro) With 250B ?compact=1 JSON
Shows how automatic broker ticker normalization (.pro, m, _ecn) and the tiny 250-byte ?compact=1 JSON endpoint keep MQL5 WebRequest loops fast and bug-free.
Execution venues rarely standardize instrument identifiers: Spot Gold trades as XAUUSD, XAUUSDm, XAUUSD.pro, XAUUSD_ecn, or XAU/USD across retail and institutional bridges. Exact-string lookup tables inside custom EAs fail silently when users deploy bots onto a new broker feed, throwing unknown-symbol errors or skipping news protection entirely. Server-side prefix and suffix normalization inside /api/v1/pairs/{SYMBOL} resolves messy broker strings to canonical feeds cleanly, while ?compact=1 trims payload weight down to roughly 250 flat JSON bytes so MQL5 StringFind checks parse in microseconds.
Integrating With the Python MetaTrader5 Package, cTrader, or OANDA
Call check_prop_gate(symbol) right before mt5.order_send() or your broker REST order call. Because the helper fails closed on network timeouts, HTTP 402 locked pairs, or radar_health.stale = true, a transient cloud disconnect never accidentally fires a live order inside a restricted CPI or NFP window.
When polling multiple symbols from one Python process, fetch GET https://forexnewsradar.com/api/v1/pairs?compact=1 once every 15 seconds (4 requests/min total) to refresh all 18 FX, Gold, and Silver instruments in a single JSON payload.
Using requests or Streamable HTTP MCP in Autonomous Python Agents
Prefer the requests library? Swap urllib.request.urlopen for requests.get(url, headers=headers, timeout=5).json() with identical fail-closed exception handling. For LLM agent loops, connect directly to POST https://forexnewsradar.com/mcp—EUR/USD works free without credentials (30 req/min) and optional Bearer FNR_API_KEY unlocks Gold (XAU/USD) and all 18 pairs (240 req/min).
Primary Technical References & Verification Sources
- Python Standard Library — urllib.request Fail-Closed Timeout Handling
- ForexNewsRadar OpenAPI 3.1 CompactPairResponse Specification (/openapi.json)
- ForexNewsRadar 2026 Prop-Firm News Rules Matrix (/prop-firm-news-rules)
Frequently Asked Engineering & Compliance Questions
Can I run the Python prop-firm filter without installing third-party packages or paying?
Yes. The snippet above uses only Python standard library modules (json, os, time, urllib) and calls https://forexnewsradar.com/api/v1/pairs/EURUSD?compact=1 for $0 forever with zero signup.
How do I unlock Gold (XAUUSD) or GBPUSD in the same Python script?
Export FNR_API_KEY=fnr_live_... in your environment after unlocking a fixed-term Single-Pair ($9/30d) or All-18-Pair ($29/30d) pass at https://forexnewsradar.com/?unlock=ALL. The script automatically detects FNR_API_KEY and sends the Authorization: Bearer header.
Should I poll safe_to_trade or prop_safe_to_trade in Python?
For funded prop-firm accounts (FTMO, FundingPips, The5ers, FundedNext, E8, Alpha Capital), always gate on prop_safe_to_trade—which enforces T-5m PRE_NEWS, the 5m post-release compliance floor, and all 4 post-print VETO shields.