From a6e92a6b5e77936fcf98d01476dc96c99d285c12 Mon Sep 17 00:00:00 2001 From: Yijia-Xiao Date: Wed, 23 Sep 2026 21:15:06 +0000 Subject: [PATCH] chore(agents): remove the deprecated social media analyst names - the social_media_analyst module and the create_social_media_analyst alias; use create_sentiment_analyst --- tradingagents/agents/__init__.py | 6 +- .../agents/analysts/sentiment_analyst.py | 58 ++++--------------- .../agents/analysts/social_media_analyst.py | 23 -------- tradingagents/graph/setup.py | 2 +- 4 files changed, 14 insertions(+), 75 deletions(-) delete mode 100644 tradingagents/agents/analysts/social_media_analyst.py diff --git a/tradingagents/agents/__init__.py b/tradingagents/agents/__init__.py index b78803a04..f8aa4d373 100644 --- a/tradingagents/agents/__init__.py +++ b/tradingagents/agents/__init__.py @@ -1,10 +1,7 @@ from .analysts.fundamentals_analyst import create_fundamentals_analyst from .analysts.market_analyst import create_market_analyst from .analysts.news_analyst import create_news_analyst -from .analysts.sentiment_analyst import ( - create_sentiment_analyst, - create_social_media_analyst, # deprecated alias kept for back-compat -) +from .analysts.sentiment_analyst import create_sentiment_analyst from .managers.portfolio_manager import create_portfolio_manager from .managers.research_manager import create_research_manager from .researchers.bear_researcher import create_bear_researcher @@ -32,6 +29,5 @@ __all__ = [ "create_portfolio_manager", "create_conservative_debator", "create_sentiment_analyst", - "create_social_media_analyst", # deprecated; will be removed in a future version "create_trader", ] diff --git a/tradingagents/agents/analysts/sentiment_analyst.py b/tradingagents/agents/analysts/sentiment_analyst.py index 1051746ac..acabea433 100644 --- a/tradingagents/agents/analysts/sentiment_analyst.py +++ b/tradingagents/agents/analysts/sentiment_analyst.py @@ -1,31 +1,19 @@ -"""Sentiment analyst — multi-source sentiment analysis for a target ticker. +"""Sentiment analyst: one sentiment report from three sources. -Previously named ``social_media_analyst``. Renamed and redesigned because -the old version had a prompt that demanded social-media analysis but the -only tool available was Yahoo Finance news — which led LLMs to fabricate -Reddit/X/StockTwits content under prompt pressure (verified live). +The node fetches its sources before calling the model and puts them in the +prompt, so the model reports on data it was given rather than inventing posts: -The redesigned agent pre-fetches three complementary data sources before -the LLM is invoked and injects them into the prompt as structured blocks: + 1. News headlines: Yahoo Finance + 2. StockTwits messages: the cashtag stream, with Bullish/Bearish tags + 3. Reddit posts: r/wallstreetbets, r/stocks, r/investing - 1. News headlines — Yahoo Finance (institutional framing) - 2. StockTwits messages — retail-trader posts indexed by cashtag, with - user-labeled Bullish/Bearish sentiment tags - 3. Reddit posts — r/wallstreetbets, r/stocks, r/investing +Each source is trimmed to the analysis window. These feeds serve recent items +and are not archived, so a historical run's sentiment inputs are not +point-in-time. -Each source is trimmed to the analysis window. These text feeds serve recent -items and are not archived as of a past date, so sentiment inputs for a -historical run are not guaranteed to be point-in-time. - -The agent does not use tool-calling; the data is in the prompt from -turn 0. Output uses the structured-output pattern (json_schema for -OpenAI/xAI, response_schema for Gemini, tool-use for Anthropic), falling -back to free-text generation for providers that lack native support, so -the sentiment header (band + score + confidence) is deterministic across -runs and providers instead of free-form per-model prose. - -See: https://github.com/TauricResearch/TradingAgents/issues/557 -See: https://github.com/TauricResearch/TradingAgents/issues/796 +The report is a SentimentReport through structured output where the provider +supports it and free text otherwise, so the band, score and confidence header +reads the same across providers. """ from datetime import datetime, timedelta @@ -193,25 +181,3 @@ Fill the following fields: - **narrative**: Full source-by-source breakdown, divergences, dominant narrative themes, catalysts and risks, and a markdown summary table of key sentiment signals (direction, source, supporting evidence). {get_language_instruction()}""" - - -# --------------------------------------------------------------------------- -# Backwards-compatibility shim -# --------------------------------------------------------------------------- -def create_social_media_analyst(llm): - """Deprecated alias for :func:`create_sentiment_analyst`. - - Kept so existing code that imports ``create_social_media_analyst`` - continues to work. - - .. deprecated:: - Import :func:`create_sentiment_analyst` directly instead. - """ - import warnings - warnings.warn( - "create_social_media_analyst is deprecated and will be removed in a " - "future version. Use create_sentiment_analyst instead.", - DeprecationWarning, - stacklevel=2, - ) - return create_sentiment_analyst(llm) diff --git a/tradingagents/agents/analysts/social_media_analyst.py b/tradingagents/agents/analysts/social_media_analyst.py deleted file mode 100644 index 8c72df082..000000000 --- a/tradingagents/agents/analysts/social_media_analyst.py +++ /dev/null @@ -1,23 +0,0 @@ -"""Backwards-compatibility shim for the renamed module. - -The agent is now ``sentiment_analyst`` and aggregates Yahoo Finance news, -StockTwits cashtag streams, and Reddit posts into a single sentiment -report. Import from ``tradingagents.agents.analysts.sentiment_analyst`` -going forward; this module will be removed in a future release. - -See: https://github.com/TauricResearch/TradingAgents/issues/557 -""" - -import warnings as _warnings - -from tradingagents.agents.analysts.sentiment_analyst import ( # noqa: F401 - create_sentiment_analyst, - create_social_media_analyst, -) - -_warnings.warn( - "tradingagents.agents.analysts.social_media_analyst is deprecated. " - "Import from tradingagents.agents.analysts.sentiment_analyst instead.", - DeprecationWarning, - stacklevel=2, -) diff --git a/tradingagents/graph/setup.py b/tradingagents/graph/setup.py index 171b65651..1b7dd52cf 100644 --- a/tradingagents/graph/setup.py +++ b/tradingagents/graph/setup.py @@ -66,7 +66,7 @@ class GraphSetup: Args: selected_analysts (list): List of analyst types to include. Options are: - "market": Market analyst - - "social": Social media analyst + - "social": Sentiment analyst - "news": News analyst - "fundamentals": Fundamentals analyst """