a
This commit is contained in:
@@ -0,0 +1,471 @@
|
||||
# TradingAgents 技术架构分析及 akshare 集成修改
|
||||
|
||||
> **文档时间**: 2026-05-05
|
||||
> **项目路径**: `/home/ubuntu/forgithub/TradingAgents`
|
||||
> **运行端口**: `:8500` (Web UI)
|
||||
|
||||
---
|
||||
|
||||
## 一、项目概述
|
||||
|
||||
TradingAgents 是一个基于 LLM 的多智能体(Multi-Agent)金融交易分析框架。它模拟真实投资决策中的"研究员→辩论→交易员"流程,由多个分析师角色协作完成对单只股票的深入分析,并输出最终交易决策(买入/卖出/持有)。
|
||||
|
||||
核心思想:**用 LLM 扮演不同角色的分析师,使用真实市场数据工具,通过辩论机制达成投资共识。**
|
||||
|
||||
---
|
||||
|
||||
## 二、技术栈
|
||||
|
||||
| 层次 | 技术选型 |
|
||||
|------|----------|
|
||||
| 多智能体编排 | LangGraph(StateGraph) |
|
||||
| LLM 接口 | LangChain + DeepSeek / OpenAI |
|
||||
| 工具系统 | LangChain `@tool` 装饰器 |
|
||||
| 数据源 | akshare / yfinance / Alpha Vantage |
|
||||
| Web 服务 | FastAPI + 自定义 SPA 页面 |
|
||||
| 部署 | systemd(`tradingagents.service`) |
|
||||
|
||||
---
|
||||
|
||||
## 三、架构分层
|
||||
|
||||
### 3.1 整体流程
|
||||
|
||||
```
|
||||
用户输入 (ticker + date)
|
||||
│
|
||||
▼
|
||||
┌──────────────────────┐
|
||||
│ TradingAgentsGraph │ ← LangGraph StateGraph
|
||||
│ (trading_graph.py) │
|
||||
└──────┬───────────────┘
|
||||
│
|
||||
▼
|
||||
┌───────────────────────────────────────┐
|
||||
│ Researcher Team │
|
||||
│ ┌──────────┐ ┌──────────┐ │
|
||||
│ │ Market │ │ News │ ... │ ← 并行分析
|
||||
│ │ Analyst │ │ Analyst │ │
|
||||
│ └────┬─────┘ └────┬─────┘ │
|
||||
│ │ │ │
|
||||
│ └─────┬──────┘ │
|
||||
│ ▼ │
|
||||
│ Debate Layer (1~N rounds) │ ← 多轮辩论
|
||||
│ │ │
|
||||
│ ▼ │
|
||||
│ Final Decision │
|
||||
│ (Buy/Sell/Hold) │
|
||||
└───────────────────────────────────────┘
|
||||
│
|
||||
▼
|
||||
输出:分析报告 + 交易决策
|
||||
```
|
||||
|
||||
### 3.2 节点说明
|
||||
|
||||
| 节点 | 文件 | 角色 | 使用的工具 |
|
||||
|------|------|------|-----------|
|
||||
| **Market Analyst** | `analysts/market_analyst.py` | 技术面分析师 | `get_stock_data`, `get_indicators` (RSI, MACD, 布林带等 19 项指标) |
|
||||
| **News Analyst** | `analysts/news_analyst.py` | 宏观新闻分析师 | `get_news`, `get_global_news` |
|
||||
| **Social Media Analyst** | `analysts/social_media_analyst.py` | 社交媒体分析师 | `get_news` |
|
||||
| **Fundamentals Analyst** | `analysts/fundamentals_analyst.py` | 基本面分析师 | `get_fundamentals`, `get_balance_sheet`, `get_cashflow`, `get_income_statement` |
|
||||
| **Debate Layer** | `trading_graph.py` | 多智能体辩论 | 各分析师报告交叉辩论 |
|
||||
| **Final Decision** | `trading_graph.py` | 最终交易决策 | 综合所有报告和辩论结果 |
|
||||
|
||||
### 3.3 数据流
|
||||
|
||||
```
|
||||
每个 Analyst 节点
|
||||
│
|
||||
├─ 构造 system prompt + 数据查询指令
|
||||
├─ 通过 LangChain tool 调用 route_to_vendor()
|
||||
├─ route_to_vendor 按优先级选择数据源
|
||||
│ ├─ akshare (默认)
|
||||
│ ├─ yfinance (fallback)
|
||||
│ └─ alpha_vantage (fallback)
|
||||
└─ 返回格式化数据,LLM 生成分析报告
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 四、核心模块
|
||||
|
||||
### 4.1 Graph 编排层
|
||||
|
||||
**文件**: `tradingagents/graph/trading_graph.py`
|
||||
|
||||
- 基于 LangGraph `StateGraph` 构建
|
||||
- `setup_graph()` 按选定的分析师列表动态添加节点
|
||||
- 支持配置 `max_debate_rounds`(默认 1 轮,可多轮辩论)
|
||||
- 输出最终状态和交易决策
|
||||
|
||||
**文件**: `tradingagents/graph/setup.py`
|
||||
|
||||
- 提供 `create_complete_graph()` 工厂函数
|
||||
- 封装完整流程:研究员 → 辩论 → 终判
|
||||
|
||||
### 4.2 工具层
|
||||
|
||||
**文件**: `tradingagents/agents/utils/agent_utils.py`
|
||||
|
||||
- `create_completion()` — LLM 调用封装,支持 reasoning_effort 参数
|
||||
- `ToolKit` — 工具集管理,按分析师类型分发工具
|
||||
|
||||
**工具定义文件**(位于 `agents/utils/`):
|
||||
|
||||
| 文件 | 包含工具 |
|
||||
|------|---------|
|
||||
| `core_stock_tools.py` | `get_stock_data` |
|
||||
| `technical_indicators_tools.py` | `get_indicators` (19 项技术指标) |
|
||||
| `fundamental_data_tools.py` | `get_fundamentals`, `get_balance_sheet`, `get_cashflow`, `get_income_statement` |
|
||||
| `news_data_tools.py` | `get_news`, `get_global_news`, `get_insider_transactions` |
|
||||
|
||||
所有工具统一通过 `route_to_vendor(method, *args)` 调用,实现数据源透明切换。
|
||||
|
||||
### 4.3 数据源层
|
||||
|
||||
**入口**: `tradingagents/dataflows/interface.py`
|
||||
|
||||
```
|
||||
route_to_vendor(method, *args)
|
||||
│
|
||||
├─ 读取 config["data_vendors"] 确定主数据源
|
||||
├─ 按 fallback 链依次尝试:
|
||||
│ ├─ akshare (优先级最高)
|
||||
│ ├─ yfinance
|
||||
│ └─ alpha_vantage
|
||||
└─ 返回第一个成功结果
|
||||
```
|
||||
|
||||
**配置系统**: `tradingagents/dataflows/config.py` + `tradingagents/default_config.py`
|
||||
|
||||
- `default_config.py` 定义全局默认配置
|
||||
- `config.py` 提供运行时 `get_config()` / `set_config()` 接口
|
||||
- 可通过 `set_config({"data_vendors": {"...": "akshare"}})` 动态切换
|
||||
|
||||
### 4.4 Web 服务层
|
||||
|
||||
**文件**: `web_server.py`
|
||||
|
||||
- FastAPI 应用,端口 `8500`
|
||||
- `POST /api/analyze` — 提交分析任务(后台异步执行)
|
||||
- `GET /api/task/{task_id}` — 查询任务状态
|
||||
- `GET /` — 内置 Web 面板(`web.html`)
|
||||
|
||||
---
|
||||
|
||||
## 五、akshare 集成修改(详细改动点)
|
||||
|
||||
### 5.1 修改动机
|
||||
|
||||
原始项目的默认数据源是 `yfinance`,存在以下问题:
|
||||
|
||||
1. **国内访问不稳定**: yfinance 对非美股数据支持有限,频繁触发 Rate Limit
|
||||
2. **A 股数据质量差**: yfinance 的 A 股 OHLCV 数据常常缺失或不准确
|
||||
3. **新闻源偏西式**: yfinance 的新闻来源主要是英文媒体,对 A 股分析不友好
|
||||
4. **无国内数据源**: 缺少针对中国市场的本地化数据适配
|
||||
|
||||
**解决方案**: 集成 **akshare**(国内开源金融数据接口库)作为主数据源,yfinance 降级为 fallback。
|
||||
|
||||
### 5.2 文件变更清单
|
||||
|
||||
| 文件 | 类型 | 行数 | 说明 |
|
||||
|------|------|------|------|
|
||||
| `tradingagents/dataflows/akshare_data.py` | **新增** | 563 | A股/港股/美股行情、财务数据、技术指标适配 |
|
||||
| `tradingagents/dataflows/akshare_news.py` | **新增** | 165 | 个股新闻(东方财富)、全球新闻(CCTV)适配 |
|
||||
| `tradingagents/dataflows/interface.py` | **修改** | +22 | 注册 akshare 到 VENDOR_METHODS,调优 fallback 顺序 |
|
||||
| `tradingagents/default_config.py` | **修改** | +14/-8 | 默认 vendor 改为 akshare |
|
||||
| `web_server.py` | **新增** | 124 | FastAPI Web 服务 + 后台任务 |
|
||||
| `web.html` | **新增** | 480 | 前端分析面板 |
|
||||
|
||||
### 5.3 akshare_data.py 详细设计
|
||||
|
||||
#### 5.3.1 市场检测
|
||||
|
||||
```python
|
||||
def _detect_market(symbol: str) -> str:
|
||||
"""自动识别股票所属市场"""
|
||||
# 6位数字 → A股上海/深圳
|
||||
# 5位数字 → 港股
|
||||
# 字母 → 美股
|
||||
```
|
||||
|
||||
通过 ticker 格式自动路由到正确的 akshare 接口:
|
||||
- `600xxx` / `000xxx` / `300xxx` → A 股(`ak.stock_zh_a_hist`)
|
||||
- `00700` / `09988` → 港股(`ak.stock_hk_hist`)
|
||||
- `AAPL` / `MSFT` / `TSLA` → 美股(`ak.stock_us_hist`)
|
||||
|
||||
#### 5.3.2 实现的接口
|
||||
|
||||
| 接口 | 签名 | akshare 函数 | 说明 |
|
||||
|------|------|-------------|------|
|
||||
| `get_stock_data` | `(symbol, start_date, end_date)` | `stock_zh_a_hist` / `stock_hk_hist` / `stock_us_hist` | 三市场统一 OHLCV 数据 |
|
||||
| `get_indicators` | `(symbol, indicator, curr_date, look_back_days)` | `stock_zh_a_hist` + 手动计算 | 19 项技术指标(RSI/MACD/布林带等) |
|
||||
| `get_fundamentals` | `(ticker, curr_date)` | `stock_individual_info_em` | 公司概况/市盈率/市净率等 |
|
||||
| `get_balance_sheet` | `(ticker, freq, curr_date)` | `stock_balance_sheet_by_report_em` | 资产负债表(年报/季报) |
|
||||
| `get_cashflow` | `(ticker, freq, curr_date)` | `stock_cash_flow_sheet_by_report_em` | 现金流量表 |
|
||||
| `get_income_statement` | `(ticker, freq, curr_date)` | `stock_profit_sheet_by_report_em` | 利润表 |
|
||||
| `get_insider_transactions` | `(ticker)` | — | 抛出异常触发 fallback 到 yfinance |
|
||||
|
||||
#### 5.3.3 技术指标计算实现
|
||||
|
||||
采用**原始公式重算**而非依赖第三方库,确保数据一致性:
|
||||
|
||||
```
|
||||
rsi → 100 - (100 / (1 + RS)) [平均涨跌幅比值法]
|
||||
macd → EMA(12) - EMA(26), Signal=EMA(9) [指数加权移动平均]
|
||||
bb → MA ± 2*STD [布林带]
|
||||
atr → TR 的 Wilder 平滑 [真实波幅]
|
||||
sma_20 → MA(20)
|
||||
ema_20 → EMA(20)
|
||||
```
|
||||
|
||||
共支持 19 项常用技术指标,覆盖趋势类、动量类、波动类、成交量类。
|
||||
|
||||
#### 5.3.4 输出格式
|
||||
|
||||
所有接口返回统一格式:**Pandas DataFrame → Markdown 表格字符串**,与 yfinance 适配器输出格式一致,保证 LLM 可正常解析。
|
||||
|
||||
```markdown
|
||||
| Date | Open | High | Low | Close | Volume |
|
||||
|------------|--------|--------|--------|--------|-----------|
|
||||
| 2026-04-25 | 12.50 | 12.80 | 12.30 | 12.65 | 12345678 |
|
||||
```
|
||||
|
||||
#### 5.3.5 TQDM 噪音抑制
|
||||
|
||||
akshare 内部使用 tqdm 显示进度条,在 LLM 工具调用场景中会产生大量噪音输出。通过在 akshare import 之前设置环境变量解决:
|
||||
|
||||
```python
|
||||
os.environ.setdefault('TQDM_DISABLE', '1')
|
||||
import akshare as ak
|
||||
```
|
||||
|
||||
### 5.4 akshare_news.py 详细设计
|
||||
|
||||
#### 5.4.1 实现的接口
|
||||
|
||||
| 接口 | 说明 | 数据来源 |
|
||||
|------|------|---------|
|
||||
| `get_news(ticker, start_date, end_date)` | 个股新闻 | `ak.stock_news_em`(东方财富) |
|
||||
| `get_global_news(curr_date, look_back_days, limit)` | 宏观/全球新闻 | `ak.news_cctv`(CCTV 新闻联播) |
|
||||
|
||||
#### 5.4.2 Ticker 规范化
|
||||
|
||||
```
|
||||
600362 → 600362 (A股,不变)
|
||||
000001 → 000001 (A股,不变)
|
||||
AAPL → AAPL (美股,不变)
|
||||
→ 回退到原 ticker
|
||||
```
|
||||
|
||||
#### 5.4.3 东方财富新闻接口特点
|
||||
|
||||
- 返回 15 天内个股相关新闻,含标题、发布时间、来源
|
||||
- 自动按日期过滤,限制返回最近 50 条
|
||||
- 格式化输出为 Markdown 表格,便于 LLM 分析
|
||||
|
||||
#### 5.4.4 CCTV 新闻接口特点
|
||||
|
||||
- 获取新闻联播文字稿摘要
|
||||
- 适合宏观政策面分析
|
||||
- 输出为时间线格式的文本列表
|
||||
|
||||
### 5.5 interface.py 修改详情
|
||||
|
||||
#### 5.5.1 VENDOR_METHODS 注册
|
||||
|
||||
为以下 9 个方法注册了 akshare 实现:
|
||||
|
||||
```python
|
||||
VENDOR_METHODS = {
|
||||
"get_stock_data": {"akshare": ..., "yfinance": ..., "alpha_vantage": ...},
|
||||
"get_indicators": {"akshare": ..., "yfinance": ...},
|
||||
"get_fundamentals": {"akshare": ..., "yfinance": ..., "alpha_vantage": ...},
|
||||
"get_balance_sheet": {"akshare": ..., "yfinance": ..., "alpha_vantage": ...},
|
||||
"get_cashflow": {"akshare": ..., "yfinance": ..., "alpha_vantage": ...},
|
||||
"get_income_statement": {"akshare": ..., "yfinance": ..., "alpha_vantage": ...},
|
||||
"get_news": {"akshare": ..., "yfinance": ...},
|
||||
"get_global_news": {"akshare": ..., "yfinance": ...},
|
||||
"get_insider_transactions": {"akshare": ..., "yfinance": ..., "alpha_vantage": ...},
|
||||
}
|
||||
```
|
||||
|
||||
#### 5.5.2 Fallback 顺序优化
|
||||
|
||||
`get_insider_transactions` 的字典键顺序调整为 **akshare → yfinance → alpha_vantage**:
|
||||
|
||||
```
|
||||
原始顺序: alpha_vantage → yfinance → [无 akshare]
|
||||
修改后: akshare → yfinance → alpha_vantage
|
||||
```
|
||||
|
||||
原因:如果 alpha_vantage 排在 yfinance 之前,当 akshare 不支持时,会先尝试 alpha_vantage —— 它的 `get_api_key()` 在无 API key 时会抛出 `ValueError`(非 `AlphaVantageRateLimitError`),导致异常直接传播、不会继续尝试 yfinance。
|
||||
|
||||
调整后 fallback 路径:
|
||||
1. `akshare` → 抛出 `AlphaVantageRateLimitError`(触发 fallback)
|
||||
2. `yfinance` → 获取数据(成功)✓
|
||||
|
||||
#### 5.5.3 数据源分类优化
|
||||
|
||||
将 akshare 明确归入 `all_available_vendors`,确保它在所有 `data_vendors` 分类组中可用:
|
||||
|
||||
```python
|
||||
all_available_vendors = ["akshare", "yfinance", "alpha_vantage"]
|
||||
```
|
||||
|
||||
### 5.6 default_config.py 修改
|
||||
|
||||
```python
|
||||
# 修改前
|
||||
"data_vendors": {
|
||||
"core_stock_data": {"primary": "yfinance"},
|
||||
"technical_indicators": {"primary": "yfinance"},
|
||||
"fundamental_data": {"primary": "yfinance"},
|
||||
"news_data": {"primary": "yfinance"},
|
||||
}
|
||||
|
||||
# 修改后
|
||||
"data_vendors": {
|
||||
"core_stock_data": {"primary": "akshare"},
|
||||
"technical_indicators": {"primary": "akshare"},
|
||||
"fundamental_data": {"primary": "akshare"},
|
||||
"news_data": {"primary": "akshare"},
|
||||
}
|
||||
```
|
||||
|
||||
效果:所有分析请求默认走 akshare,彻底避免 yfinance Rate Limit 问题。
|
||||
|
||||
### 5.7 web_server.py 设计
|
||||
|
||||
#### 5.7.1 API 端点
|
||||
|
||||
| 方法 | 路径 | 说明 |
|
||||
|------|------|------|
|
||||
| GET | `/` | Web 分析面板(`web.html`) |
|
||||
| GET | `/api/health` | 健康检查 |
|
||||
| POST | `/api/analyze` | 提交分析任务,返回 task_id |
|
||||
| GET | `/api/task/{task_id}` | 查询任务状态和结果 |
|
||||
|
||||
#### 5.7.2 异步任务机制
|
||||
|
||||
```python
|
||||
class AnalysisRequest(BaseModel):
|
||||
ticker: str # 股票代码
|
||||
date: Optional[str] # 分析日期,默认今天
|
||||
analysts: Optional[list] # 分析师列表,默认 ["market", "news"]
|
||||
max_debate_rounds: int # 辩论轮次,默认 1
|
||||
```
|
||||
|
||||
分析流程在 `BackgroundTasks` 中异步执行,通过线程安全的 `tasks_store` 字典管理任务状态。
|
||||
|
||||
### 5.8 web.html 设计
|
||||
|
||||
- 纯原生 HTML/CSS/JS 单页应用
|
||||
- 响应式设计,支持移动端
|
||||
- 输入框:股票代码 + 日期 + 分析师选择 + 辩论轮次
|
||||
- 实时轮询任务状态(每 3 秒)
|
||||
- 结果展示:Markdown 渲染的交易决策和分析报告(使用 marked.js)
|
||||
- 适配 DeepSeek 推理过程的 `reasoning_content` 展示
|
||||
|
||||
---
|
||||
|
||||
## 六、部署架构
|
||||
|
||||
```
|
||||
http://129.211.173.87:8500/
|
||||
│
|
||||
┌────────┴────────┐
|
||||
│ web_server.py │
|
||||
│ (FastAPI) │
|
||||
│ port :8500 │
|
||||
└────────┬────────┘
|
||||
│
|
||||
┌────────┴────────┐
|
||||
│ TradingAgents │
|
||||
│ Graph │
|
||||
│ (LangGraph) │
|
||||
└──────┬─────────┘
|
||||
│
|
||||
┌───────────┼───────────┐
|
||||
▼ ▼ ▼
|
||||
┌─────────┐ ┌─────────┐ ┌─────────┐
|
||||
│ akshare │ │yfinance │ │ alpha │
|
||||
│ (主要) │ │(备用1) │ │vantage │
|
||||
└─────────┘ └─────────┘ └─────────┘
|
||||
```
|
||||
|
||||
- **进程管理**: systemd `tradingagents.service`
|
||||
- **LLM 后端**: DeepSeek(通过 `DEEPSEEK_API_KEY` 环境变量)
|
||||
- **数据源**: akshare(默认,国内数据丰富)+ yfinance(fallback,美股内部交易等场景)
|
||||
|
||||
---
|
||||
|
||||
## 七、修改前后对比
|
||||
|
||||
| 维度 | 修改前 | 修改后 |
|
||||
|------|--------|--------|
|
||||
| **默认数据源** | yfinance | **akshare** |
|
||||
| **A 股行情** | 不稳定,频繁 Rate Limit | ✅ 稳定,无限制 |
|
||||
| **A 股财务数据** | ❌ 不可用 | ✅ 完整(资产负债表/利润表/现金流) |
|
||||
| **技术指标** | 依赖 yfinance 返回 | ✅ 原始公式重算,19 项指标 |
|
||||
| **个股新闻** | 英文来源,A 股覆盖差 | ✅ 东方财富,中文,时效性强 |
|
||||
| **宏观新闻** | 英文来源 | ✅ CCTV 新闻联播,政策面 |
|
||||
| **港股支持** | 部分 | ✅ 完整 |
|
||||
| **Rate Limit** | 频繁触发 | ✅ 已消除 |
|
||||
| **内部交易** | yfinance | akshare 自动 fallback 到 yfinance |
|
||||
| **Web UI** | ❌ 无 | ✅ 新增 FastAPI + Web 面板 |
|
||||
| **任务异步** | ❌ 无 | ✅ 后台任务 + 状态查询 |
|
||||
| **TQDM 噪音** | — | ✅ 已抑制 |
|
||||
|
||||
---
|
||||
|
||||
## 八、项目目录结构
|
||||
|
||||
```
|
||||
TradingAgents/
|
||||
├── tradingagents/
|
||||
│ ├── agents/
|
||||
│ │ ├── analysts/ # 四个分析师角色
|
||||
│ │ │ ├── fundamentals_analyst.py
|
||||
│ │ │ ├── market_analyst.py
|
||||
│ │ │ ├── news_analyst.py
|
||||
│ │ │ └── social_media_analyst.py
|
||||
│ │ └── utils/ # 工具定义和 LLM 封装
|
||||
│ │ ├── agent_utils.py # LLM 调用 + ToolKit
|
||||
│ │ ├── core_stock_tools.py # get_stock_data
|
||||
│ │ ├── technical_indicators_tools.py # get_indicators
|
||||
│ │ ├── fundamental_data_tools.py # 财务分析工具
|
||||
│ │ └── news_data_tools.py # 新闻工具
|
||||
│ ├── dataflows/ # 数据源层
|
||||
│ │ ├── interface.py # 路由分发 + VENDOR_METHODS
|
||||
│ │ ├── config.py # 运行时配置
|
||||
│ │ ├── akshare_data.py # 🆕 akshare 行情+财务适配
|
||||
│ │ ├── akshare_news.py # 🆕 akshare 新闻适配
|
||||
│ │ ├── yfinance_news.py # yfinance 新闻
|
||||
│ │ ├── y_finance.py # yfinance 行情
|
||||
│ │ └── alpha_vantage*.py # Alpha Vantage 适配
|
||||
│ ├── graph/ # LangGraph 编排
|
||||
│ │ ├── trading_graph.py # 主图定义
|
||||
│ │ └── setup.py # 图工厂
|
||||
│ └── default_config.py # 默认配置(已改为 akshare)
|
||||
├── docs/ # 文档
|
||||
│ ├── architecture-and-modifications.md # 🆕 本文档
|
||||
│ └── ...
|
||||
├── web_server.py # 🆕 FastAPI Web 服务
|
||||
├── web.html # 🆕 前端面板
|
||||
└── pyproject.toml # 依赖管理
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 九、关键代码路径
|
||||
|
||||
| 功能 | 起点 | 链路 |
|
||||
|------|------|------|
|
||||
| 用户提交分析 | `web_server.py:94 POST /api/analyze` | → `run_analysis_task` → `TradingAgentsGraph.propagate()` |
|
||||
| 获取行情数据 | `core_stock_tools.py:get_stock_data` | → `route_to_vendor("get_stock_data", ...)` → `akshare_data.get_stock_data()` |
|
||||
| 获取技术指标 | `technical_indicators_tools.py:get_indicators` | → `route_to_vendor` → `akshare_data.get_indicators()` |
|
||||
| 获取财务数据 | `fundamental_data_tools.py:get_fundamentals` | → `route_to_vendor` → `akshare_data.get_fundamentals()` |
|
||||
| 获取新闻 | `news_data_tools.py:get_news` | → `route_to_vendor` → `akshare_news.get_news()` |
|
||||
| 数据源切换 | `interface.py:route_to_vendor` | 按 config → fallback 链尝试 |
|
||||
@@ -0,0 +1,148 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate TradingAgents workflow diagrams for the analysis document."""
|
||||
import sys, os
|
||||
sys.path.insert(0, '/home/ubuntu/.nanobot/workspace/skills/hand-drawn-diagram')
|
||||
from generator import DiagramGenerator, Component, Connection, Container
|
||||
|
||||
DOCS = '/home/ubuntu/nanocode/TradingAgents/docs'
|
||||
|
||||
# ──────────────────────────────────────────────────────────────────
|
||||
# Diagram 1: High-level pipeline flowchart
|
||||
# ──────────────────────────────────────────────────────────────────
|
||||
gen1 = DiagramGenerator(style="sketch")
|
||||
|
||||
steps = [
|
||||
{"type": "start", "label": "用户输入\n股票代码 + 日期"},
|
||||
{"type": "process", "label": "并行数据采集\n(4个分析师同时工作)"},
|
||||
{"type": "process", "label": "研究经理汇总\n收集4份分析报告"},
|
||||
{"type": "decision", "label": "多空辩论\nBull vs Bear × N轮"},
|
||||
{"type": "process", "label": "交易员决策\n综合辩论形成草案"},
|
||||
{"type": "decision", "label": "三级风控评审\n激进/保守/中立"},
|
||||
{"type": "end", "label": "最终输出\nBuy / Sell / Hold"},
|
||||
]
|
||||
|
||||
gen1.create_flowchart(
|
||||
title="TradingAgents 单次股票分析流程",
|
||||
steps=steps,
|
||||
output=f"{DOCS}/workflow-pipeline.html",
|
||||
)
|
||||
|
||||
print(f"✅ 1. Pipeline flowchart: {DOCS}/workflow-pipeline.html")
|
||||
|
||||
# ──────────────────────────────────────────────────────────────────
|
||||
# Diagram 2: Detailed architecture with data flows
|
||||
# ──────────────────────────────────────────────────────────────────
|
||||
W, H = 1300, 1200
|
||||
gen2 = DiagramGenerator(style="sketch")
|
||||
|
||||
# --- Component definitions ---
|
||||
center = W // 2
|
||||
|
||||
# Row 1: Input layer
|
||||
user = Component("用户浏览器", "cloud", center-70, 20, 140, 45, "cloud")
|
||||
|
||||
# Row 2: Web server
|
||||
web_srv = Component("Web Server (FastAPI)\n后台异步分析任务", "frontend", center-95, 95, 190, 55)
|
||||
|
||||
# Row 3: LangGraph
|
||||
graph = Component("TradingAgents Graph\n(LangGraph StateGraph)", "backend", center-105, 185, 210, 55, "hexagon")
|
||||
|
||||
# Row 4: Four analysts + manager (parallel)
|
||||
mkt = Component("市场分析师\n行情+技术指标", "backend", 50, 310, 150, 60)
|
||||
snt = Component("社媒分析师\n舆论情绪", "backend", 240, 310, 140, 60)
|
||||
nws = Component("新闻分析师\n个股+宏观新闻", "backend", 420, 310, 150, 60)
|
||||
fnd = Component("基本面分析师\n三表+估值", "backend", 610, 310, 150, 60)
|
||||
mgr = Component("研究经理\n汇总4份报告", "security", 810, 310, 140, 60)
|
||||
|
||||
# Row 5: Debate agents
|
||||
bull = Component("Bull 多头\n研究员", "frontend", 230, 440, 140, 50)
|
||||
bear = Component("Bear 空头\n研究员", "security", 420, 440, 140, 50)
|
||||
dbj = Component("辩论裁判\n评估论据", "backend", 610, 440, 140, 50)
|
||||
|
||||
# Row 6: Trader
|
||||
trader = Component("Trader 交易员\n综合辩论→决策草案", "backend", center-105, 560, 210, 55, "hexagon")
|
||||
|
||||
# Row 7: Risk management trio
|
||||
agg = Component("Aggressive\n激进风控", "frontend", 190, 680, 140, 55)
|
||||
con = Component("Conservative\n保守风控", "security", 390, 680, 145, 55)
|
||||
neu = Component("Neutral\n中立风控", "backend", 590, 680, 140, 55)
|
||||
rsk = Component("Risk Judge\n风控终审", "security", 800, 680, 140, 55)
|
||||
|
||||
# Row 8: Final output
|
||||
output = Component("输出结果\n分析报告 + 交易信号", "cloud", center-110, 800, 220, 55, "cloud")
|
||||
|
||||
# Row 9: Data sources
|
||||
ak = Component("akshare 主数据源\nA股/港股/美股/新闻", "database", 80, 930, 185, 55)
|
||||
yf = Component("yfinance 备用1\n美股+内部交易", "database", 320, 930, 165, 55)
|
||||
av = Component("Alpha Vantage 备用2\n美国市场备选", "database", 540, 930, 165, 55)
|
||||
llm = Component("DeepSeek LLM\n推理引擎", "database", 780, 930, 155, 55)
|
||||
|
||||
components = [user, web_srv, graph,
|
||||
mkt, snt, nws, fnd, mgr,
|
||||
bull, bear, dbj,
|
||||
trader,
|
||||
agg, con, neu, rsk,
|
||||
output,
|
||||
ak, yf, av, llm]
|
||||
|
||||
# --- Connections ---
|
||||
connections = [
|
||||
Connection("用户浏览器", "Web Server (FastAPI)\n后台异步分析任务", "solid", "POST /api/analyze", "#22d3ee"),
|
||||
Connection("Web Server (FastAPI)\n后台异步分析任务", "TradingAgents Graph\n(LangGraph StateGraph)", "solid", "启动分析", "#22d3ee"),
|
||||
# Graph → 4 analysts
|
||||
Connection("TradingAgents Graph\n(LangGraph StateGraph)", "市场分析师\n行情+技术指标", "dashed", "分发", "#fbbf24"),
|
||||
Connection("TradingAgents Graph\n(LangGraph StateGraph)", "社媒分析师\n舆论情绪", "dashed", "分发", "#fbbf24"),
|
||||
Connection("TradingAgents Graph\n(LangGraph StateGraph)", "新闻分析师\n个股+宏观新闻", "dashed", "分发", "#fbbf24"),
|
||||
Connection("TradingAgents Graph\n(LangGraph StateGraph)", "基本面分析师\n三表+估值", "dashed", "分发", "#fbbf24"),
|
||||
# Analysts → Manager
|
||||
Connection("市场分析师\n行情+技术指标", "研究经理\n汇总4份报告", "solid", "报告", "#34d399"),
|
||||
Connection("社媒分析师\n舆论情绪", "研究经理\n汇总4份报告", "solid", "报告", "#34d399"),
|
||||
Connection("新闻分析师\n个股+宏观新闻", "研究经理\n汇总4份报告", "solid", "报告", "#34d399"),
|
||||
Connection("基本面分析师\n三表+估值", "研究经理\n汇总4份报告", "solid", "报告", "#34d399"),
|
||||
# Manager → Debate
|
||||
Connection("研究经理\n汇总4份报告", "Bull 多头\n研究员", "solid", "启动辩论", "#a78bfa"),
|
||||
Connection("研究经理\n汇总4份报告", "Bear 空头\n研究员", "solid", "启动辩论", "#a78bfa"),
|
||||
Connection("Bull 多头\n研究员", "辩论裁判\n评估论据", "solid", "多方论据", "#f87171"),
|
||||
Connection("Bear 空头\n研究员", "辩论裁判\n评估论据", "solid", "空方论据", "#f87171"),
|
||||
# Judge → Trader
|
||||
Connection("辩论裁判\n评估论据", "Trader 交易员\n综合辩论→决策草案", "solid", "辩论摘要", "#fb923c"),
|
||||
# Trader → Risk
|
||||
Connection("Trader 交易员\n综合辩论→决策草案", "Aggressive\n激进风控", "dashed", "草案", "#38bdf8"),
|
||||
Connection("Trader 交易员\n综合辩论→决策草案", "Conservative\n保守风控", "dashed", "草案", "#38bdf8"),
|
||||
Connection("Trader 交易员\n综合辩论→决策草案", "Neutral\n中立风控", "dashed", "草案", "#38bdf8"),
|
||||
# Risk → Judge
|
||||
Connection("Aggressive\n激进风控", "Risk Judge\n风控终审", "solid", "评估", "#34d399"),
|
||||
Connection("Conservative\n保守风控", "Risk Judge\n风控终审", "solid", "评估", "#34d399"),
|
||||
Connection("Neutral\n中立风控", "Risk Judge\n风控终审", "solid", "评估", "#34d399"),
|
||||
# Final
|
||||
Connection("Risk Judge\n风控终审", "输出结果\n分析报告 + 交易信号", "solid", "最终决策", "#22d3ee"),
|
||||
# Data source connections
|
||||
Connection("市场分析师\n行情+技术指标", "akshare 主数据源\nA股/港股/美股/新闻", "dashed", "数据", "#94a3b8"),
|
||||
Connection("基本面分析师\n三表+估值", "akshare 主数据源\nA股/港股/美股/新闻", "dashed", "数据", "#94a3b8"),
|
||||
Connection("新闻分析师\n个股+宏观新闻", "akshare 主数据源\nA股/港股/美股/新闻", "dashed", "数据", "#94a3b8"),
|
||||
Connection("akshare 主数据源\nA股/港股/美股/新闻", "yfinance 备用1\n美股+内部交易", "dashed", "fallback", "#64748b"),
|
||||
Connection("yfinance 备用1\n美股+内部交易", "Alpha Vantage 备用2\n美国市场备选", "dashed", "fallback", "#64748b"),
|
||||
Connection("Bull 多头\n研究员", "DeepSeek LLM\n推理引擎", "dashed", "推理", "#94a3b8"),
|
||||
Connection("Bear 空头\n研究员", "DeepSeek LLM\n推理引擎", "dashed", "推理", "#94a3b8"),
|
||||
]
|
||||
|
||||
# --- Container groups ---
|
||||
containers = [
|
||||
Container("分析师团队 (并行)", 20, 285, 960, 110, "#fbbf24"),
|
||||
Container("多空辩论 (可多轮)", 200, 415, 580, 100, "#a78bfa"),
|
||||
Container("三级风控", 150, 655, 820, 105, "#f87171"),
|
||||
Container("数据源层", 50, 905, 950, 105, "#64748b"),
|
||||
]
|
||||
|
||||
# --- Generate ---
|
||||
gen2.create_architecture(
|
||||
title="TradingAgents 详细架构与数据流",
|
||||
components=components,
|
||||
connections=connections,
|
||||
output=f"{DOCS}/workflow-architecture",
|
||||
containers=containers,
|
||||
auto_layout=False,
|
||||
)
|
||||
|
||||
print(f"✅ 2. Architecture diagram: {DOCS}/workflow-architecture.html")
|
||||
print("\nDone!")
|
||||
@@ -0,0 +1,480 @@
|
||||
# TradingAgents 股票分析工作流程详解
|
||||
|
||||
> **文档时间**: 2026-05-05
|
||||
> **相关文档**: [技术架构分析](./architecture-and-modifications.md)
|
||||
> **配套图表**: [流程图](workflow-pipeline.html) | [架构图](workflow-architecture.html)
|
||||
|
||||
---
|
||||
|
||||
## 一、一次分析的完整生命周期
|
||||
|
||||
当用户在 Web UI 输入 `600362` 并点击"分析",系统会经历以下完整流程:
|
||||
|
||||
```
|
||||
用户点击 [分析] → 后台异步任务 → 约 3-8 分钟后 → 输出交易决策
|
||||
```
|
||||
|
||||
整个流程由 **LangGraph StateGraph** 驱动,状态在 15+ 个节点间流转。下面按执行顺序逐步拆解。
|
||||
|
||||
---
|
||||
|
||||
## 二、流程图
|
||||
|
||||

|
||||
|
||||
> 详细架构图: [workflow-architecture.html](workflow-architecture.html)
|
||||
|
||||
---
|
||||
|
||||
## 三、分阶段详解
|
||||
|
||||
### 阶段 1:请求接收与任务创建
|
||||
|
||||
**入口**: `web_server.py` → `POST /api/analyze`
|
||||
|
||||
```
|
||||
用户输入: { ticker: "600362", date: "2026-04-30", analysts: [...], max_debate_rounds: 1 }
|
||||
```
|
||||
|
||||
1. 生成唯一的 `task_id`(格式: `600362_20260505191807`)
|
||||
2. 创建任务记录写入 `tasks_store`(内存字典)
|
||||
3. 通过 FastAPI `BackgroundTasks` 异步启动 `run_analysis_task()`
|
||||
4. 立即返回 `{"task_id": "...", "status": "pending"}`
|
||||
5. 前端每 3 秒轮询 `GET /api/task/{task_id}` 获取进度
|
||||
|
||||
### 阶段 2:Graph 初始化
|
||||
|
||||
**文件**: `tradingagents/graph/trading_graph.py` → `TradingAgentsGraph.propagate()`
|
||||
|
||||
```python
|
||||
# 1. 读取配置
|
||||
config = get_config() # 默认 vendor: akshare
|
||||
llm_name = config["llm_provider"] # DeepSeek
|
||||
|
||||
# 2. 初始化 LangGraph StateGraph
|
||||
workflow = StateGraph(AgentState)
|
||||
|
||||
# 3. 按用户选择的分析师类型动态添加节点
|
||||
# 可选: market, sentiment, news, fundamentals
|
||||
# 默认: market + news
|
||||
```
|
||||
|
||||
`AgentState` 中关键字段:
|
||||
|
||||
| 字段 | 初始值 | 说明 |
|
||||
|------|--------|------|
|
||||
| `messages` | `[]` | 全流程消息日志 |
|
||||
| `ticker` | `"600362"` | 股票代码 |
|
||||
| `trade_date` | `"2026-04-30"` | 分析日期 |
|
||||
| `company_name` | `""` | 公司名称(初始为空) |
|
||||
| `market_report` | `""` | 市场分析报告 |
|
||||
| `sentiment_report` | `""` | 情绪分析报告 |
|
||||
| `news_report` | `""` | 新闻分析报告 |
|
||||
| `fundamentals_report` | `""` | 基本面报告 |
|
||||
| `investment_plan` | `""` | 投资决策草案 |
|
||||
| `final_decision` | `""` | 最终交易信号 |
|
||||
| `current_debate_round` | `0` | 当前辩论轮次 |
|
||||
|
||||
### 阶段 3:并行分析师采集(核心环节)
|
||||
|
||||
这是整个流程中**数据量最大、耗时最长**的阶段。四个分析师节点通过 LangGraph 的并行边**同时启动**。
|
||||
|
||||
#### 3.1 市场分析师 (Market Analyst)
|
||||
|
||||
**文件**: `tradingagents/agents/analysts/market_analyst.py`
|
||||
|
||||
**角色定位**: 技术面专家
|
||||
|
||||
**System Prompt 核心**:
|
||||
> "You are a trading assistant agent with extensive market insight. Your task is to analyze market data using technical indicators."
|
||||
|
||||
**执行的工具调用**:
|
||||
|
||||
```
|
||||
1. get_stock_data("600362", "2026-03-30", "2026-04-30")
|
||||
→ 路线: route_to_vendor → akshare_data.get_stock_data()
|
||||
→ 输出: 最近一个月 OHLCV 数据(~22条日K线)
|
||||
|
||||
2. get_indicators("600362", "rsi", "2026-04-30", 30)
|
||||
3. get_indicators("600362", "macd", "2026-04-30", 30)
|
||||
4. get_indicators("600362", "bollinger_bands", "2026-04-30", 30)
|
||||
5. get_indicators("600362", "volume", "2026-04-30", 30)
|
||||
... (最多调用 19 项技术指标中的 5-8 项关键指标)
|
||||
```
|
||||
|
||||
**指标清单**(akshare_data.py 支持的全部 19 项):
|
||||
|
||||
| 类别 | 指标 |
|
||||
|------|------|
|
||||
| 趋势类 | sma_20, ema_20, macd, adx |
|
||||
| 动量类 | rsi, stochastic_oscillator, williams_r, cci |
|
||||
| 波动类 | bollinger_bands, atr, standard_deviation |
|
||||
| 成交量类 | obv, volume, volume_sma |
|
||||
| 其他 | mfi, ppo, roc, triple_ema, vortex |
|
||||
|
||||
**输出**: 一份 800-1500 字的 Markdown 技术分析报告,含关键指标解读和趋势判断。
|
||||
|
||||
#### 3.2 社交媒体分析师 (Social Media Analyst)
|
||||
|
||||
**文件**: `tradingagents/agents/analysts/social_media_analyst.py`
|
||||
|
||||
**角色定位**: 市场情绪雷达
|
||||
|
||||
**执行的工具调用**:
|
||||
|
||||
```
|
||||
1. get_news("600362", "2026-04-01", "2026-05-04")
|
||||
→ 路线: route_to_vendor → akshare_news.get_news()
|
||||
→ 数据源: 东方财富个股新闻
|
||||
→ 输出: 最近 15 天内与该股相关的新闻(最多50条)
|
||||
```
|
||||
|
||||
**输出**: 一份舆情分析报告,提炼市场情绪信号(恐慌/贪婪/中性)。
|
||||
|
||||
#### 3.3 新闻分析师 (News Analyst)
|
||||
|
||||
**文件**: `tradingagents/agents/analysts/news_analyst.py`
|
||||
|
||||
**角色定位**: 宏观政策雷达
|
||||
|
||||
**System Prompt 核心**:
|
||||
> "You are a news analyst agent with expertise in global macro trends. Your task is to analyze news related to the company and the broader economic landscape."
|
||||
|
||||
**执行的工具调用**:
|
||||
|
||||
```
|
||||
1. get_news("600362", "2026-04-01", "2026-05-04")
|
||||
→ 与社媒分析师相同的数据源,但解读角度不同
|
||||
|
||||
2. get_global_news("2026-05-04", look_back_days=7, limit=20)
|
||||
→ 路线: route_to_vendor → akshare_news.get_global_news()
|
||||
→ 数据源: CCTV 新闻联播文字稿
|
||||
→ 输出: 宏观政策、经济事件摘要
|
||||
```
|
||||
|
||||
**输出**: 一份包含个股新闻分析和宏观经济背景的综合报告。
|
||||
|
||||
#### 3.4 基本面分析师 (Fundamentals Analyst)
|
||||
|
||||
**文件**: `tradingagents/agents/analysts/fundamentals_analyst.py`
|
||||
|
||||
**角色定位**: 价值投资者
|
||||
|
||||
**System Prompt 核心**:
|
||||
> "You are a fundamental analysis expert with deep knowledge of valuation methodologies. Your task is to analyze company fundamentals and financial health."
|
||||
|
||||
**执行的工具调用** (共 4 次):
|
||||
|
||||
```
|
||||
1. get_fundamentals("600362")
|
||||
→ 数据: 公司概况、市盈率、市净率、总市值、流通股本等
|
||||
|
||||
2. get_balance_sheet("600362")
|
||||
→ 数据: 最新一期资产负债表(总资产/负债/权益)
|
||||
|
||||
3. get_cashflow("600362")
|
||||
→ 数据: 最新一期现金流量表(经营/投资/筹资现金流)
|
||||
|
||||
4. get_income_statement("600362")
|
||||
→ 数据: 最新一期利润表(营收/成本/净利润/每股收益)
|
||||
```
|
||||
|
||||
**输出**: 一份包含估值分析、财务健康度评分、盈利能力判断的基本面报告。
|
||||
|
||||
### 阶段 4:研究经理汇总
|
||||
|
||||
**文件**: `tradingagents/graph/trading_graph.py` → `create_research_manager_node()`
|
||||
|
||||
```
|
||||
输入: 4份分析师报告(并行采集完成后的汇总)
|
||||
处理: 研究经理 LLM 阅读所有报告,提取关键矛盾点
|
||||
输出: 投资者简报 (investment briefing)
|
||||
```
|
||||
|
||||
研究经理不产生独立决策,而是**整理和总结**分析师团队输出的核心信息,为下一阶段的辩论做准备。
|
||||
|
||||
### 阶段 5:多空辩论 (Debate)
|
||||
|
||||
**文件**: `tradingagents/graph/trading_graph.py` → `create_debate_node()` + `debate_bull_researcher()` + `debate_bear_researcher()`
|
||||
|
||||
这是框架的**核心创新**:用 LLM 模拟真实投资决策中的多空辩论。
|
||||
|
||||
#### 辩论角色
|
||||
|
||||
| 角色 | 文件 | 立场 | 职责 |
|
||||
|------|------|------|------|
|
||||
| **Bull Researcher** | `agents/researchers/bull_researcher.py` | 多头 | 找出所有支撑买入的论据 |
|
||||
| **Bear Researcher** | `agents/researchers/bear_researcher.py` | 空头 | 找出所有支撑卖出的论据 |
|
||||
| **Debate Judge** | `agents/managers/research_manager.py` | 裁判 | 评估双方论据,判断胜负 |
|
||||
|
||||
#### 辩论流程
|
||||
|
||||
```
|
||||
轮次 1:
|
||||
Bull → 提出 3-5 个多方论点(基于分析师报告)
|
||||
Bear → 反驳多方论点 + 提出 3-5 个空方论点
|
||||
Judge → 评估双方论据质量,判断本轮是否分出胜负
|
||||
|
||||
轮次 2 (如果裁判认为需要继续):
|
||||
Bull → 回应空方反驳 + 补充新论点
|
||||
Bear → 回应多方回应 + 强化空方论点
|
||||
Judge → 再次评估
|
||||
|
||||
... 直到 max_debate_rounds 耗尽或裁判判定胜负
|
||||
```
|
||||
|
||||
**关键**: `max_debate_rounds` 在配置中可调,默认 **1 轮**。每增加一轮,LLM 调用次数翻倍,总耗时显著增长。
|
||||
|
||||
#### 辩论输出
|
||||
|
||||
- 辩论完整记录(谁说了什么)
|
||||
- 裁判的最终评估(多方胜/空方胜/平局)
|
||||
|
||||
### 阶段 6:交易员决策
|
||||
|
||||
**文件**: `tradingagents/agents/trader/trader_agent.py`
|
||||
|
||||
**System Prompt 核心**:
|
||||
> "You are a professional trader agent. Based on the analysts' reports and debate results, make a trading decision."
|
||||
|
||||
**输入**:
|
||||
- 4 份分析师报告
|
||||
- 辩论摘要(裁判评估)
|
||||
|
||||
**处理**: 交易员 LLM 综合所有证据,形成投资决策草案
|
||||
|
||||
**输出**: `investment_plan` — 包含:
|
||||
- 决策方向(Buy/Sell/Hold)
|
||||
- 置信度评估
|
||||
- 关键依据
|
||||
- 风险提示
|
||||
|
||||
### 阶段 7:三级风控评审
|
||||
|
||||
**文件**: `tradingagents/graph/trading_graph.py` → `create_risk_analysis_node()` + 三个风控 agent
|
||||
|
||||
这是项目的**第二道安全阀**:交易员的决策必须通过风控审查。
|
||||
|
||||
| 风控角色 | 文件 | 风格 | 关注点 |
|
||||
|----------|------|------|--------|
|
||||
| **Aggressive** | `agents/risk_mgmt/aggressive_debator.py` | 激进 | 机会最大化,风险容忍度较高 |
|
||||
| **Conservative** | `agents/risk_mgmt/conservative_debator.py` | 保守 | 本金安全第一,宁可错过不做错 |
|
||||
| **Neutral** | `agents/risk_mgmt/neutral_debator.py` | 中立 | 平衡收益与风险 |
|
||||
|
||||
#### 流程
|
||||
|
||||
```
|
||||
交易员输出投资草案
|
||||
│
|
||||
├→ Aggressive 评估 → "风险可接受,建议执行"
|
||||
├→ Conservative 评估 → "风险过高,建议降低仓位"
|
||||
└→ Neutral 评估 → "风险适中,可执行但需设置止损"
|
||||
│
|
||||
└→ Risk Judge 汇总三个评估 → 最终裁定
|
||||
```
|
||||
|
||||
**Risk Judge** 文件: `tradingagents/agents/managers/risk_manager.py` — 综合三方意见,给出最终风控建议。
|
||||
|
||||
**注意**: 风控评审是一个循环 — 如果 `final_decision` 为空(未达成一致),图会回到交易员节点重新决策。
|
||||
|
||||
### 阶段 8:最终输出
|
||||
|
||||
经过以上所有阶段后,系统输出:
|
||||
|
||||
```python
|
||||
{
|
||||
"ticker": "600362",
|
||||
"date": "2026-04-30",
|
||||
"company_name": "江西铜业",
|
||||
"market_report": "...", # 技术分析报告
|
||||
"sentiment_report": "...", # 情绪分析报告
|
||||
"news_report": "...", # 新闻分析报告
|
||||
"fundamentals_report": "...", # 基本面报告
|
||||
"investment_plan": "...", # 交易决策草案
|
||||
"debate_log": "...", # 辩论记录
|
||||
"final_decision": "BUY", # 最终交易信号: BUY / SELL / HOLD
|
||||
"risk_assessment": "...", # 风控评估
|
||||
"messages": [...] # 全流程消息日志
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 四、完整节点流转图(Graph 内部)
|
||||
|
||||
```
|
||||
┌──────────────┐
|
||||
│ START │
|
||||
└──────┬───────┘
|
||||
│
|
||||
┌────────────────┼────────────────┐
|
||||
▼ ▼ ▼ ▼
|
||||
┌────────────┐ ┌────────────┐ ┌────────────┐ ┌────────────┐
|
||||
│mkt_start │ │snt_start │ │nws_start │ │fnd_start │
|
||||
└─────┬──────┘ └─────┬──────┘ └─────┬──────┘ └─────┬──────┘
|
||||
▼ ▼ ▼ ▼
|
||||
┌────────────┐ ┌────────────┐ ┌────────────┐ ┌────────────┐
|
||||
│mkt_analyst │ │snt_analyst │ │nws_analyst │ │fnd_analyst │
|
||||
│(LLM分析) │ │(LLM分析) │ │(LLM分析) │ │(LLM分析) │
|
||||
└─────┬──────┘ └─────┬──────┘ └─────┬──────┘ └─────┬──────┘
|
||||
▼ ▼ ▼ ▼
|
||||
┌────────────┐ ┌────────────┐ ┌────────────┐ ┌────────────┐
|
||||
│mkt_tools │ │snt_tools │ │nws_tools │ │fnd_tools │
|
||||
│(调用数据) │ │(调用数据) │ │(调用数据) │ │(调用数据) │
|
||||
└─────┬──────┘ └─────┬──────┘ └─────┬──────┘ └─────┬──────┘
|
||||
▼ ▼ ▼ ▼
|
||||
┌────────────┐ ┌────────────┐ ┌────────────┐ ┌────────────┐
|
||||
│mkt_cond │ │snt_cond │ │nws_cond │ │fnd_cond │
|
||||
│(if 需继续) │ │(if 需继续) │ │(if 需继续) │ │(if 需继续) │
|
||||
└─────┬──────┘ └─────┬──────┘ └─────┬──────┘ └─────┬──────┘
|
||||
│ │ │ │
|
||||
└────────────────┼────────────────┼────────────────┘
|
||||
▼
|
||||
┌──────────────┐
|
||||
│ invest_judge │ (研究经理汇总)
|
||||
└──────┬───────┘
|
||||
│
|
||||
┌───────────┴───────────┐
|
||||
▼ ▼
|
||||
┌────────────┐ ┌────────────┐
|
||||
│bull_resrch │ │bear_resrch │
|
||||
│(多方) │ │(空方) │
|
||||
└─────┬──────┘ └─────┬──────┘
|
||||
│ │
|
||||
└──────────┬───────────┘
|
||||
▼
|
||||
┌──────────────┐
|
||||
│ invest_judge │ (辩论裁判评估)
|
||||
└──────┬───────┘
|
||||
│ (if 辩论未结束 → 回到 bull/bear)
|
||||
▼
|
||||
┌──────────────┐
|
||||
│ trader │ (交易员决策)
|
||||
└──────┬───────┘
|
||||
▼
|
||||
┌──────────────┐
|
||||
│trader_tools │ (可能需要查询数据)
|
||||
└──────┬───────┘
|
||||
│
|
||||
┌──────────────┼──────────────┐
|
||||
▼ ▼ ▼
|
||||
┌──────────┐ ┌──────────────┐ ┌──────────┐
|
||||
│aggressive│ │conservative │ │ neutral │
|
||||
│ 风控 │ │ 风控 │ │ 风控 │
|
||||
└────┬─────┘ └──────┬───────┘ └────┬─────┘
|
||||
│ │ │
|
||||
└────────────────┼────────────────┘
|
||||
▼
|
||||
┌──────────────┐
|
||||
│ risk_judge │ (风控终审)
|
||||
└──────┬───────┘
|
||||
│ (if 未通过 → 回到 trader)
|
||||
▼
|
||||
┌──────────────┐
|
||||
│ final │ (输出结果)
|
||||
└──────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 五、关键数据流路径
|
||||
|
||||
以"600362 市场分析"为例,追踪一次数据调用的完整路径:
|
||||
|
||||
```
|
||||
1. Market Analyst LLM 决定调用 get_stock_data("600362", ...)
|
||||
|
||||
2. LangChain @tool 装饰器触发
|
||||
→ agents/utils/core_stock_tools.py:28
|
||||
|
||||
3. 内部调用 route_to_vendor("get_stock_data", "600362", ...)
|
||||
→ dataflows/interface.py:140
|
||||
|
||||
4. route_to_vendor 读取 config["data_vendors"]["core_stock_data"]
|
||||
→ {"primary": "akshare"}
|
||||
|
||||
5. 按 priority 顺序尝试:
|
||||
a) akshare → akshare_data.get_stock_data("600362", ...)
|
||||
- 检测 "600362" 是6位数字 → 路由到 A 股接口
|
||||
- 调用 ak.stock_zh_a_hist(symbol="600362", period="daily", ...)
|
||||
- 格式化 DataFrame → Markdown 表格字符串
|
||||
- 成功!返回数据 ✓
|
||||
|
||||
6. route_to_vendor 获得 Markdown 字符串 → 返回给 tool
|
||||
|
||||
7. tool 将数据嵌入 LLM context
|
||||
|
||||
8. Market Analyst LLM 收到数据,生成技术分析报告
|
||||
|
||||
9. 报告写入 state.market_report
|
||||
```
|
||||
|
||||
如果第5步 akshare 失败,route_to_vendor 会自动尝试 yfinance,再失败尝试 alpha_vantage,**完全透明,LLM 无感知**。
|
||||
|
||||
---
|
||||
|
||||
## 六、耗时分布估算
|
||||
|
||||
基于 DeepSeek 推理速度的单次分析耗时(仅供参考):
|
||||
|
||||
| 阶段 | LLM 调用次数 | 数据API调用 | 耗时估算 |
|
||||
|------|-------------|------------|----------|
|
||||
| 并行分析师(4个) | 8-16次 (LLM + tool) | 8-15次 | 90-180秒 |
|
||||
| 研究经理汇总 | 1次 | 0 | 10-20秒 |
|
||||
| 辩论(1轮) | 3次 (Bull/Bear/Judge) | 0 | 30-60秒 |
|
||||
| 交易员决策 | 1次 | 0-2次 | 15-30秒 |
|
||||
| 三级风控 | 4次 (3风控+1裁判) | 0 | 40-80秒 |
|
||||
| **合计** | **17-25次** | **8-17次** | **3-6分钟** |
|
||||
|
||||
> **注意**: 如果 `max_debate_rounds` 设为 2 或更多,辩论耗时翻倍。数据源的 Rate Limit 状况也会影响实际耗时。
|
||||
|
||||
---
|
||||
|
||||
## 七、与原始实现的关键差异
|
||||
|
||||
本项目基于开源 TradingAgents 框架,做了以下适应性修改(详见[架构文档](./architecture-and-modifications.md)):
|
||||
|
||||
| 差异点 | 原始实现 | 当前实现 |
|
||||
|--------|---------|---------|
|
||||
| 数据源 | yfinance 为主 | **akshare 为主**,yfinance 降级为 fallback |
|
||||
| A股行情 | 不稳定,频繁 Rate Limit | ✅ 稳定,不限流 |
|
||||
| A股财务数据 | ❌ | ✅ 三大报表完整 |
|
||||
| 新闻源 | 英文(yfinance news) | ✅ 中文(东方财富 + CCTV) |
|
||||
| 港股支持 | 部分 | ✅ 完整 |
|
||||
| Web UI | ❌ 无 | ✅ FastAPI + 前端面板 |
|
||||
| 部署 | 脚本手动运行 | ✅ systemd 服务自动管理 |
|
||||
|
||||
---
|
||||
|
||||
## 八、配置调优建议
|
||||
|
||||
通过修改 `default_config.py` 或运行时 `set_config()` 可调整的参数:
|
||||
|
||||
| 参数 | 默认值 | 建议范围 | 说明 |
|
||||
|------|--------|---------|------|
|
||||
| `max_debate_rounds` | 1 | 1-3 | 辩论轮次,越多越深度但越慢 |
|
||||
| `data_vendors.*.primary` | `"akshare"` | `"akshare"` / `"yfinance"` | 主数据源 |
|
||||
| `llm_provider` | `"deepseek"` | — | LLM 后端 |
|
||||
| `quick_thinking` | `False` | `True` / `False` | True 使用 fast model,速度更快精度略低 |
|
||||
|
||||
---
|
||||
|
||||
## 九、监控与调试
|
||||
|
||||
### 查看服务日志
|
||||
|
||||
```bash
|
||||
journalctl -u tradingagents.service -f
|
||||
```
|
||||
|
||||
### 查看分析任务状态
|
||||
|
||||
```bash
|
||||
curl http://129.211.173.87:8500/api/task/{task_id}
|
||||
```
|
||||
|
||||
### 重启服务
|
||||
|
||||
```bash
|
||||
sudo systemctl restart tradingagents.service
|
||||
```
|
||||
@@ -0,0 +1,300 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>TradingAgents 详细架构与数据流</title>
|
||||
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
body {
|
||||
font-family: 'Noto Sans Mono CJK SC', 'JetBrains Mono', 'WenQuanYi Zen Hei Mono', monospace;
|
||||
background: #020617;
|
||||
min-height: 100vh;
|
||||
padding: 2rem;
|
||||
color: white;
|
||||
}
|
||||
.container { max-width: 1200px; margin: 0 auto; }
|
||||
.header { margin-bottom: 2rem; }
|
||||
.header-row { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.5rem; }
|
||||
.pulse-dot {
|
||||
width: 12px; height: 12px; background: #22d3ee; border-radius: 50%;
|
||||
animation: pulse 2s infinite;
|
||||
}
|
||||
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
|
||||
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.025em; }
|
||||
.subtitle { color: #94a3b8; font-size: 0.875rem; margin-left: 1.75rem; }
|
||||
.diagram-container {
|
||||
background: rgba(15, 23, 42, 0.5); border-radius: 1rem;
|
||||
border: 1px solid #1e293b; padding: 1.5rem; overflow-x: auto;
|
||||
}
|
||||
svg { width: 100%; min-width: 900px; display: block; }
|
||||
.cards {
|
||||
display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
||||
gap: 1rem; margin-top: 2rem;
|
||||
}
|
||||
.card {
|
||||
background: rgba(15, 23, 42, 0.5); border-radius: 0.75rem;
|
||||
border: 1px solid #1e293b; padding: 1.25rem;
|
||||
}
|
||||
.card-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
|
||||
.card-dot { width: 8px; height: 8px; border-radius: 50%; }
|
||||
.card h3 { font-size: 0.875rem; font-weight: 600; color: #e2e8f0; }
|
||||
.card ul { list-style: none; font-size: 0.75rem; color: #94a3b8; line-height: 1.8; }
|
||||
.card li::before { content: "• "; color: #64748b; }
|
||||
.footer {
|
||||
margin-top: 2rem; padding-top: 1rem; border-top: 1px solid #1e293b;
|
||||
font-size: 0.75rem; color: #64748b; text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<div class="header-row">
|
||||
<div class="pulse-dot"></div>
|
||||
<h1>TradingAgents 详细架构与数据流</h1>
|
||||
</div>
|
||||
<div class="subtitle">系统架构图 · Hand-Drawn SVG</div>
|
||||
</div>
|
||||
<div class="diagram-container">
|
||||
<svg viewBox="0 0 1100 1160" xmlns="http://www.w3.org/2000/svg" font-family="'Noto Sans Mono CJK SC', 'JetBrains Mono', 'WenQuanYi Zen Hei Mono', monospace">
|
||||
<defs>
|
||||
<pattern id="grid" width="40" height="40" patternUnits="userSpaceOnUse">
|
||||
<path d="M 40 0 L 0 0 0 40" fill="none" stroke="#1e293b" stroke-width="0.5"/>
|
||||
</pattern>
|
||||
<filter id="dropShadow" x="-50%" y="-50%" width="200%" height="200%">
|
||||
<feDropShadow dx="0" dy="2" stdDeviation="3" flood-opacity="0.3"/>
|
||||
</filter>
|
||||
<marker id="arrowhead" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#64748b"/>
|
||||
</marker>
|
||||
<marker id="arrowhead-cyan" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#22d3ee"/>
|
||||
</marker>
|
||||
<marker id="arrowhead-green" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#34d399"/>
|
||||
</marker>
|
||||
<marker id="arrowhead-rose" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#fb7185"/>
|
||||
</marker>
|
||||
<marker id="arrowhead-amber" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#fbbf24"/>
|
||||
</marker>
|
||||
<marker id="arrowhead-purple" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#a78bfa"/>
|
||||
</marker>
|
||||
</defs>
|
||||
<rect width="1100" height="1160" fill="url(#grid)"/>
|
||||
<rect x="20" y="285" width="960" height="110" rx="10" fill="rgba(15, 23, 42, 0.3)" stroke="#fbbf24" stroke-width="1.5" stroke-dasharray="5,3"/>
|
||||
<rect x="35" y="277" width="90" height="16" fill="#0f172a"/>
|
||||
<text x="80" y="288" fill="#fbbf24" font-size="9" font-weight="500" text-anchor="middle">分析师团队 (并行)</text>
|
||||
<rect x="200" y="415" width="580" height="100" rx="10" fill="rgba(15, 23, 42, 0.3)" stroke="#a78bfa" stroke-width="1.5" stroke-dasharray="5,3"/>
|
||||
<rect x="215" y="407" width="90" height="16" fill="#0f172a"/>
|
||||
<text x="260" y="418" fill="#a78bfa" font-size="9" font-weight="500" text-anchor="middle">多空辩论 (可多轮)</text>
|
||||
<rect x="150" y="655" width="820" height="105" rx="10" fill="rgba(15, 23, 42, 0.3)" stroke="#f87171" stroke-width="1.5" stroke-dasharray="5,3"/>
|
||||
<rect x="165" y="647" width="42" height="16" fill="#0f172a"/>
|
||||
<text x="186" y="658" fill="#f87171" font-size="9" font-weight="500" text-anchor="middle">三级风控</text>
|
||||
<rect x="50" y="905" width="950" height="105" rx="10" fill="rgba(15, 23, 42, 0.3)" stroke="#64748b" stroke-width="1.5" stroke-dasharray="5,3"/>
|
||||
<rect x="65" y="897" width="42" height="16" fill="#0f172a"/>
|
||||
<text x="86" y="908" fill="#64748b" font-size="9" font-weight="500" text-anchor="middle">数据源层</text>
|
||||
<path d="M 608.0 47.0 A 15.749999999999998 15.749999999999998 0 0 1 629.0 33.5 A 18.9 18.9 0 0 1 671.0 31.25 A 15.749999999999998 15.749999999999998 0 0 1 692.0 44.75 A 12.6 12.6 0 0 1 685.0 53.75 L 615.0 53.75 A 12.6 12.6 0 0 1 608.0 47.0 Z" fill="rgba(120, 53, 15, 0.3)" stroke="#fbbf24" stroke-width="1.5"/>
|
||||
<text x="650" y="46" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">用户浏览器</text>
|
||||
<rect x="555" y="95" width="190" height="55" rx="6" fill="#0f172a" stroke="#22d3ee" stroke-width="1.5" opacity="1.0"/>
|
||||
<rect x="555" y="95" width="190" height="55" rx="6" fill="rgba(8, 51, 68, 0.4)" stroke="#22d3ee" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="650" y="113" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">Web Server (FastAPI)
|
||||
后台异步分析任务</text>
|
||||
<rect x="545" y="185" width="210" height="55" rx="6" fill="#0f172a" stroke="#34d399" stroke-width="1.5" opacity="1.0"/>
|
||||
<rect x="545" y="185" width="210" height="55" rx="6" fill="rgba(6, 78, 59, 0.4)" stroke="#34d399" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="650" y="203" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">TradingAgents Graph
|
||||
(LangGraph StateGraph)</text>
|
||||
<text x="650" y="217" fill="#94a3b8" font-size="8" font-weight="normal" text-anchor="middle">hexagon</text>
|
||||
<rect x="50" y="310" width="150" height="60" rx="6" fill="#0f172a" stroke="#34d399" stroke-width="1.5" opacity="1.0"/>
|
||||
<rect x="50" y="310" width="150" height="60" rx="6" fill="rgba(6, 78, 59, 0.4)" stroke="#34d399" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="125" y="328" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">市场分析师
|
||||
行情+技术指标</text>
|
||||
<rect x="240" y="310" width="140" height="60" rx="6" fill="#0f172a" stroke="#34d399" stroke-width="1.5" opacity="1.0"/>
|
||||
<rect x="240" y="310" width="140" height="60" rx="6" fill="rgba(6, 78, 59, 0.4)" stroke="#34d399" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="310" y="328" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">社媒分析师
|
||||
舆论情绪</text>
|
||||
<rect x="420" y="310" width="150" height="60" rx="6" fill="#0f172a" stroke="#34d399" stroke-width="1.5" opacity="1.0"/>
|
||||
<rect x="420" y="310" width="150" height="60" rx="6" fill="rgba(6, 78, 59, 0.4)" stroke="#34d399" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="495" y="328" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">新闻分析师
|
||||
个股+宏观新闻</text>
|
||||
<rect x="610" y="310" width="150" height="60" rx="6" fill="#0f172a" stroke="#34d399" stroke-width="1.5" opacity="1.0"/>
|
||||
<rect x="610" y="310" width="150" height="60" rx="6" fill="rgba(6, 78, 59, 0.4)" stroke="#34d399" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="685" y="328" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">基本面分析师
|
||||
三表+估值</text>
|
||||
<rect x="810" y="310" width="140" height="60" rx="6" fill="#0f172a" stroke="#fb7185" stroke-width="1.5" opacity="1.0"/>
|
||||
<rect x="810" y="310" width="140" height="60" rx="6" fill="rgba(136, 19, 55, 0.4)" stroke="#fb7185" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="880" y="328" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">研究经理
|
||||
汇总4份报告</text>
|
||||
<rect x="230" y="440" width="140" height="50" rx="6" fill="#0f172a" stroke="#22d3ee" stroke-width="1.5" opacity="1.0"/>
|
||||
<rect x="230" y="440" width="140" height="50" rx="6" fill="rgba(8, 51, 68, 0.4)" stroke="#22d3ee" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="300" y="458" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">Bull 多头
|
||||
研究员</text>
|
||||
<rect x="420" y="440" width="140" height="50" rx="6" fill="#0f172a" stroke="#fb7185" stroke-width="1.5" opacity="1.0"/>
|
||||
<rect x="420" y="440" width="140" height="50" rx="6" fill="rgba(136, 19, 55, 0.4)" stroke="#fb7185" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="490" y="458" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">Bear 空头
|
||||
研究员</text>
|
||||
<rect x="610" y="440" width="140" height="50" rx="6" fill="#0f172a" stroke="#34d399" stroke-width="1.5" opacity="1.0"/>
|
||||
<rect x="610" y="440" width="140" height="50" rx="6" fill="rgba(6, 78, 59, 0.4)" stroke="#34d399" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="680" y="458" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">辩论裁判
|
||||
评估论据</text>
|
||||
<rect x="545" y="560" width="210" height="55" rx="6" fill="#0f172a" stroke="#34d399" stroke-width="1.5" opacity="1.0"/>
|
||||
<rect x="545" y="560" width="210" height="55" rx="6" fill="rgba(6, 78, 59, 0.4)" stroke="#34d399" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="650" y="578" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">Trader 交易员
|
||||
综合辩论→决策草案</text>
|
||||
<text x="650" y="592" fill="#94a3b8" font-size="8" font-weight="normal" text-anchor="middle">hexagon</text>
|
||||
<rect x="190" y="680" width="140" height="55" rx="6" fill="#0f172a" stroke="#22d3ee" stroke-width="1.5" opacity="1.0"/>
|
||||
<rect x="190" y="680" width="140" height="55" rx="6" fill="rgba(8, 51, 68, 0.4)" stroke="#22d3ee" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="260" y="698" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">Aggressive
|
||||
激进风控</text>
|
||||
<rect x="390" y="680" width="145" height="55" rx="6" fill="#0f172a" stroke="#fb7185" stroke-width="1.5" opacity="1.0"/>
|
||||
<rect x="390" y="680" width="145" height="55" rx="6" fill="rgba(136, 19, 55, 0.4)" stroke="#fb7185" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="462" y="698" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">Conservative
|
||||
保守风控</text>
|
||||
<rect x="590" y="680" width="140" height="55" rx="6" fill="#0f172a" stroke="#34d399" stroke-width="1.5" opacity="1.0"/>
|
||||
<rect x="590" y="680" width="140" height="55" rx="6" fill="rgba(6, 78, 59, 0.4)" stroke="#34d399" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="660" y="698" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">Neutral
|
||||
中立风控</text>
|
||||
<rect x="800" y="680" width="140" height="55" rx="6" fill="#0f172a" stroke="#fb7185" stroke-width="1.5" opacity="1.0"/>
|
||||
<rect x="800" y="680" width="140" height="55" rx="6" fill="rgba(136, 19, 55, 0.4)" stroke="#fb7185" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="870" y="698" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">Risk Judge
|
||||
风控终审</text>
|
||||
<path d="M 584.0 833.0 A 19.25 19.25 0 0 1 617.0 816.5 A 23.099999999999998 23.099999999999998 0 0 1 683.0 813.75 A 19.25 19.25 0 0 1 716.0 830.25 A 15.4 15.4 0 0 1 705.0 841.25 L 595.0 841.25 A 15.4 15.4 0 0 1 584.0 833.0 Z" fill="rgba(120, 53, 15, 0.3)" stroke="#fbbf24" stroke-width="1.5"/>
|
||||
<text x="650" y="831" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">输出结果
|
||||
分析报告 + 交易信号</text>
|
||||
<path d="M 80 940 L 80 975 A 92 10 0 0 0 265 975 L 265 940 A 92 10 0 0 0 80 940 Z" fill="rgba(76, 29, 149, 0.4)" stroke="#a78bfa" stroke-width="1.5"/>
|
||||
<ellipse cx="172" cy="940" rx="92" ry="10" fill="rgba(76, 29, 149, 0.4)" stroke="#a78bfa" stroke-width="1.5"/>
|
||||
<text x="172" y="961" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">akshare 主数据源
|
||||
A股/港股/美股/新闻</text>
|
||||
<path d="M 320 940 L 320 975 A 82 10 0 0 0 485 975 L 485 940 A 82 10 0 0 0 320 940 Z" fill="rgba(76, 29, 149, 0.4)" stroke="#a78bfa" stroke-width="1.5"/>
|
||||
<ellipse cx="402" cy="940" rx="82" ry="10" fill="rgba(76, 29, 149, 0.4)" stroke="#a78bfa" stroke-width="1.5"/>
|
||||
<text x="402" y="961" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">yfinance 备用1
|
||||
美股+内部交易</text>
|
||||
<path d="M 540 940 L 540 975 A 82 10 0 0 0 705 975 L 705 940 A 82 10 0 0 0 540 940 Z" fill="rgba(76, 29, 149, 0.4)" stroke="#a78bfa" stroke-width="1.5"/>
|
||||
<ellipse cx="622" cy="940" rx="82" ry="10" fill="rgba(76, 29, 149, 0.4)" stroke="#a78bfa" stroke-width="1.5"/>
|
||||
<text x="622" y="961" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">Alpha Vantage 备用2
|
||||
美国市场备选</text>
|
||||
<path d="M 780 940 L 780 975 A 77 10 0 0 0 935 975 L 935 940 A 77 10 0 0 0 780 940 Z" fill="rgba(76, 29, 149, 0.4)" stroke="#a78bfa" stroke-width="1.5"/>
|
||||
<ellipse cx="857" cy="940" rx="77" ry="10" fill="rgba(76, 29, 149, 0.4)" stroke="#a78bfa" stroke-width="1.5"/>
|
||||
<text x="857" y="961" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">DeepSeek LLM
|
||||
推理引擎</text>
|
||||
<line x1="650" y1="65" x2="650" y2="95" stroke="POST /api/analyze" stroke-width="1.5" marker-end="url(#arrowhead)"/>
|
||||
<rect x="626" y="72" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="650" y="83" fill="POST /api/analyze" font-size="8" font-weight="normal" text-anchor="middle">#22d3ee</text>
|
||||
<line x1="650" y1="150" x2="650" y2="185" stroke="启动分析" stroke-width="1.5" marker-end="url(#arrowhead)"/>
|
||||
<rect x="626" y="159" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="650" y="170" fill="启动分析" font-size="8" font-weight="normal" text-anchor="middle">#22d3ee</text>
|
||||
<line x1="650" y1="240" x2="125" y2="310" stroke="分发" stroke-width="1.5" stroke-dasharray="5,3" marker-end="url(#arrowhead)"/>
|
||||
<rect x="363" y="267" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="387" y="278" fill="分发" font-size="8" font-weight="normal" text-anchor="middle">#fbbf24</text>
|
||||
<line x1="650" y1="240" x2="310" y2="310" stroke="分发" stroke-width="1.5" stroke-dasharray="5,3" marker-end="url(#arrowhead)"/>
|
||||
<rect x="456" y="267" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="480" y="278" fill="分发" font-size="8" font-weight="normal" text-anchor="middle">#fbbf24</text>
|
||||
<line x1="650" y1="240" x2="495" y2="310" stroke="分发" stroke-width="1.5" stroke-dasharray="5,3" marker-end="url(#arrowhead)"/>
|
||||
<rect x="548" y="267" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="572" y="278" fill="分发" font-size="8" font-weight="normal" text-anchor="middle">#fbbf24</text>
|
||||
<line x1="650" y1="240" x2="685" y2="310" stroke="分发" stroke-width="1.5" stroke-dasharray="5,3" marker-end="url(#arrowhead)"/>
|
||||
<rect x="643" y="267" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="667" y="278" fill="分发" font-size="8" font-weight="normal" text-anchor="middle">#fbbf24</text>
|
||||
<line x1="200" y1="340" x2="810" y2="340" stroke="报告" stroke-width="1.5" marker-end="url(#arrowhead)"/>
|
||||
<rect x="481" y="332" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="505" y="343" fill="报告" font-size="8" font-weight="normal" text-anchor="middle">#34d399</text>
|
||||
<line x1="380" y1="340" x2="810" y2="340" stroke="报告" stroke-width="1.5" marker-end="url(#arrowhead)"/>
|
||||
<rect x="571" y="332" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="595" y="343" fill="报告" font-size="8" font-weight="normal" text-anchor="middle">#34d399</text>
|
||||
<line x1="570" y1="340" x2="810" y2="340" stroke="报告" stroke-width="1.5" marker-end="url(#arrowhead)"/>
|
||||
<rect x="666" y="332" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="690" y="343" fill="报告" font-size="8" font-weight="normal" text-anchor="middle">#34d399</text>
|
||||
<line x1="760" y1="340" x2="810" y2="340" stroke="报告" stroke-width="1.5" marker-end="url(#arrowhead)"/>
|
||||
<rect x="761" y="332" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="785" y="343" fill="报告" font-size="8" font-weight="normal" text-anchor="middle">#34d399</text>
|
||||
<line x1="880" y1="370" x2="300" y2="440" stroke="启动辩论" stroke-width="1.5" marker-end="url(#arrowhead)"/>
|
||||
<rect x="566" y="397" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="590" y="408" fill="启动辩论" font-size="8" font-weight="normal" text-anchor="middle">#a78bfa</text>
|
||||
<line x1="880" y1="370" x2="490" y2="440" stroke="启动辩论" stroke-width="1.5" marker-end="url(#arrowhead)"/>
|
||||
<rect x="661" y="397" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="685" y="408" fill="启动辩论" font-size="8" font-weight="normal" text-anchor="middle">#a78bfa</text>
|
||||
<line x1="370" y1="465" x2="610" y2="465" stroke="多方论据" stroke-width="1.5" marker-end="url(#arrowhead)"/>
|
||||
<rect x="466" y="457" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="490" y="468" fill="多方论据" font-size="8" font-weight="normal" text-anchor="middle">#f87171</text>
|
||||
<line x1="560" y1="465" x2="610" y2="465" stroke="空方论据" stroke-width="1.5" marker-end="url(#arrowhead)"/>
|
||||
<rect x="561" y="457" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="585" y="468" fill="空方论据" font-size="8" font-weight="normal" text-anchor="middle">#f87171</text>
|
||||
<line x1="680" y1="490" x2="650" y2="560" stroke="辩论摘要" stroke-width="1.5" marker-end="url(#arrowhead)"/>
|
||||
<rect x="641" y="517" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="665" y="528" fill="辩论摘要" font-size="8" font-weight="normal" text-anchor="middle">#fb923c</text>
|
||||
<line x1="650" y1="615" x2="260" y2="680" stroke="草案" stroke-width="1.5" stroke-dasharray="5,3" marker-end="url(#arrowhead)"/>
|
||||
<rect x="431" y="639" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="455" y="650" fill="草案" font-size="8" font-weight="normal" text-anchor="middle">#38bdf8</text>
|
||||
<line x1="650" y1="615" x2="462" y2="680" stroke="草案" stroke-width="1.5" stroke-dasharray="5,3" marker-end="url(#arrowhead)"/>
|
||||
<rect x="532" y="639" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="556" y="650" fill="草案" font-size="8" font-weight="normal" text-anchor="middle">#38bdf8</text>
|
||||
<line x1="650" y1="615" x2="660" y2="680" stroke="草案" stroke-width="1.5" stroke-dasharray="5,3" marker-end="url(#arrowhead)"/>
|
||||
<rect x="631" y="639" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="655" y="650" fill="草案" font-size="8" font-weight="normal" text-anchor="middle">#38bdf8</text>
|
||||
<line x1="330" y1="707" x2="800" y2="707" stroke="评估" stroke-width="1.5" marker-end="url(#arrowhead)"/>
|
||||
<rect x="541" y="699" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="565" y="710" fill="评估" font-size="8" font-weight="normal" text-anchor="middle">#34d399</text>
|
||||
<line x1="535" y1="707" x2="800" y2="707" stroke="评估" stroke-width="1.5" marker-end="url(#arrowhead)"/>
|
||||
<rect x="643" y="699" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="667" y="710" fill="评估" font-size="8" font-weight="normal" text-anchor="middle">#34d399</text>
|
||||
<line x1="730" y1="707" x2="800" y2="707" stroke="评估" stroke-width="1.5" marker-end="url(#arrowhead)"/>
|
||||
<rect x="741" y="699" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="765" y="710" fill="评估" font-size="8" font-weight="normal" text-anchor="middle">#34d399</text>
|
||||
<line x1="870" y1="735" x2="650" y2="800" stroke="最终决策" stroke-width="1.5" marker-end="url(#arrowhead)"/>
|
||||
<rect x="736" y="759" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="760" y="770" fill="最终决策" font-size="8" font-weight="normal" text-anchor="middle">#22d3ee</text>
|
||||
<line x1="125" y1="370" x2="172" y2="930" stroke="数据" stroke-width="1.5" stroke-dasharray="5,3" marker-end="url(#arrowhead)"/>
|
||||
<rect x="124" y="642" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="148" y="653" fill="数据" font-size="8" font-weight="normal" text-anchor="middle">#94a3b8</text>
|
||||
<line x1="685" y1="370" x2="172" y2="930" stroke="数据" stroke-width="1.5" stroke-dasharray="5,3" marker-end="url(#arrowhead)"/>
|
||||
<rect x="404" y="642" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="428" y="653" fill="数据" font-size="8" font-weight="normal" text-anchor="middle">#94a3b8</text>
|
||||
<line x1="495" y1="370" x2="172" y2="930" stroke="数据" stroke-width="1.5" stroke-dasharray="5,3" marker-end="url(#arrowhead)"/>
|
||||
<rect x="309" y="642" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="333" y="653" fill="数据" font-size="8" font-weight="normal" text-anchor="middle">#94a3b8</text>
|
||||
<line x1="265" y1="957" x2="320" y2="957" stroke="fallback" stroke-width="1.5" stroke-dasharray="5,3" marker-end="url(#arrowhead)"/>
|
||||
<rect x="268" y="949" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="292" y="960" fill="fallback" font-size="8" font-weight="normal" text-anchor="middle">#64748b</text>
|
||||
<line x1="485" y1="957" x2="540" y2="957" stroke="fallback" stroke-width="1.5" stroke-dasharray="5,3" marker-end="url(#arrowhead)"/>
|
||||
<rect x="488" y="949" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="512" y="960" fill="fallback" font-size="8" font-weight="normal" text-anchor="middle">#64748b</text>
|
||||
<line x1="300" y1="490" x2="857" y2="930" stroke="推理" stroke-width="1.5" stroke-dasharray="5,3" marker-end="url(#arrowhead)"/>
|
||||
<rect x="554" y="702" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="578" y="713" fill="推理" font-size="8" font-weight="normal" text-anchor="middle">#94a3b8</text>
|
||||
<line x1="490" y1="490" x2="857" y2="930" stroke="推理" stroke-width="1.5" stroke-dasharray="5,3" marker-end="url(#arrowhead)"/>
|
||||
<rect x="649" y="702" width="49" height="14" fill="#0f172a" rx="2"/>
|
||||
<text x="673" y="713" fill="推理" font-size="8" font-weight="normal" text-anchor="middle">#94a3b8</text>
|
||||
<rect x="30" y="1090" width="850" height="60" rx="6" fill="rgba(15, 23, 42, 0.8)" stroke="#1e293b" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="45" y="1110" fill="#64748b" font-size="10" font-weight="normal" text-anchor="start">组件类型:</text>
|
||||
<rect x="120" y="1098" width="16" height="16" rx="3" fill="rgba(8, 51, 68, 0.4)" stroke="#22d3ee" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="142" y="1110" fill="#94a3b8" font-size="9" font-weight="normal" text-anchor="start">前端</text>
|
||||
<rect x="195" y="1098" width="16" height="16" rx="3" fill="rgba(6, 78, 59, 0.4)" stroke="#34d399" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="217" y="1110" fill="#94a3b8" font-size="9" font-weight="normal" text-anchor="start">后端</text>
|
||||
<rect x="270" y="1098" width="16" height="16" rx="3" fill="rgba(76, 29, 149, 0.4)" stroke="#a78bfa" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="292" y="1110" fill="#94a3b8" font-size="9" font-weight="normal" text-anchor="start">数据库</text>
|
||||
<rect x="345" y="1098" width="16" height="16" rx="3" fill="rgba(120, 53, 15, 0.3)" stroke="#fbbf24" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="367" y="1110" fill="#94a3b8" font-size="9" font-weight="normal" text-anchor="start">外部API</text>
|
||||
<rect x="420" y="1098" width="16" height="16" rx="3" fill="rgba(136, 19, 55, 0.4)" stroke="#fb7185" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="442" y="1110" fill="#94a3b8" font-size="9" font-weight="normal" text-anchor="start">认证</text>
|
||||
<rect x="495" y="1098" width="16" height="16" rx="3" fill="rgba(30, 41, 59, 0.5)" stroke="#94a3b8" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="517" y="1110" fill="#94a3b8" font-size="9" font-weight="normal" text-anchor="start">通用</text>
|
||||
<text x="45" y="1135" fill="#64748b" font-size="10" font-weight="normal" text-anchor="start">连接类型:</text>
|
||||
<line x1="120" y1="1130" x2="140" y2="1130" stroke="#64748b" stroke-width="1.5" marker-end="url(#arrowhead)"/>
|
||||
<text x="148" y="1134" fill="#94a3b8" font-size="9" font-weight="normal" text-anchor="start">数据流</text>
|
||||
<line x1="195" y1="1130" x2="215" y2="1130" stroke="#fb7185" stroke-width="1.5" marker-end="url(#arrowhead-rose)"/>
|
||||
<text x="223" y="1134" fill="#94a3b8" font-size="9" font-weight="normal" text-anchor="start">认证流</text>
|
||||
<line x1="270" y1="1130" x2="290" y2="1130" stroke="#fbbf24" stroke-width="1.5" marker-end="url(#arrowhead-amber)"/>
|
||||
<text x="298" y="1134" fill="#94a3b8" font-size="9" font-weight="normal" text-anchor="start">配置</text>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
生成时间: 2026-05-05 19:42 | Hand-Drawn Diagram · Zero Token Cost
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,121 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>TradingAgents 单次股票分析流程</title>
|
||||
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
body {
|
||||
font-family: 'Noto Sans Mono CJK SC', 'JetBrains Mono', 'WenQuanYi Zen Hei Mono', monospace;
|
||||
background: #020617;
|
||||
min-height: 100vh;
|
||||
padding: 2rem;
|
||||
color: white;
|
||||
}
|
||||
.container { max-width: 1200px; margin: 0 auto; }
|
||||
.header { margin-bottom: 2rem; }
|
||||
.header-row { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.5rem; }
|
||||
.pulse-dot {
|
||||
width: 12px; height: 12px; background: #22d3ee; border-radius: 50%;
|
||||
animation: pulse 2s infinite;
|
||||
}
|
||||
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
|
||||
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.025em; }
|
||||
.subtitle { color: #94a3b8; font-size: 0.875rem; margin-left: 1.75rem; }
|
||||
.diagram-container {
|
||||
background: rgba(15, 23, 42, 0.5); border-radius: 1rem;
|
||||
border: 1px solid #1e293b; padding: 1.5rem; overflow-x: auto;
|
||||
}
|
||||
svg { width: 100%; min-width: 900px; display: block; }
|
||||
.cards {
|
||||
display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
||||
gap: 1rem; margin-top: 2rem;
|
||||
}
|
||||
.card {
|
||||
background: rgba(15, 23, 42, 0.5); border-radius: 0.75rem;
|
||||
border: 1px solid #1e293b; padding: 1.25rem;
|
||||
}
|
||||
.card-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
|
||||
.card-dot { width: 8px; height: 8px; border-radius: 50%; }
|
||||
.card h3 { font-size: 0.875rem; font-weight: 600; color: #e2e8f0; }
|
||||
.card ul { list-style: none; font-size: 0.75rem; color: #94a3b8; line-height: 1.8; }
|
||||
.card li::before { content: "• "; color: #64748b; }
|
||||
.footer {
|
||||
margin-top: 2rem; padding-top: 1rem; border-top: 1px solid #1e293b;
|
||||
font-size: 0.75rem; color: #64748b; text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<div class="header-row">
|
||||
<div class="pulse-dot"></div>
|
||||
<h1>TradingAgents 单次股票分析流程</h1>
|
||||
</div>
|
||||
<div class="subtitle">系统架构图 · Hand-Drawn SVG</div>
|
||||
</div>
|
||||
<div class="diagram-container">
|
||||
<svg viewBox="0 0 800 660" xmlns="http://www.w3.org/2000/svg" font-family="'Noto Sans Mono CJK SC', 'JetBrains Mono', 'WenQuanYi Zen Hei Mono', monospace">
|
||||
<defs>
|
||||
<pattern id="grid" width="40" height="40" patternUnits="userSpaceOnUse">
|
||||
<path d="M 40 0 L 0 0 0 40" fill="none" stroke="#1e293b" stroke-width="0.5"/>
|
||||
</pattern>
|
||||
<filter id="dropShadow" x="-50%" y="-50%" width="200%" height="200%">
|
||||
<feDropShadow dx="0" dy="2" stdDeviation="3" flood-opacity="0.3"/>
|
||||
</filter>
|
||||
<marker id="arrowhead" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#64748b"/>
|
||||
</marker>
|
||||
<marker id="arrowhead-cyan" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#22d3ee"/>
|
||||
</marker>
|
||||
<marker id="arrowhead-green" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#34d399"/>
|
||||
</marker>
|
||||
<marker id="arrowhead-rose" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#fb7185"/>
|
||||
</marker>
|
||||
<marker id="arrowhead-amber" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#fbbf24"/>
|
||||
</marker>
|
||||
<marker id="arrowhead-purple" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#a78bfa"/>
|
||||
</marker>
|
||||
</defs>
|
||||
<rect width="800" height="660" fill="url(#grid)"/>
|
||||
<rect x="340" y="50" width="120" height="40" rx="20" fill="rgba(6, 78, 59, 0.4)" stroke="#34d399" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="400" y="74" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">用户输入
|
||||
股票代码 + 日期</text>
|
||||
<rect x="320" y="130" width="160" height="50" rx="6" fill="#0f172a" stroke="#94a3b8" stroke-width="1.5" opacity="1.0"/>
|
||||
<rect x="320" y="130" width="160" height="50" rx="6" fill="rgba(30, 41, 59, 0.5)" stroke="#94a3b8" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="400" y="148" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">并行数据采集
|
||||
(4个分析师同时工作)</text>
|
||||
<rect x="320" y="210" width="160" height="50" rx="6" fill="#0f172a" stroke="#94a3b8" stroke-width="1.5" opacity="1.0"/>
|
||||
<rect x="320" y="210" width="160" height="50" rx="6" fill="rgba(30, 41, 59, 0.5)" stroke="#94a3b8" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="400" y="228" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">研究经理汇总
|
||||
收集4份分析报告</text>
|
||||
<polygon points="400,290 440,330 400,370 360,330" fill="rgba(251, 146, 60, 0.3)" stroke="#fb923c" stroke-width="1.5"/>
|
||||
<text x="400" y="334" fill="#e2e8f0" font-size="10" font-weight="normal" text-anchor="middle">多空辩论
|
||||
Bull vs Bear × N轮</text>
|
||||
<rect x="320" y="370" width="160" height="50" rx="6" fill="#0f172a" stroke="#94a3b8" stroke-width="1.5" opacity="1.0"/>
|
||||
<rect x="320" y="370" width="160" height="50" rx="6" fill="rgba(30, 41, 59, 0.5)" stroke="#94a3b8" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="400" y="388" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">交易员决策
|
||||
综合辩论形成草案</text>
|
||||
<polygon points="400,450 440,490 400,530 360,490" fill="rgba(251, 146, 60, 0.3)" stroke="#fb923c" stroke-width="1.5"/>
|
||||
<text x="400" y="494" fill="#e2e8f0" font-size="10" font-weight="normal" text-anchor="middle">三级风控评审
|
||||
激进/保守/中立</text>
|
||||
<rect x="340" y="530" width="120" height="40" rx="20" fill="rgba(136, 19, 55, 0.4)" stroke="#fb7185" stroke-width="1.5" opacity="1.0"/>
|
||||
<text x="400" y="554" fill="#e2e8f0" font-size="11" font-weight="600" text-anchor="middle">最终输出
|
||||
Buy / Sell / Hold</text>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
生成时间: 2026-05-05 19:42 | Hand-Drawn Diagram · Zero Token Cost
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user