* feat(ui): scoped graph nodes per ticker + MockEngine for LLM-free UI testing
## Summary
Adds a MockEngine that streams scripted agent events with zero real LLM calls,
enabling full UI testing (graph, terminal, drawer, metrics) without API keys or
network. Also fixes the ReactFlow graph so that each ticker/identifier gets its
own visual node — previously an auto run with 5 tickers collapsed all pipelines
into the same node IDs, overwriting each other.
## Changes
- **MockEngine** (`agent_os/backend/services/mock_engine.py`): new class that
generates realistic scripted events for pipeline, scan, and auto run types.
Supports configurable speed divisor (1× realistic → 10× instant). Auto mock
accepts a `tickers` list for multi-ticker runs.
- **POST /api/run/mock** (`runs.py`): new endpoint wiring MockEngine into the
BackgroundTasks + store pattern identical to real run endpoints.
- **WebSocket routing** (`websocket.py`): added `mock` run-type branch so the
WS executor path also dispatches to MockEngine when the background task hasn't
started yet.
- **LangGraphEngine** (`langgraph_engine.py`): added `_run_identifiers` dict to
track ticker/MARKET/portfolio_id per run; all emitted events now carry an
`identifier` field so the frontend can scope them.
- **AgentGraph.tsx**: ReactFlow nodes now keyed by `node_id:identifier` (e.g.
`news_analyst:AAPL`, `news_analyst:NVDA`). Edges scoped to same identifier.
`onNodeClick` passes raw `node_id` + `identifier` separately so the event
drawer can filter without parsing the scoped key.
- **Dashboard.tsx**: Mock button + type/speed controls added. `openNodeDetail`
accepts identifier; `NodeEventsDetail` filters by both `node_id` and
`identifier`. Comma-separated ticker input for mock auto runs (e.g.
`AAPL,NVDA,TSLA`).
- **useAgentStream.ts**: `AgentEvent` interface extended with `identifier?`
field.
## Decision Context
- Scoped node ID format chosen as `node_id:identifier` (colon separator) rather
than embedding identifier in the agent display name — keeps node labels clean
and identifier visible as a coloured badge, not label text.
- Raw `node_id` and `identifier` stored separately in `node.data` so the drawer
filtering (`events.filter(e => e.node_id === nodeId && e.identifier === id)`)
does not need to parse/split the scoped key.
- Parent edges are scoped to the same identifier as the child, assuming intra-
ticker chains. Cross-run topology edges (e.g. scan → pipeline) are implicit
via log events, not ReactFlow edges.
- MockEngine uses `asyncio.sleep` with a speed divisor — higher speed values
give faster replays for rapid iteration during UI development.
## Considerations for Future Agents
- Re-run button on graph nodes already uses `identifier` to dispatch
`startRun('pipeline', { ticker: identifier })` or `startRun('scan')` — no
further changes needed for per-node re-runs to be correctly scoped.
- The `_run_identifiers` dict in LangGraphEngine is keyed by `run_id`; it is
cleaned up after each run. If parallel runs are ever supported per engine
instance, this dict handles them correctly already.
- For run_auto, each sub-run (scan, per-ticker pipeline) calls its own
`run_scan`/`run_pipeline` which sets `_run_identifiers[run_id]`. The outer
`run_auto` does not set it — this is intentional.
- `uv.lock` changes reflect dependency tree after Chainlit removal in the
previous commit; no new runtime dependencies were added by this PR.
---
🤖 Commit Agent | Session: mock-engine + scoped-graph-nodes
* feat(graph): two-phase column layout — scan top, ticker columns below
## Summary
Redesigns the ReactFlow graph layout engine so scan nodes form a centred funnel
at the top and each ticker gets its own vertical column below, matching the
agreed design. Ticker header cards (bold ticker symbol + pulse dot + progress
counter) act as column anchors; agent cards stack beneath each one. Fan-out
dashed edges connect macro_synthesis → each ticker header.
## Changes
- SCAN phase: geopolitical/market-movers/sector scanners placed on the same
horizontal row at x = [0, COL_WIDTH, 2×COL_WIDTH] (aligns with first 3
ticker columns); industry_deep_dive and macro_synthesis centered below.
- TICKER columns: new identifiers get a TickerHeaderNode at tickerStartY;
agent nodes stack beneath using column-based parent tracking
(header → agent0 → agent1 → …) independent of evt.parent_node_id.
- TickerHeaderNode: wide card, bold ticker symbol, animated pulse status dot,
completedCount/agentCount counter updated live as results arrive.
- Tool nodes (node_id starts with "tool_") skipped from graph — visible in
terminal/drawer, not cluttering the column layout.
- Portfolio nodes centred below all ticker columns.
- Layout state extracted into LayoutState ref + freshLayout() for clean resets.
- Node labels use toLabel() (snake_case → Title Case).
- Metrics row shows total tokens (in+out) instead of just latency.
## Decision Context
- Column-based parent edges chosen over evt.parent_node_id because mock engine
emits parent_node_id="start" for all agents; column ordering is reliable.
- Scan phase X positions reuse COL_WIDTH so phase-1 scanners visually align
above first three ticker columns — no arbitrary magic numbers.
- Tool nodes removed from graph (not hidden) — they add noise to column layout
with no actionable meaning; the drawer already shows them per node.
## Considerations for Future Agents
- identifierLastNode tracks scoped ID of previous agent per ticker column —
used for sequential edge chaining; do not remove without replacing edge logic.
- tickerStartY is set once on first ticker arrival; subsequent tickers share
the same Y baseline — only colCount and identifierAgentRow differ per ticker.
- TickerHeaderNode clicks pass node_id='header' + identifier to onNodeClick;
Dashboard NodeEventsDetail filters all events by identifier when node_id is
'header' (shows the full ticker run timeline in the drawer).
---
🤖 Commit Agent | Session: two-phase column graph layout
|
||
|---|---|---|
| .claude | ||
| agent_os | ||
| assets | ||
| cli | ||
| docs | ||
| tests | ||
| tradingagents | ||
| .DS_Store | ||
| .env.example | ||
| .gitignore | ||
| CLAUDE.md | ||
| LICENSE | ||
| PLAN.md | ||
| README.md | ||
| benchmark.py | ||
| benchmark_append.py | ||
| benchmark_csv.py | ||
| benchmark_engine.py | ||
| benchmark_full.py | ||
| benchmark_iteration.py | ||
| benchmark_list.py | ||
| benchmark_v2.py | ||
| benchmark_v3.py | ||
| benchmark_v4.py | ||
| benchmark_v5.py | ||
| main.py | ||
| package-lock.json | ||
| parse_again.py | ||
| parse_issue.py | ||
| pyproject.toml | ||
| requirements.txt | ||
| run_benchmark_6.py | ||
| run_test.py | ||
| test.py | ||
| test2.py | ||
| test_agent_os_connection.py | ||
| test_cache.csv | ||
| test_df.py | ||
| test_opt.py | ||
| test_pd.py | ||
| test_pyarrow.py | ||
README.md
TradingAgents: Multi-Agents LLM Financial Trading Framework
News
- [2026-03] TradingAgents v0.2.2 released with GPT-5.4/Gemini 3.1/Claude 4.6 model coverage, five-tier rating scale, OpenAI Responses API, Anthropic effort control, and cross-platform stability.
- [2026-02] TradingAgents v0.2.0 released with multi-provider LLM support (GPT-5.x, Gemini 3.x, Claude 4.x, Grok 4.x) and improved system architecture.
- [2026-01] Trading-R1 Technical Report released, with Terminal expected to land soon.
🎉 TradingAgents officially released! We have received numerous inquiries about the work, and we would like to express our thanks for the enthusiasm in our community.
So we decided to fully open-source the framework. Looking forward to building impactful projects with you!
🚀 TradingAgents | ⚡ Installation & CLI | 🎬 Demo | 📦 Package Usage | 🤝 Contributing | 📄 Citation
TradingAgents Framework
TradingAgents is a multi-agent trading framework that mirrors the dynamics of real-world trading firms. By deploying specialized LLM-powered agents: from fundamental analysts, sentiment experts, and technical analysts, to trader, risk management team, the platform collaboratively evaluates market conditions and informs trading decisions. Moreover, these agents engage in dynamic discussions to pinpoint the optimal strategy.
TradingAgents framework is designed for research purposes. Trading performance may vary based on many factors, including the chosen backbone language models, model temperature, trading periods, the quality of data, and other non-deterministic factors. It is not intended as financial, investment, or trading advice.
Our framework decomposes complex trading tasks into specialized roles. This ensures the system achieves a robust, scalable approach to market analysis and decision-making.
Analyst Team
- Fundamentals Analyst: Evaluates company financials and performance metrics, identifying intrinsic values and potential red flags.
- Sentiment Analyst: Analyzes social media and public sentiment using sentiment scoring algorithms to gauge short-term market mood.
- News Analyst: Monitors global news and macroeconomic indicators, interpreting the impact of events on market conditions.
- Technical Analyst: Utilizes technical indicators (like MACD and RSI) to detect trading patterns and forecast price movements.
Researcher Team
- Comprises both bullish and bearish researchers who critically assess the insights provided by the Analyst Team. Through structured debates, they balance potential gains against inherent risks.
Trader Agent
- Composes reports from the analysts and researchers to make informed trading decisions. It determines the timing and magnitude of trades based on comprehensive market insights.
Risk Management and Portfolio Manager
- Continuously evaluates portfolio risk by assessing market volatility, liquidity, and other risk factors. The risk management team evaluates and adjusts trading strategies, providing assessment reports to the Portfolio Manager for final decision.
- The Portfolio Manager approves/rejects the transaction proposal. If approved, the order will be sent to the simulated exchange and executed.
Installation and CLI
Installation
Clone TradingAgents:
git clone https://github.com/TauricResearch/TradingAgents.git
cd TradingAgents
Create a virtual environment in any of your favorite environment managers:
conda create -n tradingagents python=3.13
conda activate tradingagents
Install the package and its dependencies:
pip install .
Required APIs
TradingAgents supports multiple LLM providers. Set the API key for your chosen provider:
export OPENAI_API_KEY=... # OpenAI (GPT)
export GOOGLE_API_KEY=... # Google (Gemini)
export ANTHROPIC_API_KEY=... # Anthropic (Claude)
export XAI_API_KEY=... # xAI (Grok)
export OPENROUTER_API_KEY=... # OpenRouter
export ALPHA_VANTAGE_API_KEY=... # Alpha Vantage
For local models, configure Ollama with llm_provider: "ollama" in your config.
Alternatively, copy .env.example to .env and fill in your keys:
cp .env.example .env
CLI Usage
Launch the interactive CLI:
tradingagents # installed command
python -m cli.main # alternative: run directly from source
You will see a screen where you can select your desired tickers, analysis date, LLM provider, research depth, and more.
An interface will appear showing results as they load, letting you track the agent's progress as it runs.
CLI Commands
| Command | Description |
|---|---|
analyze |
Interactive per-ticker multi-agent analysis (select analysts, LLM, date) |
scan |
Run the 3-phase macro scanner (geopolitical → sector → synthesis) |
pipeline |
Full pipeline: macro scan JSON → filter by conviction → per-ticker deep dive |
portfolio |
Run the Portfolio Manager workflow (requires portfolio ID + scan JSON) |
check-portfolio |
Review current holdings only — no new candidates |
auto |
End-to-end: scan → pipeline → portfolio manager (one command) |
Examples:
# Per-ticker analysis (interactive prompts for ticker, date, LLM, analysts)
python -m cli.main analyze
# Run macro scanner for a specific date
python -m cli.main scan --date 2026-03-21
# Run the full pipeline (scan → filter → per-ticker analysis)
python -m cli.main pipeline
# Run portfolio manager with a specific portfolio and scan results
python -m cli.main portfolio
# Review current holdings without new candidates
python -m cli.main check-portfolio --portfolio-id main_portfolio --date 2026-03-21
# Full autonomous mode: scan → pipeline → portfolio
python -m cli.main auto --portfolio-id main_portfolio --date 2026-03-21
Running Tests
# Install dev dependencies
pip install -e ".[dev]"
# Run all unit tests (integration and e2e excluded by default)
python -m pytest tests/ -v
# Run only portfolio tests
python -m pytest tests/portfolio/ -v
# Run a specific test file
python -m pytest tests/portfolio/test_models.py -v
# Run tests with coverage (requires pytest-cov)
python -m pytest tests/ --cov=tradingagents --cov-report=term-missing
Note: Integration tests that require network access or database connections auto-skip when the relevant environment variables (
SUPABASE_CONNECTION_STRING,FINNHUB_API_KEY, etc.) are not set.
TradingAgents Package
Implementation Details
We built TradingAgents with LangGraph to ensure flexibility and modularity. The framework supports multiple LLM providers: OpenAI, Google, Anthropic, xAI, OpenRouter, and Ollama.
Python Usage
To use TradingAgents inside your code, you can import the tradingagents module and initialize a TradingAgentsGraph() object. The .propagate() function will return a decision. You can run main.py, here's also a quick example:
from tradingagents.graph.trading_graph import TradingAgentsGraph
from tradingagents.default_config import DEFAULT_CONFIG
ta = TradingAgentsGraph(debug=True, config=DEFAULT_CONFIG.copy())
# forward propagate
_, decision = ta.propagate("NVDA", "2026-01-15")
print(decision)
You can also adjust the default configuration to set your own choice of LLMs, debate rounds, etc.
from tradingagents.graph.trading_graph import TradingAgentsGraph
from tradingagents.default_config import DEFAULT_CONFIG
config = DEFAULT_CONFIG.copy()
config["llm_provider"] = "openai" # openai, google, anthropic, xai, openrouter, ollama
config["deep_think_llm"] = "gpt-5.2" # Model for complex reasoning
config["quick_think_llm"] = "gpt-5-mini" # Model for quick tasks
config["max_debate_rounds"] = 2
ta = TradingAgentsGraph(debug=True, config=config)
_, decision = ta.propagate("NVDA", "2026-01-15")
print(decision)
See tradingagents/default_config.py for all configuration options.
Contributing
We welcome contributions from the community! Whether it's fixing a bug, improving documentation, or suggesting a new feature, your input helps make this project better. If you are interested in this line of research, please consider joining our open-source financial AI research community Tauric Research.
Citation
Please reference our work if you find TradingAgents provides you with some help :)
@misc{xiao2025tradingagentsmultiagentsllmfinancial,
title={TradingAgents: Multi-Agents LLM Financial Trading Framework},
author={Yijia Xiao and Edward Sun and Di Luo and Wei Wang},
year={2025},
eprint={2412.20138},
archivePrefix={arXiv},
primaryClass={q-fin.TR},
url={https://arxiv.org/abs/2412.20138},
}