This commit is contained in:
MarkLo 2025-12-18 19:00:42 +08:00
parent f6aba8c838
commit 7fabb34e01
25 changed files with 147 additions and 82 deletions

141
README.md
View File

@ -2,7 +2,7 @@
<div align="center"> <div align="center">
<img src="frontend/public/icon-v5.png" alt="TradingAgentsX Logo" width="300" /> <img src="frontend/public/icon-v7.png" alt="TradingAgentsX Logo" width="300" />
**基於 LangGraph 的 AI 股票交易分析平台,結合多個專業 AI 代理進行協作決策** **基於 LangGraph 的 AI 股票交易分析平台,結合多個專業 AI 代理進行協作決策**
@ -26,16 +26,16 @@
### 🎯 核心特色 ### 🎯 核心特色
| 功能 | 說明 | | 功能 | 說明 |
|------|------| | ------------------------ | --------------------------------------------------------------- |
| 🤖 **多代理協作架構** | 12 個專業化 AI 代理(分析師、研究員、交易員、風險管理)協同工作 | | 🤖 **多代理協作架構** | 12 個專業化 AI 代理(分析師、研究員、交易員、風險管理)協同工作 |
| 🌐 **多模型支援** | OpenAI、Anthropic、Gemini、Grok、DeepSeek、Qwen 等 LLM 提供商 | | 🌐 **多模型支援** | OpenAI、Anthropic、Gemini、Grok、DeepSeek、Qwen 等 LLM 提供商 |
| 🔒 **Google OAuth 登入** | 雲端同步 API 設定與歷史報告,支援多裝置同步 | | 🔒 **Google OAuth 登入** | 雲端同步 API 設定與歷史報告,支援多裝置同步 |
| 📊 **美股與台股支援** | 完整支援美股Yahoo Finance與台股FinMind資料 | | 📊 **美股與台股支援** | 完整支援美股Yahoo Finance與台股FinMind資料 |
| 🔑 **BYOK 模式** | 使用者自帶 API 金鑰,前端加密儲存,保障隱私 | | 🔑 **BYOK 模式** | 使用者自帶 API 金鑰,前端加密儲存,保障隱私 |
| 🛡️ **安全防護** | Rate Limiting、Security Headers、API Key 遮罩 | | 🛡️ **安全防護** | Rate Limiting、Security Headers、API Key 遮罩 |
| 📱 **響應式設計** | 支援桌面與手機瀏覽器 | | 📱 **響應式設計** | 支援桌面與手機瀏覽器 |
| 🐳 **Docker 部署** | 一鍵啟動前後端服務 | | 🐳 **Docker 部署** | 一鍵啟動前後端服務 |
--- ---
@ -144,28 +144,31 @@ TradingAgentsX/
## 🤖 AI 代理團隊 ## 🤖 AI 代理團隊
### 分析師團隊 (4 位) ### 分析師團隊 (4 位)
| 代理 | 職責 | 輸出 |
|------|------|------| | 代理 | 職責 | 輸出 |
| 市場分析師 | 技術分析 | RSI、MACD、布林通道、支撐阻力位 | | -------------- | -------- | ----------------------------------- |
| 市場分析師 | 技術分析 | RSI、MACD、布林通道、支撐阻力位 |
| 社群媒體分析師 | 情緒評估 | Reddit/Twitter 情緒指標、投資者信心 | | 社群媒體分析師 | 情緒評估 | Reddit/Twitter 情緒指標、投資者信心 |
| 新聞分析師 | 新聞分析 | 最新新聞摘要、事件影響評估 | | 新聞分析師 | 新聞分析 | 最新新聞摘要、事件影響評估 |
| 基本面分析師 | 財務分析 | 財報數據、P/E、P/B、盈利能力 | | 基本面分析師 | 財務分析 | 財報數據、P/E、P/B、盈利能力 |
### 研究團隊 (3 位) ### 研究團隊 (3 位)
| 代理 | 職責 |
|------|------| | 代理 | 職責 |
| ---------- | ---------------------------- |
| 看漲研究員 | 多頭觀點論證、上漲催化劑分析 | | 看漲研究員 | 多頭觀點論證、上漲催化劑分析 |
| 看跌研究員 | 空頭觀點論證、下跌風險警告 | | 看跌研究員 | 空頭觀點論證、下跌風險警告 |
| 研究經理 | 綜合看漲與看跌觀點的決策 | | 研究經理 | 綜合看漲與看跌觀點的決策 |
### 交易與風險團隊 (5 位) ### 交易與風險團隊 (5 位)
| 代理 | 職責 |
|------|------| | 代理 | 職責 |
| 交易員 | 整合所有報告,制定交易計劃 | | ---------- | -------------------------- |
| 激進分析師 | 高風險高回報策略分析 | | 交易員 | 整合所有報告,制定交易計劃 |
| 保守分析師 | 穩健保守策略與風險控制 | | 激進分析師 | 高風險高回報策略分析 |
| 中立分析師 | 中立平衡策略評估 | | 保守分析師 | 穩健保守策略與風險控制 |
| 風險經理 | 風險管理綜合決策與最終建議 | | 中立分析師 | 中立平衡策略評估 |
| 風險經理 | 風險管理綜合決策與最終建議 |
--- ---
@ -179,11 +182,11 @@ TradingAgentsX/
### 必要的 API 金鑰 ### 必要的 API 金鑰
| API | 用途 | 申請網址 | | API | 用途 | 申請網址 |
|-----|------|----------| | --------------------- | -------------- | -------------------------------------------- |
| OpenAI | GPT 模型 | https://platform.openai.com/api-keys | | OpenAI | GPT 模型 | https://platform.openai.com/api-keys |
| Alpha Vantage選填 | 美股基本面資料 | https://www.alphavantage.co/support/#api-key | | Alpha Vantage選填 | 美股基本面資料 | https://www.alphavantage.co/support/#api-key |
| FinMind選填 | 台股資料 | https://finmindtrade.com/ | | FinMind選填 | 台股資料 | https://finmindtrade.com/ |
### 安裝步驟 ### 安裝步驟
@ -214,6 +217,7 @@ python -m backend
``` ```
後端服務: 後端服務:
- API: http://localhost:8000 - API: http://localhost:8000
- Swagger 文檔: http://localhost:8000/docs - Swagger 文檔: http://localhost:8000/docs
@ -248,6 +252,7 @@ docker compose down -v
``` ```
服務端口: 服務端口:
- 後端: http://localhost:8000 - 後端: http://localhost:8000
- 前端: http://localhost:3000 - 前端: http://localhost:3000
@ -257,13 +262,13 @@ docker compose down -v
### 本地開發 vs 生產環境 ### 本地開發 vs 生產環境
| 功能 | 本地開發 (localhost) | 生產環境 (Railway 等) | | 功能 | 本地開發 (localhost) | 生產環境 (Railway 等) |
|------|----------------------|----------------------| | ------------ | -------------------- | --------------------- |
| Google 登入 | 選用(可不設定) | 建議啟用 | | Google 登入 | 選用(可不設定) | 建議啟用 |
| 資料自動清除 | ❌ 不會清除 | ✅ 未登入時離開會清除 | | 資料自動清除 | ❌ 不會清除 | ✅ 未登入時離開會清除 |
| PostgreSQL | 選用 | 必需 | | PostgreSQL | 選用 | 必需 |
| API 設定儲存 | 永久保留 | 登入後雲端同步 | | API 設定儲存 | 永久保留 | 登入後雲端同步 |
| 歷史報告儲存 | 永久保留 | 登入後雲端同步 | | 歷史報告儲存 | 永久保留 | 登入後雲端同步 |
### 前端安全 ### 前端安全
@ -272,12 +277,14 @@ docker compose down -v
- **Safari 觸控優化** - 修復 iOS Safari 的觸控事件問題 - **Safari 觸控優化** - 修復 iOS Safari 的觸控事件問題
### 後端安全 ### 後端安全
- **Rate Limiting** - 每分鐘 30 次請求限制 - **Rate Limiting** - 每分鐘 30 次請求限制
- **Security Headers** - X-Content-Type-Options、X-Frame-Options 等 - **Security Headers** - X-Content-Type-Options、X-Frame-Options 等
- **敏感資料遮罩** - API Key 在日誌中自動遮罩 - **敏感資料遮罩** - API Key 在日誌中自動遮罩
- **CORS 配置** - 限制跨域請求來源 - **CORS 配置** - 限制跨域請求來源
### 雲端同步 ### 雲端同步
- **Google OAuth 2.0** - 安全的第三方登入 - **Google OAuth 2.0** - 安全的第三方登入
- **JWT Token** - 無狀態認證 - **JWT Token** - 無狀態認證
- **雲端備份** - API 設定與歷史報告同步到伺服器 - **雲端備份** - API 設定與歷史報告同步到伺服器
@ -287,9 +294,11 @@ docker compose down -v
## 📱 使用指南 ## 📱 使用指南
### 1. 配置 API 金鑰 ### 1. 配置 API 金鑰
點擊右上角「設定」按鈕,輸入您的 API 金鑰。 點擊右上角「設定」按鈕,輸入您的 API 金鑰。
### 2. 選擇分析參數 ### 2. 選擇分析參數
- **市場類型**: 美股 / 台股上市 / 台股上櫃 - **市場類型**: 美股 / 台股上市 / 台股上櫃
- **股票代碼**: 如 NVDA、2330 - **股票代碼**: 如 NVDA、2330
- **分析師團隊**: 選擇需要的分析師 - **分析師團隊**: 選擇需要的分析師
@ -297,14 +306,17 @@ docker compose down -v
- **LLM 模型**: 快速思維模型 + 深層思維模型 - **LLM 模型**: 快速思維模型 + 深層思維模型
### 3. 執行分析 ### 3. 執行分析
點擊「執行分析」,等待 1-5 分鐘(依研究深度而定)。 點擊「執行分析」,等待 1-5 分鐘(依研究深度而定)。
### 4. 查看結果 ### 4. 查看結果
- **交易決策摘要** - BUY / SELL / HOLD 建議 - **交易決策摘要** - BUY / SELL / HOLD 建議
- **股價走勢圖** - 折線圖 / K 線圖切換 - **股價走勢圖** - 折線圖 / K 線圖切換
- **12 位代理報告** - 點擊標籤查看詳細分析 - **12 位代理報告** - 點擊標籤查看詳細分析
### 5. 儲存與下載 ### 5. 儲存與下載
- **儲存報告** - 保存到本地 / 雲端 - **儲存報告** - 保存到本地 / 雲端
- **下載 PDF 報告** - 匯出完整 PDF 分析報告 - **下載 PDF 報告** - 匯出完整 PDF 分析報告
@ -319,11 +331,13 @@ docker compose down -v
## 🔌 API 文檔 ## 🔌 API 文檔
### 健康檢查 ### 健康檢查
```bash ```bash
GET /api/health GET /api/health
``` ```
### 執行分析 ### 執行分析
```bash ```bash
POST /api/analyze POST /api/analyze
Content-Type: application/json Content-Type: application/json
@ -344,6 +358,7 @@ Content-Type: application/json
``` ```
### 查詢任務狀態 ### 查詢任務狀態
```bash ```bash
GET /api/task/{task_id} GET /api/task/{task_id}
``` ```
@ -355,25 +370,27 @@ GET /api/task/{task_id}
## 🛠️ 技術棧 ## 🛠️ 技術棧
### 後端 ### 後端
| 技術 | 用途 |
|------|------| | 技術 | 用途 |
| FastAPI | 異步 Web 框架 | | -------------------- | ---------------------- |
| LangGraph | 多代理工作流編排 | | FastAPI | 異步 Web 框架 |
| LangChain | LLM 應用開發 | | LangGraph | 多代理工作流編排 |
| ChromaDB | 向量資料庫(記憶系統)| | LangChain | LLM 應用開發 |
| PostgreSQL | 使用者資料儲存 | | ChromaDB | 向量資料庫(記憶系統) |
| SQLAlchemy + asyncpg | 異步資料庫 ORM | | PostgreSQL | 使用者資料儲存 |
| Pydantic | 資料驗證 | | SQLAlchemy + asyncpg | 異步資料庫 ORM |
| Pydantic | 資料驗證 |
### 前端 ### 前端
| 技術 | 用途 |
|------|------| | 技術 | 用途 |
| Next.js 16 | React 全端框架 | | ------------ | -------------- |
| TypeScript | 靜態型別 | | Next.js 16 | React 全端框架 |
| Tailwind CSS | 樣式框架 | | TypeScript | 靜態型別 |
| shadcn/ui | UI 組件庫 | | Tailwind CSS | 樣式框架 |
| Dexie.js | IndexedDB 封裝 | | shadcn/ui | UI 組件庫 |
| Recharts | 資料視覺化 | | Dexie.js | IndexedDB 封裝 |
| Recharts | 資料視覺化 |
--- ---
@ -385,11 +402,12 @@ GET /api/task/{task_id}
--- ---
### API配置頁面 ### API 配置頁面
![API配置頁面](web_screenshot/2.png) ![API配置頁面](web_screenshot/2.png)
--- ---
### 任務配置頁面 ### 任務配置頁面
![任務配置頁面](web_screenshot/3.png) ![任務配置頁面](web_screenshot/3.png)
@ -429,77 +447,66 @@ GET /api/task/{task_id}
### 社群媒體分析師報告 ### 社群媒體分析師報告
![社群媒體分析師報告](web_screenshot/8.png) ![社群媒體分析師報告](web_screenshot/8.png)
--- ---
### 新聞分析師報告 ### 新聞分析師報告
![新聞分析師報告](web_screenshot/9.png) ![新聞分析師報告](web_screenshot/9.png)
--- ---
### 基本面分析師報告 ### 基本面分析師報告
![基本面分析師報告](web_screenshot/10.png) ![基本面分析師報告](web_screenshot/10.png)
--- ---
### 看漲研究員報告 ### 看漲研究員報告
![看漲研究員報告](web_screenshot/11.png) ![看漲研究員報告](web_screenshot/11.png)
--- ---
### 看跌研究員報告 ### 看跌研究員報告
![看跌研究員報告](web_screenshot/12.png) ![看跌研究員報告](web_screenshot/12.png)
--- ---
### 研究經理報告 ### 研究經理報告
![研究經理報告](web_screenshot/13.png) ![研究經理報告](web_screenshot/13.png)
--- ---
### 交易員報告 ### 交易員報告
![交易員報告](web_screenshot/14.png) ![交易員報告](web_screenshot/14.png)
--- ---
### 激進分析師報告 ### 激進分析師報告
![激進分析師報告](web_screenshot/15.png) ![激進分析師報告](web_screenshot/15.png)
--- ---
### 保守分析師報告 ### 保守分析師報告
![保守分析師報告](web_screenshot/16.png) ![保守分析師報告](web_screenshot/16.png)
--- ---
### 中立分析師報告 ### 中立分析師報告
![中立分析師報告](web_screenshot/17.png) ![中立分析師報告](web_screenshot/17.png)
--- ---
### 風險經理報告 ### 風險經理報告
![風險經理報告](web_screenshot/18.png) ![風險經理報告](web_screenshot/18.png)
--- ---

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 332 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 332 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 332 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 332 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 332 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 332 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 353 KiB

