SuperAPI AI Directory

trading-agents

Data & analytics

View repository

Updated 10-15 21:49

About this skill

TradingAgents Multi-Agent Trading Framework

1. When to use me?

When the user says:

  • "Analyze NVDA stock"
  • "Can AAPL be bought now?"
  • "Use multi-agent to analyze MSFT"
  • "Get trading signals"
  • "Conduct fundamental analysis of a stock"
  • "Technical analysis of TSLA"
  • "Risk assessment"
  • Any trading decision that requires professional quantitative analysis

2. What can I do?

Core Features

  • Multi-agent collaborative analysis: Simulates the team decision-making process of a real trading company
  • Fundamental analysis: Evaluates company financial and performance metrics
  • Sentiment analysis: Analyzes social media and public sentiment
  • News analysis: Monitors global news and macroeconomic indicators
  • Technical analysis: Uses technical indicators such as MACD and RSI
  • Bull-bear debate: Bull and bear researchers conduct structured debates
  • Risk management: Evaluates risk factors such as market volatility and liquidity
  • Trading decisions: Generates buy/sell/hold recommendations

Supported LLM Providers

  • OpenAI (GPT-5.x, GPT-4.x)
  • Google (Gemini 3.x, 2.x)
  • Anthropic (Claude 4.x, 3.x)
  • xAI (Grok 4.x)
  • OpenRouter
  • Ollama (local models)

Data Sources

  • yfinance (default, no API key required)
  • Alpha Vantage (API key required)

3. Quick Start

3.1 Basic Usage

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

# 初始化
ta = TradingAgentsGraph(debug=True, config=DEFAULT_CONFIG.copy())

# 分析股票
_, decision = ta.propagate("NVDA", "2024-05-10")
print(decision)

3.2 Custom Configuration

config = DEFAULT_CONFIG.copy()
config["llm_provider"] = "openai"        # openai, google, anthropic, xai, openrouter, ollama
config["deep_think_llm"] = "gpt-5.2"     # 复杂推理模型
config["quick_think_llm"] = "gpt-5-mini" # 快速任务模型
config["max_debate_rounds"] = 2          # 辩论轮数

ta = TradingAgentsGraph(debug=True, config=config)
_, decision = ta.propagate("AAPL", "2024-05-10")

3.3 Configure Data Sources

config["data_vendors"] = {
    "core_stock_apis": "yfinance",           # alpha_vantage, yfinance
    "technical_indicators": "yfinance",
    "fundamental_data": "yfinance",
    "news_data": "yfinance",
}

4. Configure API Keys

Method 1: Environment Variables

export OPENAI_API_KEY=...          # OpenAI
export GOOGLE_API_KEY=...          # Google
export ANTHROPIC_API_KEY=...       # Anthropic
export XAI_API_KEY=...             # xAI
export OPENROUTER_API_KEY=...      # OpenRouter
export ALPHA_VANTAGE_API_KEY=...   # Alpha Vantage

Method 2: .env File

In ~/.openclaw/workspace/.env add:

OPENAI_API_KEY=sk-...
ALPHA_VANTAGE_API_KEY=...

5. Agent Architecture

Analysis Team

Agent Responsibility
Fundamentals Analyst Evaluate company financials and intrinsic value
Sentiment Analyst Analyze social media sentiment scores
News Analyst Monitor global news and macroeconomic indicators
Technical Analyst Technical indicator analysis (MACD, RSI)

Research Team

  • Bull Researcher: Bullish view, looking for upside opportunities
  • Bear Researcher: Bearish view, identifying potential risks

Trading Team

  • Trader: Synthesizes reports and makes trading decisions
  • Risk Manager: Assesses and adjusts risk
  • Portfolio Manager: Final approval of trades

6. Output Example

{
    "ticker": "NVDA",
    "date": "2024-05-10",
    "action": "BUY",
    "quantity": 100,
    "confidence": 0.75,
    "reasoning": "基本面强劲,AI 需求增长,技术面突破...",
    "risk_level": "MEDIUM",
    "target_price": 950.00,
    "stop_loss": 800.00
}

7. File Structure

This Skill itself (the signals engine works out of the box and does not depend on an external directory layout):

TradingAgents-OpenClaw-Skill/
├── __init__.py             # TradingAgentsSkill + CLI(多 engine 路由)
├── signals.py              # 本地技术信号引擎(无需 API key)
├── requirements.txt
├── tests/                  # pytest(合成数据,无网络)
├── example_usage.py        # 端到端示例
└── SKILL.md                # 本文件

Enabling the LLM engine additionally requires the TradingAgents framework (PyPI package or local clone):

tradingagents/              # pip install tradingagents 后可直接 import
├── agents/                 # 智能体定义
├── dataflows/              # 数据流
├── graph/                  # LangGraph 流程
└── default_config.py       # 默认配置

8. Running Locally

signals engine (no API key required)

pip install -r requirements.txt
python __init__.py NVDA --engine signals

LLM engine (requires TradingAgents + API key)

pip install tradingagents
export OPENAI_API_KEY=sk-...
# 若为本地 clone,可改用环境变量指向:
#   export TRADING_AGENTS_HOME=/path/to/TradingAgents-Official
python __init__.py NVDA --engine llm

9. Using in OpenClaw

Example Conversation

用户:分析一下 NVDA 股票
助手:正在用 TradingAgents 多智能体框架分析 NVDA……
     [基本面分析师] 公司财务表现强劲
     [技术分析师] MACD 金叉,RSI 处于健康区间
     [风险管理] 波动性中等,建议控制仓位
     综合建议:BUY,目标价 $950,止损 $800

10. Notes

⚠️ Important Notice:

  • This framework is for research use only
  • Does not constitute investment advice
  • Trading performance is affected by many factors (model, temperature, data quality, etc.)
  • Do not use for real trading decisions unless you fully understand the risks

11. Dependencies

langgraph>=0.2.0
langchain>=0.3.0
openai>=1.0.0
google-generativeai>=0.8.0
anthropic>=0.40.0
yfinance>=0.2.40
alpha-vantage>=3.0.0
pandas>=2.0.0
numpy>=1.24.0
python-dotenv>=1.0.0

12. References