TradingAgents: Multi-Agents LLM Financial Trading Framework
10
stars
425
commits
Python
primary language
Sep 9, 2026
updated
We created this fork to build a complete analyst application and portfolio workflow around upstream's multi-agent analysis engine. It brings running analyses, reviewing evidence, tracking holdings, and planning portfolio changes into one research workspace, built on TauricResearch/TradingAgents.
Compared with the upstream revision merged into this repository (be952b8), the
main additions are:
| Addition | What it enables |
|---|---|
| Browser application | Run and cancel analyses, follow live progress, browse history, and configure settings through a Next.js/FastAPI application. A legacy Streamlit GUI is also included. |
| Batch analysis | Analyze multiple tickers from a list or portfolio CSV/JSON, include holdings information, and produce consolidated summaries and machine-readable results. |
| Portfolio allocation planning | Turn analysis ratings into target weights and whole-share buy/sell proposals, with available-cash, position-size, and minimum-cash constraints. |
| Richer reports | Export HTML/PDF reports, read plain-English briefs, compare benchmark charts, and chat about a completed analysis. |
| Research workspace | Keep searchable notes linked to tickers or runs, inspect archived debate transcripts and tool-call traces, and browse decision memory. |
| Portfolio monitoring | Track positions and valuations, maintain watchlists, follow price/news updates, and view an earnings/dividend calendar. |
| Scenario simulation | Save simple portfolio projections based on historical returns and volatility, with an SPY comparison. |
| Financial-planner integration | Import account holdings from a separate planner service and preview proposed position updates. |
| Automation and deployment | Use expanded noninteractive CLI options, web/API Docker services, Windows launchers, and Synology deployment and maintenance scripts. |
Allocation plans are research proposals and do not submit broker orders. Scenario simulation provides projections, not a historical strategy backtester.
Structured agent outputs, checkpoint/resume, persistent decision memory, broad LLM-provider support, Ollama/custom endpoints, and basic Docker support are shared upstream capabilities, not exclusive fork features. This fork keeps compatibility extensions where its application workflows or saved data need them.
This project is an independent fork with selective upstream sync. We retain the original multi-agent analysis foundation while developing the analyst application, portfolio workflows, reporting, and operational tooling described above.
Upstream bug fixes, security fixes, and useful infrastructure improvements may be merged when they fit this fork. We preserve fork-specific workflows and saved-data compatibility during those merges; we do not aim to mirror every upstream feature or maintain strict drop-in compatibility.
A detailed explainer on how it works is available.
🚀 TradingAgents | ⚡ Install & Run | 🎬 Demo | 📦 Package Usage | 🤝 Contributing | 📄 Citation
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.
Clone TradingAgents:
git clone https://github.com/skanga/TradingAgents.git
cd TradingAgents
Create a project-local virtual environment with Python 3.13:
python -m venv .venv
.\.venv\Scripts\activate
./.venv/Scripts/activate
Install the package and its CLI/development dependencies:
python -m pip install -e ".[dev]"
Run the CLI interactively (you will be prompted for everything):
python -m cli.main
TradingAgents currently has three local user interfaces:
| Interface | Purpose | Command |
|---|---|---|
| CLI | Terminal workflow | python -m cli.main or tradingagents |
| Streamlit GUI | Legacy browser GUI | python -m streamlit run gui/app.py or tradingagents-gui |
| Next.js web app | Primary web UI | FastAPI backend on port 8000 plus Next.js frontend on port 3000 |
For the legacy Streamlit GUI, install the GUI extra first:
python -m pip install -e ".[gui]"
python -m streamlit run gui/app.py
On Windows, run.bat launches the Streamlit GUI using the first matching
virtual environment it finds:
.\run.bat
For the Next.js web app, run the FastAPI backend and the frontend in separate
terminals. The backend currently reuses some modules under gui/, so install
both service and gui extras; otherwise uvicorn service.app:app can fail
with ModuleNotFoundError: No module named 'streamlit'.
python -m pip install -e ".[service,gui]"
python -m uvicorn service.app:app --host 0.0.0.0 --port 8000 --reload
Then start the web app:
cd web
npm install
npm run dev
Open http://localhost:3000. The Next.js app proxies /api/* to the backend
through API_URL, which defaults to http://localhost:8000.
Common development checks:
# Run the full test suite
python -m pytest
# Run a focused test file
python -m pytest tests/test_cli_llm_config.py -v
# Lint
ruff check .
# Static type check
mypy .
Alternatively, run the CLI with Docker:
cp .env.example .env # add your API keys
docker compose run --rm tradingagents
Run the Next.js web UI and FastAPI backend with Docker:
cp .env.example .env # add your API keys
docker compose up api web
Then open http://localhost:3000. Docker installs the needed backend
dependencies inside the API image, including the GUI modules reused by the
service.
Run the legacy Streamlit GUI with Docker:
cp .env.example .env # add your API keys
docker compose --profile legacy up gui
Then open http://localhost:8501.
For local models with Ollama:
docker compose --profile ollama run --rm tradingagents-ollama
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 DEEPSEEK_API_KEY=... # DeepSeek
export DASHSCOPE_API_KEY=... # Qwen — International (dashscope-intl.aliyuncs.com)
export DASHSCOPE_CN_API_KEY=... # Qwen — China (dashscope.aliyuncs.com)
export ZHIPU_API_KEY=... # GLM via Z.AI (international)
export ZHIPU_CN_API_KEY=... # GLM via BigModel (China, open.bigmodel.cn)
export MINIMAX_API_KEY=... # MiniMax — Global (api.minimax.io, M2.x, 204K ctx)
export MINIMAX_CN_API_KEY=... # MiniMax — China (api.minimaxi.com, M2.x, 204K ctx)
export OPENROUTER_API_KEY=... # OpenRouter
export ALPHA_VANTAGE_API_KEY=... # Alpha Vantage
For Azure OpenAI, copy .env.enterprise.example to .env.enterprise and fill in your credentials.
For AWS Bedrock, install the extra with pip install ".[bedrock]", set llm_provider: "bedrock", configure AWS credentials (environment variables, ~/.aws/credentials, or an IAM role) and AWS_DEFAULT_REGION, and use a Bedrock model ID, e.g. us.anthropic.claude-opus-4-8-v1:0.
For local models, configure Ollama with llm_provider: "ollama". The default endpoint is http://localhost:11434/v1; set OLLAMA_BASE_URL to point at a remote ollama-serve. Pull models with ollama pull <name>, and pick "Custom model ID" in the CLI for any model not listed by default.
For any other OpenAI-compatible server (vLLM, LM Studio, llama.cpp, or a custom relay), use llm_provider: "openai_compatible" and set the endpoint via backend_url (or TRADINGAGENTS_LLM_BACKEND_URL), e.g. http://localhost:8000/v1 for vLLM or http://localhost:1234/v1 for LM Studio. The model is whatever your server serves. No key is needed for local servers; set OPENAI_COMPATIBLE_API_KEY when the endpoint requires one.
Alternatively, copy .env.example to .env and fill in your keys:
cp .env.example .env
LLM runtime settings can come from CLI options or .env variables. CLI options take precedence over .env and environment variables. When llm_provider, quick_model, and deep_model are already configured, the interactive TUI skips the provider/model prompts and only asks for unrelated run settings such as ticker, date, analysts, and research depth.
Supported runtime env vars:
TRADINGAGENTS_LLM_PROVIDER=openai
TRADINGAGENTS_QUICK_MODEL=gpt-5.4-mini
TRADINGAGENTS_DEEP_MODEL=gpt-5.4
TRADINGAGENTS_BACKEND_URL=
TRADINGAGENTS_OPENAI_REASONING_EFFORT=
TRADINGAGENTS_GOOGLE_THINKING_LEVEL=
TRADINGAGENTS_ANTHROPIC_EFFORT=
For any unknown OpenAI-compatible endpoint (like InceptionLabs in this case), use the OpenAI provider with a custom base URL:
tradingagents \
--ticker SPY \
--analysis-date today \
--output-language English \
--analysts market,news,fundamentals \
--research-depth 3 \
--llm-provider openai \
--backend-url https://api.inceptionlabs.ai/v1 \
--quick-model mercury-2 \
--deep-model mercury-2 \
--save-report \
--save-path reports/spy \
--no-display-report
When all pre-analysis options are supplied, the CLI skips the setup prompts and starts the analysis directly.
Use --analysis-date today to resolve the date at runtime, or pass an explicit YYYY-MM-DD value for reproducible historical runs.
Run a holdings-aware batch analysis from a portfolio CSV or JSON file:
tradingagents batch \
--input portfolio.csv \
--analysis-date today \
--output-language English \
--analysts market,news,fundamentals \
--research-depth 1 \
--llm-provider openai \
--quick-model gpt-5.4-mini \
--deep-model gpt-5.4 \
--save-path reports/batch_tech \
--no-display-report
Batch CSV and JSON inputs must include ticker and may include quantity, average_cost, market_value, target_weight, and notes. average_cost is treated only as cost basis; allocation math uses explicit market_value and never infers current value from cost basis. Each ticker gets its own report bundle, and the batch directory also includes batch_summary.md, batch_summary.html, and batch_results.json.
Generate a portfolio allocation plan from the batch results:
tradingagents batch --input portfolio.csv --cash 2500 --allocate
tradingagents batch --tickers AAPL,MSFT,NVDA --cash 5000 --allocate --dry-run
tradingagents batch --input portfolio.csv --cash 5000 --allocate --max-position-weight 0.20 --min-cash-weight 0.05
Allocation mode ranks successful ticker analyses, computes current and target portfolio weights, sizes whole-share buy/sell deltas when prices can be derived from explicit market_value / quantity, and keeps uninvestable remainder as leftover cash. If any failed ticker has a positive market_value, allocation is skipped with a console warning so failed holdings are not dropped from the portfolio denominator. --dry-run prints planned paper orders only; it does not submit broker orders. Allocation outputs are generated research tooling, not financial advice.
When --allocate is enabled, the batch output directory also includes allocation_plan.md, allocation_plan.html, and allocation_plan.json.
The same setup can live in the .env file instead - this example uses groq:
OPENAI_API_KEY=...
TRADINGAGENTS_LLM_PROVIDER=openai
TRADINGAGENTS_BACKEND_URL=https://api.groq.com/openai/v1
TRADINGAGENTS_QUICK_MODEL=openai/gpt-oss-20b
TRADINGAGENTS_DEEP_MODEL=openai/gpt-oss-120b
Custom OpenAI-compatible base URLs use the Chat Completions-compatible path and accept unknown model IDs without catalog validation warnings.
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.
TradingAgents works with any market Yahoo Finance covers, using the exchange-suffixed ticker. Company identity and the alpha benchmark resolve automatically per market.
AAPL, SPY0700.HK · Tokyo: 7203.T · London: AZN.LRELIANCE.NS, .BO · Canada: .TO · Australia: .AX.SS, Shenzhen .SZ (e.g. 600519.SS for Kweichow Moutai)BTC-USD, ETH-USD
An interface will appear showing results as they load, letting you track the agent's progress as it runs.
We built TradingAgents with LangGraph to ensure flexibility and modularity. The framework supports multiple LLM providers: OpenAI, Google, Anthropic, xAI, DeepSeek, Qwen (Alibaba DashScope, international and China endpoints), GLM (Zhipu), MiniMax (global + China), OpenRouter, Ollama for local models, and Azure OpenAI for enterprise.
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, deepseek, qwen, qwen-cn, glm, glm-cn, minimax, minimax-cn, openrouter, ollama, azure
config["deep_think_llm"] = "gpt-5.4" # Model for complex reasoning
config["quick_think_llm"] = "gpt-5.4-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.
For an OpenAI-compatible provider that is not listed in the model catalog, keep llm_provider as openai and set backend_url:
config = DEFAULT_CONFIG.copy()
config["llm_provider"] = "openai"
config["backend_url"] = "https://api.inceptionlabs.ai/v1"
config["quick_think_llm"] = "mercury"
config["deep_think_llm"] = "mercury"
TradingAgents persists two kinds of state across runs.
The decision log is always on. Each completed run appends its decision to ~/.tradingagents/memory/trading_memory.md. On the next run for the same ticker, TradingAgents fetches the realised return (raw and alpha vs SPY), generates a one-paragraph reflection, and injects the most recent same-ticker decisions plus recent cross-ticker lessons into the Portfolio Manager prompt, so each analysis carries forward what worked and what didn't.
Override the path with TRADINGAGENTS_MEMORY_LOG_PATH.
The fork writes versioned JSONL records despite the historical .md filename.
It can also read legacy Markdown logs, including upstream resolved: dates;
the next write converts those records to JSONL. Historical analyses only use
lessons whose outcomes were known by the analysis date. An upstream version
that only reads Markdown cannot directly read a log after this conversion.
Checkpoint resume is opt-in via --checkpoint. When enabled, LangGraph saves state after each node so a crashed or interrupted run resumes from the last successful step instead of starting over. On a resume run you will see Resuming from step N for <TICKER> on <date> in the logs; on a new run you will see Starting fresh. Checkpoints are cleared automatically on successful completion.
Per-ticker SQLite databases live at ~/.tradingagents/cache/checkpoints/<TICKER>.db (override the base with TRADINGAGENTS_CACHE_DIR). Use --clear-checkpoints to reset all of them before a run.
tradingagents analyze --checkpoint # enable for this run
tradingagents analyze --clear-checkpoints # reset before running
config = DEFAULT_CONFIG.copy()
config["checkpoint_enabled"] = True
ta = TradingAgentsGraph(config=config)
_, decision = ta.propagate("NVDA", "2026-01-15")
TradingAgents is LLM-driven, so two runs of the same ticker and date can differ. This is expected for a research tool built on language models, not a defect. The variation comes from a few distinct sources, and it helps to separate them.
Language model sampling is non-deterministic. Even at a fixed temperature, providers do not guarantee byte-identical output across calls, and reasoning models (the default GPT-5.x family, and any thinking-mode model) vary the most because their internal reasoning is itself sampled.
Live data moves. News, StockTwits, and Reddit return different content as time passes, so a run today sees different inputs than a run last week even for the same historical trade date. Pin the analysis date to hold the price and indicator window fixed, but the social and news sources still reflect "now".
To reduce variation you can lower the sampling temperature. Set temperature in your config (or TRADINGAGENTS_TEMPERATURE in .env); lower values make models that honor it more repeatable. The current curated models are reasoning-first and largely ignore temperature, so for tighter reproducibility use a non-reasoning model, which you can set explicitly via the Custom model ID option.
config = DEFAULT_CONFIG.copy()
config["llm_provider"] = "openai"
config["temperature"] = 0.0
# Reasoning models ignore temperature. For tighter reproducibility, set a
# non-reasoning deep/quick model explicitly (e.g. via the Custom model ID option).
What does not vary anymore: the analyzed company identity is resolved deterministically from the ticker before any agent runs, and the market analyst grounds exact price and indicator claims in a verified data snapshot. Earlier reports of "different companies" or fabricated price levels across runs are addressed by these two mechanisms.
Backtest results are not guaranteed to match any published figure. Returns depend on the model, the temperature, the date range, data quality, and the sampling above. Treat the framework as a research scaffold for studying multi-agent analysis, not as a strategy with a fixed, replicable return.
Contributions are welcome: bug fixes, documentation, and feature ideas; past contributions are credited per release in CHANGELOG.md.
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},
}
Python
87.3%
TypeScript
10.3%
Shell
1.9%
TradingAgents: Multi-Agents LLM Financial Trading Framework
10
stars
425
commits
Python
primary language
Sep 9, 2026
updated
We created this fork to build a complete analyst application and portfolio workflow around upstream's multi-agent analysis engine. It brings running analyses, reviewing evidence, tracking holdings, and planning portfolio changes into one research workspace, built on TauricResearch/TradingAgents.
Compared with the upstream revision merged into this repository (be952b8), the
main additions are:
| Addition | What it enables |
|---|---|
| Browser application | Run and cancel analyses, follow live progress, browse history, and configure settings through a Next.js/FastAPI application. A legacy Streamlit GUI is also included. |
| Batch analysis | Analyze multiple tickers from a list or portfolio CSV/JSON, include holdings information, and produce consolidated summaries and machine-readable results. |
| Portfolio allocation planning | Turn analysis ratings into target weights and whole-share buy/sell proposals, with available-cash, position-size, and minimum-cash constraints. |
| Richer reports | Export HTML/PDF reports, read plain-English briefs, compare benchmark charts, and chat about a completed analysis. |
| Research workspace | Keep searchable notes linked to tickers or runs, inspect archived debate transcripts and tool-call traces, and browse decision memory. |
| Portfolio monitoring | Track positions and valuations, maintain watchlists, follow price/news updates, and view an earnings/dividend calendar. |
| Scenario simulation | Save simple portfolio projections based on historical returns and volatility, with an SPY comparison. |
| Financial-planner integration | Import account holdings from a separate planner service and preview proposed position updates. |
| Automation and deployment | Use expanded noninteractive CLI options, web/API Docker services, Windows launchers, and Synology deployment and maintenance scripts. |
Allocation plans are research proposals and do not submit broker orders. Scenario simulation provides projections, not a historical strategy backtester.
Structured agent outputs, checkpoint/resume, persistent decision memory, broad LLM-provider support, Ollama/custom endpoints, and basic Docker support are shared upstream capabilities, not exclusive fork features. This fork keeps compatibility extensions where its application workflows or saved data need them.
This project is an independent fork with selective upstream sync. We retain the original multi-agent analysis foundation while developing the analyst application, portfolio workflows, reporting, and operational tooling described above.
Upstream bug fixes, security fixes, and useful infrastructure improvements may be merged when they fit this fork. We preserve fork-specific workflows and saved-data compatibility during those merges; we do not aim to mirror every upstream feature or maintain strict drop-in compatibility.
A detailed explainer on how it works is available.
🚀 TradingAgents | ⚡ Install & Run | 🎬 Demo | 📦 Package Usage | 🤝 Contributing | 📄 Citation
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.
Clone TradingAgents:
git clone https://github.com/skanga/TradingAgents.git
cd TradingAgents
Create a project-local virtual environment with Python 3.13:
python -m venv .venv
.\.venv\Scripts\activate
./.venv/Scripts/activate
Install the package and its CLI/development dependencies:
python -m pip install -e ".[dev]"
Run the CLI interactively (you will be prompted for everything):
python -m cli.main
TradingAgents currently has three local user interfaces:
| Interface | Purpose | Command |
|---|---|---|
| CLI | Terminal workflow | python -m cli.main or tradingagents |
| Streamlit GUI | Legacy browser GUI | python -m streamlit run gui/app.py or tradingagents-gui |
| Next.js web app | Primary web UI | FastAPI backend on port 8000 plus Next.js frontend on port 3000 |
For the legacy Streamlit GUI, install the GUI extra first:
python -m pip install -e ".[gui]"
python -m streamlit run gui/app.py
On Windows, run.bat launches the Streamlit GUI using the first matching
virtual environment it finds:
.\run.bat
For the Next.js web app, run the FastAPI backend and the frontend in separate
terminals. The backend currently reuses some modules under gui/, so install
both service and gui extras; otherwise uvicorn service.app:app can fail
with ModuleNotFoundError: No module named 'streamlit'.
python -m pip install -e ".[service,gui]"
python -m uvicorn service.app:app --host 0.0.0.0 --port 8000 --reload
Then start the web app:
cd web
npm install
npm run dev
Open http://localhost:3000. The Next.js app proxies /api/* to the backend
through API_URL, which defaults to http://localhost:8000.
Common development checks:
# Run the full test suite
python -m pytest
# Run a focused test file
python -m pytest tests/test_cli_llm_config.py -v
# Lint
ruff check .
# Static type check
mypy .
Alternatively, run the CLI with Docker:
cp .env.example .env # add your API keys
docker compose run --rm tradingagents
Run the Next.js web UI and FastAPI backend with Docker:
cp .env.example .env # add your API keys
docker compose up api web
Then open http://localhost:3000. Docker installs the needed backend
dependencies inside the API image, including the GUI modules reused by the
service.
Run the legacy Streamlit GUI with Docker:
cp .env.example .env # add your API keys
docker compose --profile legacy up gui
Then open http://localhost:8501.
For local models with Ollama:
docker compose --profile ollama run --rm tradingagents-ollama
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 DEEPSEEK_API_KEY=... # DeepSeek
export DASHSCOPE_API_KEY=... # Qwen — International (dashscope-intl.aliyuncs.com)
export DASHSCOPE_CN_API_KEY=... # Qwen — China (dashscope.aliyuncs.com)
export ZHIPU_API_KEY=... # GLM via Z.AI (international)
export ZHIPU_CN_API_KEY=... # GLM via BigModel (China, open.bigmodel.cn)
export MINIMAX_API_KEY=... # MiniMax — Global (api.minimax.io, M2.x, 204K ctx)
export MINIMAX_CN_API_KEY=... # MiniMax — China (api.minimaxi.com, M2.x, 204K ctx)
export OPENROUTER_API_KEY=... # OpenRouter
export ALPHA_VANTAGE_API_KEY=... # Alpha Vantage
For Azure OpenAI, copy .env.enterprise.example to .env.enterprise and fill in your credentials.
For AWS Bedrock, install the extra with pip install ".[bedrock]", set llm_provider: "bedrock", configure AWS credentials (environment variables, ~/.aws/credentials, or an IAM role) and AWS_DEFAULT_REGION, and use a Bedrock model ID, e.g. us.anthropic.claude-opus-4-8-v1:0.
For local models, configure Ollama with llm_provider: "ollama". The default endpoint is http://localhost:11434/v1; set OLLAMA_BASE_URL to point at a remote ollama-serve. Pull models with ollama pull <name>, and pick "Custom model ID" in the CLI for any model not listed by default.
For any other OpenAI-compatible server (vLLM, LM Studio, llama.cpp, or a custom relay), use llm_provider: "openai_compatible" and set the endpoint via backend_url (or TRADINGAGENTS_LLM_BACKEND_URL), e.g. http://localhost:8000/v1 for vLLM or http://localhost:1234/v1 for LM Studio. The model is whatever your server serves. No key is needed for local servers; set OPENAI_COMPATIBLE_API_KEY when the endpoint requires one.
Alternatively, copy .env.example to .env and fill in your keys:
cp .env.example .env
LLM runtime settings can come from CLI options or .env variables. CLI options take precedence over .env and environment variables. When llm_provider, quick_model, and deep_model are already configured, the interactive TUI skips the provider/model prompts and only asks for unrelated run settings such as ticker, date, analysts, and research depth.
Supported runtime env vars:
TRADINGAGENTS_LLM_PROVIDER=openai
TRADINGAGENTS_QUICK_MODEL=gpt-5.4-mini
TRADINGAGENTS_DEEP_MODEL=gpt-5.4
TRADINGAGENTS_BACKEND_URL=
TRADINGAGENTS_OPENAI_REASONING_EFFORT=
TRADINGAGENTS_GOOGLE_THINKING_LEVEL=
TRADINGAGENTS_ANTHROPIC_EFFORT=
For any unknown OpenAI-compatible endpoint (like InceptionLabs in this case), use the OpenAI provider with a custom base URL:
tradingagents \
--ticker SPY \
--analysis-date today \
--output-language English \
--analysts market,news,fundamentals \
--research-depth 3 \
--llm-provider openai \
--backend-url https://api.inceptionlabs.ai/v1 \
--quick-model mercury-2 \
--deep-model mercury-2 \
--save-report \
--save-path reports/spy \
--no-display-report
When all pre-analysis options are supplied, the CLI skips the setup prompts and starts the analysis directly.
Use --analysis-date today to resolve the date at runtime, or pass an explicit YYYY-MM-DD value for reproducible historical runs.
Run a holdings-aware batch analysis from a portfolio CSV or JSON file:
tradingagents batch \
--input portfolio.csv \
--analysis-date today \
--output-language English \
--analysts market,news,fundamentals \
--research-depth 1 \
--llm-provider openai \
--quick-model gpt-5.4-mini \
--deep-model gpt-5.4 \
--save-path reports/batch_tech \
--no-display-report
Batch CSV and JSON inputs must include ticker and may include quantity, average_cost, market_value, target_weight, and notes. average_cost is treated only as cost basis; allocation math uses explicit market_value and never infers current value from cost basis. Each ticker gets its own report bundle, and the batch directory also includes batch_summary.md, batch_summary.html, and batch_results.json.
Generate a portfolio allocation plan from the batch results:
tradingagents batch --input portfolio.csv --cash 2500 --allocate
tradingagents batch --tickers AAPL,MSFT,NVDA --cash 5000 --allocate --dry-run
tradingagents batch --input portfolio.csv --cash 5000 --allocate --max-position-weight 0.20 --min-cash-weight 0.05
Allocation mode ranks successful ticker analyses, computes current and target portfolio weights, sizes whole-share buy/sell deltas when prices can be derived from explicit market_value / quantity, and keeps uninvestable remainder as leftover cash. If any failed ticker has a positive market_value, allocation is skipped with a console warning so failed holdings are not dropped from the portfolio denominator. --dry-run prints planned paper orders only; it does not submit broker orders. Allocation outputs are generated research tooling, not financial advice.
When --allocate is enabled, the batch output directory also includes allocation_plan.md, allocation_plan.html, and allocation_plan.json.
The same setup can live in the .env file instead - this example uses groq:
OPENAI_API_KEY=...
TRADINGAGENTS_LLM_PROVIDER=openai
TRADINGAGENTS_BACKEND_URL=https://api.groq.com/openai/v1
TRADINGAGENTS_QUICK_MODEL=openai/gpt-oss-20b
TRADINGAGENTS_DEEP_MODEL=openai/gpt-oss-120b
Custom OpenAI-compatible base URLs use the Chat Completions-compatible path and accept unknown model IDs without catalog validation warnings.
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.
TradingAgents works with any market Yahoo Finance covers, using the exchange-suffixed ticker. Company identity and the alpha benchmark resolve automatically per market.
AAPL, SPY0700.HK · Tokyo: 7203.T · London: AZN.LRELIANCE.NS, .BO · Canada: .TO · Australia: .AX.SS, Shenzhen .SZ (e.g. 600519.SS for Kweichow Moutai)BTC-USD, ETH-USD
An interface will appear showing results as they load, letting you track the agent's progress as it runs.
We built TradingAgents with LangGraph to ensure flexibility and modularity. The framework supports multiple LLM providers: OpenAI, Google, Anthropic, xAI, DeepSeek, Qwen (Alibaba DashScope, international and China endpoints), GLM (Zhipu), MiniMax (global + China), OpenRouter, Ollama for local models, and Azure OpenAI for enterprise.
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, deepseek, qwen, qwen-cn, glm, glm-cn, minimax, minimax-cn, openrouter, ollama, azure
config["deep_think_llm"] = "gpt-5.4" # Model for complex reasoning
config["quick_think_llm"] = "gpt-5.4-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.
For an OpenAI-compatible provider that is not listed in the model catalog, keep llm_provider as openai and set backend_url:
config = DEFAULT_CONFIG.copy()
config["llm_provider"] = "openai"
config["backend_url"] = "https://api.inceptionlabs.ai/v1"
config["quick_think_llm"] = "mercury"
config["deep_think_llm"] = "mercury"
TradingAgents persists two kinds of state across runs.
The decision log is always on. Each completed run appends its decision to ~/.tradingagents/memory/trading_memory.md. On the next run for the same ticker, TradingAgents fetches the realised return (raw and alpha vs SPY), generates a one-paragraph reflection, and injects the most recent same-ticker decisions plus recent cross-ticker lessons into the Portfolio Manager prompt, so each analysis carries forward what worked and what didn't.
Override the path with TRADINGAGENTS_MEMORY_LOG_PATH.
The fork writes versioned JSONL records despite the historical .md filename.
It can also read legacy Markdown logs, including upstream resolved: dates;
the next write converts those records to JSONL. Historical analyses only use
lessons whose outcomes were known by the analysis date. An upstream version
that only reads Markdown cannot directly read a log after this conversion.
Checkpoint resume is opt-in via --checkpoint. When enabled, LangGraph saves state after each node so a crashed or interrupted run resumes from the last successful step instead of starting over. On a resume run you will see Resuming from step N for <TICKER> on <date> in the logs; on a new run you will see Starting fresh. Checkpoints are cleared automatically on successful completion.
Per-ticker SQLite databases live at ~/.tradingagents/cache/checkpoints/<TICKER>.db (override the base with TRADINGAGENTS_CACHE_DIR). Use --clear-checkpoints to reset all of them before a run.
tradingagents analyze --checkpoint # enable for this run
tradingagents analyze --clear-checkpoints # reset before running
config = DEFAULT_CONFIG.copy()
config["checkpoint_enabled"] = True
ta = TradingAgentsGraph(config=config)
_, decision = ta.propagate("NVDA", "2026-01-15")
TradingAgents is LLM-driven, so two runs of the same ticker and date can differ. This is expected for a research tool built on language models, not a defect. The variation comes from a few distinct sources, and it helps to separate them.
Language model sampling is non-deterministic. Even at a fixed temperature, providers do not guarantee byte-identical output across calls, and reasoning models (the default GPT-5.x family, and any thinking-mode model) vary the most because their internal reasoning is itself sampled.
Live data moves. News, StockTwits, and Reddit return different content as time passes, so a run today sees different inputs than a run last week even for the same historical trade date. Pin the analysis date to hold the price and indicator window fixed, but the social and news sources still reflect "now".
To reduce variation you can lower the sampling temperature. Set temperature in your config (or TRADINGAGENTS_TEMPERATURE in .env); lower values make models that honor it more repeatable. The current curated models are reasoning-first and largely ignore temperature, so for tighter reproducibility use a non-reasoning model, which you can set explicitly via the Custom model ID option.
config = DEFAULT_CONFIG.copy()
config["llm_provider"] = "openai"
config["temperature"] = 0.0
# Reasoning models ignore temperature. For tighter reproducibility, set a
# non-reasoning deep/quick model explicitly (e.g. via the Custom model ID option).
What does not vary anymore: the analyzed company identity is resolved deterministically from the ticker before any agent runs, and the market analyst grounds exact price and indicator claims in a verified data snapshot. Earlier reports of "different companies" or fabricated price levels across runs are addressed by these two mechanisms.
Backtest results are not guaranteed to match any published figure. Returns depend on the model, the temperature, the date range, data quality, and the sampling above. Treat the framework as a research scaffold for studying multi-agent analysis, not as a strategy with a fixed, replicable return.
Contributions are welcome: bug fixes, documentation, and feature ideas; past contributions are credited per release in CHANGELOG.md.
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},
}
Python
87.3%
TypeScript
10.3%
Shell
1.9%