chore(graph): remove SignalProcessor

- process_signal reads the rating with parse_rating; the adapter ignored the model it was given
This commit is contained in:
Yijia-Xiao
2026-09-24 04:31:05 +00:00
parent a6e92a6b5e
commit 4e1faf6465
7 changed files with 15 additions and 98 deletions
-2
View File
@@ -4,7 +4,6 @@ from .conditional_logic import ConditionalLogic
from .propagation import Propagator
from .reflection import Reflector
from .setup import GraphSetup
from .signal_processing import SignalProcessor
from .trading_graph import TradingAgentsGraph
__all__ = [
@@ -13,5 +12,4 @@ __all__ = [
"GraphSetup",
"Propagator",
"Reflector",
"SignalProcessor",
]
-38
View File
@@ -1,38 +0,0 @@
"""Extract the 5-tier portfolio rating from the Portfolio Manager's decision.
The Portfolio Manager produces a typed ``PortfolioDecision`` via structured
output and renders it to markdown that always carries a ``**Rating**: X``
header (see :func:`tradingagents.agents.schemas.render_pm_decision`). The
deterministic heuristic in :mod:`tradingagents.agents.utils.rating` is more
than sufficient to extract that rating; no extra LLM call is needed.
This module exists for backwards compatibility with callers that expect a
``SignalProcessor.process_signal(text)`` interface.
"""
from __future__ import annotations
from typing import Any
from tradingagents.agents.utils.rating import RATING_REVIEW, extract_rating
class SignalProcessor:
"""Read the 5-tier rating out of a Portfolio Manager decision."""
def __init__(self, quick_thinking_llm: Any = None):
# The LLM argument is accepted for backwards compatibility but ignored:
# the PM's structured output guarantees the rating is parseable from the
# rendered markdown without a second LLM call, so it is not stored.
pass
def process_signal(self, full_signal: str) -> str:
"""Return one of Buy / Overweight / Hold / Underweight / Sell, or REVIEW.
An unrecognizable decision yields ``REVIEW`` rather than a fabricated
``Hold``, so a parsing failure is visible instead of masquerading as a
tradeable neutral signal (#1170). Consumers that map the result onto the
5-tier enum should guard with :func:`~tradingagents.agents.utils.rating.is_review`.
"""
rating = extract_rating(full_signal)
return rating if rating is not None else RATING_REVIEW
+3 -4
View File
@@ -28,6 +28,7 @@ from tradingagents.agents.utils.agent_utils import (
resolve_instrument_identity,
)
from tradingagents.agents.utils.memory import TradingMemoryLog
from tradingagents.agents.utils.rating import parse_rating
from tradingagents.dataflows.config import run_config, set_config
from tradingagents.dataflows.utils import get_current_date, safe_ticker_component
from tradingagents.dataflows.y_finance import get_closes
@@ -40,7 +41,6 @@ from .conditional_logic import ConditionalLogic
from .propagation import Propagator
from .reflection import Reflector
from .setup import GraphSetup
from .signal_processing import SignalProcessor
logger = logging.getLogger(__name__)
@@ -163,7 +163,6 @@ class TradingAgentsGraph:
max_recur_limit=self.config.get("max_recur_limit", 100),
)
self.reflector = Reflector(self.quick_thinking_llm)
self.signal_processor = SignalProcessor(self.quick_thinking_llm)
# State tracking
self.curr_state = None
@@ -655,5 +654,5 @@ class TradingAgentsGraph:
json.dump(entry, f, indent=4, ensure_ascii=False)
def process_signal(self, full_signal):
"""Process a signal to extract the core decision."""
return self.signal_processor.process_signal(full_signal)
"""The decision's 5-tier rating, or REVIEW when it has none."""
return parse_rating(full_signal)