After

Width:  |  Height:  |  Size: 332 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 332 KiB

View File

@ -14,15 +14,27 @@ export const metadata: Metadata = {
description: "由 AI 驅動的多代理 LLM 金融交易框架", description: "由 AI 驅動的多代理 LLM 金融交易框架",
icons: { icons: {
icon: [ icon: [
{ url: "/favicon-v5.ico?t=20241217", sizes: "32x32" }, { url: "/favicon-v7.png?t=20241218", sizes: "32x32" },
{ url: "/icon-192-v5.png?t=20241217", sizes: "192x192", type: "image/png" }, {
{ url: "/icon-512-v5.png?t=20241217", sizes: "512x512", type: "image/png" }, url: "/icon-192-v7.png?t=20241218",
{ url: "/icon-v5.png?t=20241217", sizes: "1024x1024", type: "image/png" }, sizes: "192x192",
type: "image/png",
},
{
url: "/icon-512-v7.png?t=20241218",
sizes: "512x512",
type: "image/png",
},
{ url: "/icon-v7.png?t=20241218", sizes: "1024x1024", type: "image/png" },
], ],
apple: [ apple: [
{ url: "/apple-touch-icon-v5.png?t=20241217", sizes: "180x180", type: "image/png" }, {
url: "/apple-touch-icon-v7.png?t=20241218",
sizes: "180x180",
type: "image/png",
},
], ],
shortcut: "/favicon-v5.ico?t=20241217", shortcut: "/favicon-v7.png?t=20241218",
}, },
appleWebApp: { appleWebApp: {
capable: true, capable: true,
@ -45,20 +57,56 @@ export default function RootLayout({
return ( return (
<html lang="en" suppressHydrationWarning> <html lang="en" suppressHydrationWarning>
<head> <head>
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" /> <meta
name="viewport"
content="width=device-width, initial-scale=1, viewport-fit=cover"
/>
<link rel="manifest" href="/manifest.json?v=20241217" /> <link rel="manifest" href="/manifest.json?v=20241217" />
<meta name="theme-color" content="#6B21A8" /> <meta name="theme-color" content="#6B21A8" />
<meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> <meta
name="apple-mobile-web-app-status-bar-style"
content="black-translucent"
/>
<meta name="apple-mobile-web-app-title" content="TAgentsX" /> <meta name="apple-mobile-web-app-title" content="TAgentsX" />
{/* Timestamp forces iOS Safari to reload new icons */} {/* Timestamp forces iOS Safari to reload new icons */}
<link rel="apple-touch-icon" href="/apple-touch-icon-v5.png?t=20241217" /> <link
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon-v5.png?t=20241217" /> rel="apple-touch-icon"
<link rel="apple-touch-icon" sizes="152x152" href="/apple-touch-icon-v5.png?t=20241217" /> href="/apple-touch-icon-v7.png?t=20241218"
<link rel="apple-touch-icon" sizes="120x120" href="/apple-touch-icon-v5.png?t=20241217" /> />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-v5.png?t=20241217" /> <link
<link rel="icon" type="image/png" sizes="192x192" href="/icon-192-v5.png?t=20241217" /> rel="apple-touch-icon"
<link rel="icon" type="image/png" sizes="512x512" href="/icon-512-v5.png?t=20241217" /> sizes="180x180"
href="/apple-touch-icon-v7.png?t=20241218"
/>
<link
rel="apple-touch-icon"
sizes="152x152"
href="/apple-touch-icon-v7.png?t=20241218"
/>
<link
rel="apple-touch-icon"
sizes="120x120"
href="/apple-touch-icon-v7.png?t=20241218"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="/favicon-v7.png?t=20241218"
/>
<link
rel="icon"
type="image/png"
sizes="192x192"
href="/icon-192-v7.png?t=20241218"
/>
<link
rel="icon"
type="image/png"
sizes="512x512"
href="/icon-512-v7.png?t=20241218"
/>
</head> </head>
<body className={inter.className}> <body className={inter.className}>
<ThemeProvider> <ThemeProvider>

View File

@ -17,6 +17,16 @@ export default function HomePage() {
{/* Hero Section */} {/* Hero Section */}
<div className="text-center mb-16 animate-fade-in relative py-8"> <div className="text-center mb-16 animate-fade-in relative py-8">
<div className="absolute inset-0 gradient-bg-radial -z-10" /> <div className="absolute inset-0 gradient-bg-radial -z-10" />
<div className="mb-6">
<Image
src="/logo.png"
alt="TradingAgentsX Logo"
width={120}
height={120}
className="mx-auto rounded-2xl shadow-2xl hover:scale-105 transition-transform duration-300"
priority
/>
</div>
<h1 className="text-4xl sm:text-5xl md:text-6xl font-bold mb-6 gradient-text-primary leading-tight"> <h1 className="text-4xl sm:text-5xl md:text-6xl font-bold mb-6 gradient-text-primary leading-tight">
TradingAgentsX TradingAgentsX
</h1> </h1>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 807 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

BIN
frontend/public/icon-v7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 KiB

BIN
frontend/public/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 KiB