How to Customize Analyst Inclusion (Market, Social, News, Fundamentals) in TradingAgents

TradingAgents enables selective execution of analyst agents through the selected_analysts parameter in TradingAgentsGraph, interactive CLI checkboxes in cli/utils.py, or overrides in tradingagents/default_config.py.

TradingAgents implements a modular multi-agent pipeline where Market, Social Media, News, and Fundamentals analysts feed data into research-debate and trading loops. You control which agents participate through three distinct configuration layers that determine graph construction and execution flow.

The Three-Layer Configuration System

TradingAgents determines analyst inclusion through a hierarchy of controls:

CLI-Driven Analyst Selection

When the interactive session starts via cli/main.py, the run_analysis() function invokes select_analysts() to present a checkbox UI. The function returns a list of AnalystType enum values that map to specific agent keys.

selected_analysts = select_analysts()                         # <- user decides

selected_set = {analyst.value for analyst in selections["analysts"]}
selected_analyst_keys = [a for a in ANALYST_ORDER if a in selected_set]

graph = TradingAgentsGraph(
    selected_analyst_keys,
    config=config,
    debug=True,
    callbacks=[stats_handler],
)

Only analysts present in selected_analyst_keys receive nodes in the workflow graph. The GraphSetup.setup_graph method explicitly checks membership before wiring nodes:

if "market" in selected_analysts:
    analyst_nodes["market"] = create_market_analyst(self.quick_thinking_llm)
    tool_nodes["market"] = self.tool_nodes["market"]

# … similarly for social, news, fundamentals

Programmatic Analyst Inclusion

For library usage without the CLI, instantiate TradingAgentsGraph directly with your desired analyst set:

from tradingagents.graph.trading_graph import TradingAgentsGraph
from tradingagents.default_config import DEFAULT_CONFIG

# Choose only Market + Fundamentals

my_analysts = ["market", "fundamentals"]

# Optional: adjust the default config (e.g., change debate rounds)

my_config = DEFAULT_CONFIG.copy()
my_config["max_debate_rounds"] = 2

graph = TradingAgentsGraph(
    selected_analysts=my_analysts,
    config=my_config,
    debug=False,
)

The pipeline now executes exactly the two specified analysts, skipping Social and News processing entirely and reducing LLM token consumption.

Extending the Analyst Set

To add a new analyst type (for example, a Technical Analyst), modify three components:

  1. Implementation: Create tradingagents/agents/analysts/technical_analyst.py following the pattern of existing analysts (system prompt, tool list, return dict with "technical_report").
  2. Package Exposure: Import the new factory in tradingagents/agents/__init__.py and add it to __all__.
  3. Graph Wiring: Update GraphSetup.setup_graph and TradingAgentsGraph.__init__ to recognize the new key ("technical"). Extend ANALYST_ORDER in cli/utils.py to enable UI selection.

State Propagation and Report Mapping

Each analyst node returns a structured report field (e.g., "market_report", "sentiment_report"). The MessageBuffer.update_analyst_statuses() method inspects state chunks for these fields to track execution status. The mapping definitions in cli/main.py establish the relationships:

ANALYST_ORDER = ["market", "social", "news", "fundamentals"]
ANALYST_AGENT_NAMES = {
    "market": "Market Analyst",
    "social": "Social Analyst",
    "news": "News Analyst",
    "fundamentals": "Fundamentals Analyst",
}
ANALYST_REPORT_MAP = {
    "market": "market_report",
    "social": "sentiment_report",
    "news": "news_report",
    "fundamentals": "fundamentals_report",
}

If an analyst is excluded from selected_analysts, its report key remains absent from the state, the status stays pending, and the node never executes, keeping the pipeline lightweight.

Customizing Default Configurations

Change the default analyst set for all programmatic instantiations by modifying tradingagents/default_config.py:


# tradingagents/default_config.py

DEFAULT_CONFIG = {
    # …

    "selected_analysts": ["market", "social", "news"],  # fundamentals omitted by default

}

When TradingAgentsGraph receives no explicit selected_analysts argument, it can fallback to this configuration list to determine which agents to initialize.

Summary

  • Programmatic control: Pass a filtered list to TradingAgentsGraph(selected_analysts=[...]) to execute specific combinations of Market, Social, News, and Fundamentals agents.
  • CLI customization: Modify cli/utils.py to change checkbox defaults or validation rules requiring specific analysts.
  • Adding analysts: Extend the system by implementing the agent class, exposing it in __init__.py, and registering the key in setup.py and ANALYST_ORDER.
  • State management: Excluded analysts do not populate their respective report fields (defined in ANALYST_REPORT_MAP), ensuring the pipeline skips unnecessary computation.

Frequently Asked Questions

How do I exclude the Social Media analyst from my TradingAgents pipeline?

Pass a list excluding "social" to the TradingAgentsGraph constructor: selected_analysts=["market", "news", "fundamentals"]. Alternatively, deselect the Social Media checkbox when prompted by the select_analysts() function in cli/utils.py.

Can I run TradingAgents with only the Market analyst enabled?

Yes. Instantiate the graph with selected_analysts=["market"] to execute solely the market analysis node. The setup_graph method in tradingagents/graph/setup.py will only create nodes for the Market analyst, skipping social sentiment, news processing, and fundamental analysis.

Where is the analyst selection logic implemented in the source code?

The interactive selection UI resides in cli/utils.py inside the select_analysts() function (lines 78-87). The graph construction logic that respects these selections is implemented in tradingagents/graph/setup.py within GraphSetup.setup_graph (lines 40-53), which conditionally instantiates analyst nodes based on the provided list.

How do I add a custom Technical Analyst to the existing four analyst types?

Create the implementation file at tradingagents/agents/analysts/technical_analyst.py following the existing analyst pattern, expose the factory in tradingagents/agents/__init__.py, and register the new "technical" key in both GraphSetup.setup_graph and the ANALYST_ORDER list in cli/utils.py to enable selection via CLI or programmatic APIs.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →