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:
9 files changed
+453
-2
No files matched your search
@@ -3,6 +3,7 @@ from tradingagents.agents.utils.agent_utils import (
|
||||
get_instrument_context_from_state,
|
||||
get_global_news,
|
||||
get_language_instruction,
|
||||
get_macro_indicators,
|
||||
get_news,
|
||||
)
|
||||
from tradingagents.dataflows.config import get_config
|
||||
@@ -18,10 +19,11 @@ def create_news_analyst(llm):
|
||||
tools = [
|
||||
get_news,
|
||||
get_global_news,
|
||||
get_macro_indicators,
|
||||
]
|
||||
|
||||
system_message = (
|
||||
f"You are a news researcher tasked with analyzing recent news and trends over the past week. Please write a comprehensive report of the current state of the world that is relevant for trading and macroeconomics. Use the available tools: get_news(query, start_date, end_date) for {asset_label}-specific or targeted news searches, and get_global_news(curr_date, look_back_days, limit) for broader macroeconomic news. Provide specific, actionable insights with supporting evidence to help traders make informed decisions."
|
||||
f"You are a news researcher tasked with analyzing recent news and trends over the past week. Please write a comprehensive report of the current state of the world that is relevant for trading and macroeconomics. Use the available tools: get_news(query, start_date, end_date) for {asset_label}-specific or targeted news searches, get_global_news(curr_date, look_back_days, limit) for broader macroeconomic news, and get_macro_indicators(indicator, curr_date, look_back_days) to ground macro commentary in actual data from FRED (e.g. 'cpi', 'core_pce', 'unemployment', 'fed_funds_rate', '10y_treasury', 'yield_curve'). Provide specific, actionable insights with supporting evidence to help traders make informed decisions."
|
||||
+ """ Make sure to append a Markdown table at the end of the report to organize key points in the report, organized and easy to read."""
|
||||
+ get_language_instruction()
|
||||
)
|
||||
|
||||
@@ -23,6 +23,9 @@ from tradingagents.agents.utils.news_data_tools import (
|
||||
get_insider_transactions,
|
||||
get_global_news
|
||||
)
|
||||
from tradingagents.agents.utils.macro_data_tools import (
|
||||
get_macro_indicators
|
||||
)
|
||||
from tradingagents.agents.utils.market_data_validation_tools import (
|
||||
get_verified_market_snapshot
|
||||
)
|
||||
|
||||
@@ -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