TauricResearch/TradingAgents · error · ValueError
'{indicator}' is not a known macro alias or a valid FRED ser
Error message
'{indicator}' is not a known macro alias or a valid FRED series ID. Use an alias (e.g. 'cpi', 'unemployment', '10y_treasury') or a raw FRED series ID (e.g. 'CPIAUCSL'). What it means
Raised by _resolve_series_id() in tradingagents/dataflows/fred.py when the indicator argument is neither a known macro alias (keys of MACRO_SERIES like 'cpi', 'unemployment', '10y_treasury') nor a plausible raw FRED series ID: FRED IDs are uppercase, short (<= 30 chars), and contain no whitespace. It is a ValueError that fails fast with guidance instead of letting a malformed query 400 at the API.
Source
Thrown at tradingagents/dataflows/fred.py:110
return api_key
def _resolve_series_id(indicator: str) -> str:
"""Map a friendly alias to a FRED series ID, or pass a raw ID through.
Raises ``ValueError`` when the input is neither a known alias nor a plausible
series ID — typically a descriptive phrase the LLM passed instead (e.g.
"bank of japan rate"). FRED IDs are short and alphanumeric, so this rejects
it up front with guidance rather than letting it 400 the API.
"""
key = indicator.strip().lower().replace(" ", "_").replace("-", "_")
if key in MACRO_SERIES:
return MACRO_SERIES[key]
candidate = indicator.strip().upper()
# FRED series IDs never contain whitespace and are short; reject anything
# else (a descriptive phrase the LLM passed) rather than 400ing the API.
if not candidate or len(candidate) > 30 or any(c.isspace() for c in candidate):
raise ValueError(
f"'{indicator}' is not a known macro alias or a valid FRED series ID. "
f"Use an alias (e.g. 'cpi', 'unemployment', '10y_treasury') or a raw "
f"FRED series ID (e.g. 'CPIAUCSL')."
)
return candidate
def _request(path: str, params: dict) -> dict:
"""GET a FRED endpoint, surfacing FRED's JSON error body on a bad request."""
api_params = {**params, "api_key": get_api_key(), "file_type": "json"}
response = requests.get(
f"{FRED_API_BASE}/{path}", params=api_params, timeout=REQUEST_TIMEOUT
)
# FRED returns 400 with a JSON {"error_message": ...} for unknown series IDs
# or malformed params; turn that into a clear, actionable error.
if response.status_code == 400:
try:
message = response.json().get("error_message", response.text)View on GitHub (pinned to a33fd4c0f1)
Solutions
- Use a documented alias from MACRO_SERIES ('cpi', 'unemployment', '10y_treasury', etc.) — check fred.py's MACRO_SERIES dict for the exact set
- Or pass a real FRED series ID (uppercase, no spaces, <= 30 chars), e.g. 'CPIAUCSL', 'FEDFUNDS', 'DGS10'
- Extend MACRO_SERIES with a new alias -> series ID mapping for phrases you use often
- In LLM tool descriptions, enumerate the accepted aliases so the model stops emitting prose
Example fix
# before
get_macro_data("bank of japan rate", "2025-06-10")
# -> ValueError: 'bank of japan rate' is not a known macro alias or a valid FRED series ID. ...
# after
get_macro_data("interest_rate", "2025-06-10") # alias in MACRO_SERIES
get_macro_data("IRSTCB01JPM156N", "2025-06-10") # raw FRED series ID (no spaces) Defensive patterns
Strategy: validation
Validate before calling
import re
from tradingagents.dataflows.fred import MACRO_SERIES
def valid_fred_indicator(name: str) -> bool:
if not isinstance(name, str):
return False
key = name.strip().lower().replace(" ", "_").replace("-", "_")
if key in MACRO_SERIES:
return True
c = name.strip().upper()
return bool(c) and len(c) <= 30 and not any(ch.isspace() for ch in c) Type guard
def is_fred_series_id(s: str) -> bool:
return bool(re.fullmatch(r"[A-Z0-9]{1,30}", s or "")) Try / catch
try:
get_macro_data(indicator, curr_date)
except ValueError as e:
if "not a known macro alias" in str(e):
indicator = "cpi" # or re-prompt the LLM with aliases + example IDs
else:
raise Prevention
- Give the LLM the alias list and 2-3 example series IDs in the tool schema
- Add a normalization map for recurring natural-language queries instead of passing them through
- Search FRED's series API first when unsure of the ID
When it happens
Trigger: Passing natural-language phrases such as 'bank of japan rate', 'fed funds', or 'GDP growth rate'; passing lowercase raw IDs without uppercase normalization won't error (upper-cased), but spaces, >30-char strings, or empty strings do; passing a question sentence from an LLM tool call.
Common situations: LLM macro analyst emitting descriptive phrases instead of the documented aliases; users guessing series names; prompts not listing the accepted aliases; multi-word queries not yet mapped in MACRO_SERIES.
Related errors
- Unsupported date format: {date_input}
- Indicator {indicator} is not supported. Please choose from:
- FRED_API_KEY environment variable is not set. Get a free key
- FRED request failed: {message}
- Method '{method}' not found in any category
AI-assisted analysis of TauricResearch/TradingAgents@a33fd4c0f1 (2026-08-14).
Data as JSON: /api/errors/0b7fcd77d4729135.
Report an issue: GitHub.