mirror of
https://github.com/TauricResearch/TradingAgents.git
synced 2026-09-19 11:15:24 +03:00
feat(data): add FRED macro indicators as an optional vendor
Surface Federal Reserve Economic Data (rates, inflation, labor, growth) to the news analyst via a new get_macro_indicators tool and a macro_data vendor category. Friendly aliases (cpi, unemployment, fed_funds_rate, 10y_treasury, yield_curve, ...) map to FRED series IDs; raw series IDs are accepted too. The report gives the latest value, change over the window, and a recent observation table. Windowing is lookahead-safe (observation_end = curr_date), missing values are skipped, and a missing FRED_API_KEY surfaces as a clear not-configured condition through the vendor router rather than a crash.
This commit is contained in:
36
tradingagents/agents/utils/macro_data_tools.py
Normal file
36
tradingagents/agents/utils/macro_data_tools.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from typing import Annotated
|
||||
|
||||
from langchain_core.tools import tool
|
||||
|
||||
from tradingagents.dataflows.interface import route_to_vendor
|
||||
|
||||
|
||||
@tool
|
||||
def get_macro_indicators(
|
||||
indicator: Annotated[
|
||||
str,
|
||||
"Macro indicator: a friendly alias such as 'cpi', 'core_pce', "
|
||||
"'unemployment', 'fed_funds_rate', '10y_treasury', 'yield_curve', "
|
||||
"'real_gdp', 'vix', or a raw FRED series ID such as 'CPIAUCSL'.",
|
||||
],
|
||||
curr_date: Annotated[str, "Current date in yyyy-mm-dd format; the end of the window"],
|
||||
look_back_days: Annotated[
|
||||
int | None, "Trailing window length in days; omit for a 1-year window"
|
||||
] = None,
|
||||
) -> str:
|
||||
"""
|
||||
Retrieve a macroeconomic indicator time series from FRED (Federal Reserve
|
||||
Economic Data): policy rates, Treasury yields, inflation, labor, and growth.
|
||||
Returns the series title, units, frequency, the latest value, the change
|
||||
over the window, and a recent observation table. Uses the configured
|
||||
macro_data vendor.
|
||||
|
||||
Args:
|
||||
indicator (str): Friendly alias or raw FRED series ID
|
||||
curr_date (str): Current date in yyyy-mm-dd format
|
||||
look_back_days (int): Trailing window length; omit for a 1-year window
|
||||
|
||||
Returns:
|
||||
str: A formatted markdown report of the macro series
|
||||
"""
|
||||
return route_to_vendor("get_macro_indicators", indicator, curr_date, look_back_days)
|
||||
Reference in New Issue
Block a user