|
| 1 | +<div align="center"> |
| 2 | + |
| 3 | + |
| 4 | +<h2>QuantAgent: 基于价格驱动的多智能体大语言模型高频交易系统</h2> |
| 5 | + |
| 6 | +<div style="position: relative; text-align: center; margin: 20px 0;"> |
| 7 | + <div style="position: absolute; top: -10px; right: 20%; font-size: 1.2em;"></div> |
| 8 | + <p> |
| 9 | + <a href="https://machineily.github.io/">Fei Xiong</a><sup>1,2 ★</sup> |
| 10 | + <a href="https://wyattz23.github.io">Xiang Zhang</a><sup>3 ★</sup> |
| 11 | + <a href="https://intersun.github.io/">Siqi Sun</a><sup>4</sup> |
| 12 | + <a href="https://chenyuyou.me/">Chenyu You</a><sup>1</sup> |
| 13 | + </p> |
| 14 | + |
| 15 | + |
| 16 | + <p> |
| 17 | + <sup>1</sup> Stony Brook University |
| 18 | + <sup>2</sup> Carnegie Mellon University |
| 19 | + <sup>3</sup> University of British Columbia <br> |
| 20 | + <sup>4</sup> Fudan University |
| 21 | + ★ Equal Contribution <br> |
| 22 | + </p> |
| 23 | +</div> |
| 24 | + |
| 25 | +[](https://github.com/Y-Research-SBU/QuantAgent/stargazers) |
| 26 | +[](https://github.com/Y-Research-SBU/QuantAgent/forks) |
| 27 | +[](https://github.com/Y-Research-SBU/QuantAgent/pulls) |
| 28 | +[](https://github.com/Y-Research-SBU/QuantAgent/issues) |
| 29 | +[](https://github.com/your-username/QuantAgents/graphs/contributors) |
| 30 | +[](https://github.com/Y-Research-SBU/QuantAgent/blob/main/LICENSE) |
| 31 | + |
| 32 | +</div> |
1 | 33 |
|
| 34 | +一个复杂的多智能体交易分析系统,结合了技术指标、模式识别和趋势分析,使用 LangChain 和 LangGraph。该系统提供网络界面和程序化访问,用于全面的市场分析。 |
2 | 35 |
|
3 | | -# QuantAgents |
| 36 | +<div align="center"> |
4 | 37 |
|
5 | | -一个复杂的多智能体交易分析系统,结合了技术指标、模式识别和趋势分析,使用 LangChain 和 LangGraph。该系统提供网络界面和程序化访问,用于全面的市场分析。 |
| 38 | +🚀 [功能特性](#-功能特性) | ⚡ [安装](#-安装) | 🎬 [使用](#-使用) | 🔧 [实现细节](#-实现细节) | 📊 [基准测试](#-基准测试) | 🤝 [贡献](#-贡献) | 📄 [许可证](#-许可证) |
6 | 39 |
|
7 | | -> QuantAgent 是一个研究导向的工具,旨在探索金融环境中的算法决策制定。其性能取决于多种变量,包括所选的语言模型、参数调优、数据完整性、市场波动性和其他随机因素。QuantAgent 生成的结果本质上是实验性的,不应被解释为实际交易或投资活动的建议。 |
| 40 | +</div> |
8 | 41 |
|
9 | 42 | ## 🚀 功能特性 |
10 | 43 |
|
11 | | -- **多智能体分析**:四个专业智能体协同工作: |
| 44 | +### 指标智能体 |
| 45 | + |
| 46 | +• 计算一套技术指标——包括用于评估动量极值的 RSI、用于量化收敛-发散动态的 MACD,以及用于测量收盘价相对于最近交易范围的随机振荡器——在每个传入的 K 线上,将原始 OHLC 数据转换为精确的、信号就绪的指标。 |
| 47 | + |
| 48 | + |
12 | 49 |
|
13 | | - - **指标智能体**:计算技术指标(MACD、RSI、随机指标等) |
14 | | -  |
15 | | - - **模式智能体**:识别蜡烛图模式并生成可视化图表 |
16 | | -  |
17 | | - - **趋势智能体**:分析市场趋势并生成趋势可视化 |
18 | | -  |
19 | | - - **风险智能体**:汇总指标、模式和趋势报告,量化潜在回撤,推荐仓位大小,并定义止损阈值,实现全面的风险管理。 |
20 | | -  |
21 | | - - **决策智能体**:整合指标、模式、趋势和风险报告,发布最终交易指令——指定做多/做空信号和理由。 |
22 | | -  |
23 | | - |
24 | | -- **网络界面**:基于 Flask 的现代网络应用程序,具有: |
| 50 | +### 模式智能体 |
| 51 | + |
| 52 | +• 在模式查询时,模式智能体首先绘制最近的价格图表,识别其主要高点、低点和总体上升或下降走势,将该形状与一组熟悉的模式进行比较,并返回最佳匹配的简短、通俗语言描述。 |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | +### 趋势智能体 |
| 57 | + |
| 58 | +• 利用工具生成的带注释的 K 线图表,叠加拟合的趋势通道——追踪最近高点和低点的上下边界线——来量化市场方向、通道斜率和盘整区域,然后提供当前趋势的简洁、专业的总结。 |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | +### 决策智能体 |
| 63 | + |
| 64 | +• 综合指标、模式、趋势和风险智能体的输出——包括动量指标、检测到的图表形态、通道分析和风险-回报评估——制定可操作的交易指令,明确指定做多或做空头寸、推荐的入场和出场点、止损阈值,以及基于每个智能体发现的简洁理由。 |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | +### 网络界面 |
| 69 | +基于 Flask 的现代网络应用程序,具有: |
25 | 70 | - 来自雅虎财经的实时市场数据 |
26 | 71 | - 交互式资产选择(股票、加密货币、商品、指数) |
27 | 72 | - 多时间框架分析(1分钟到1天) |
28 | 73 | - 动态图表生成 |
29 | 74 | - API 密钥管理 |
30 | 75 |
|
| 76 | +## 📦 安装 |
| 77 | + |
| 78 | +### 1. 创建并激活 Conda 环境 |
| 79 | + |
| 80 | +```bash |
| 81 | +conda create -n quantagents python=3.10 |
| 82 | +conda activate quantagents |
| 83 | +``` |
| 84 | + |
| 85 | +### 2. 安装依赖 |
| 86 | + |
| 87 | +```bash |
| 88 | +pip install -r requirements.txt |
| 89 | +``` |
| 90 | + |
| 91 | +如果您遇到 TA-lib-python 的问题,请尝试: |
| 92 | + |
| 93 | +```bash |
| 94 | +conda install -c conda-forge ta-lib |
| 95 | +``` |
| 96 | + |
| 97 | +或访问 [TA-Lib Python 仓库](https://github.com/ta-lib/ta-lib-python) 获取详细的安装说明。 |
| 98 | + |
| 99 | +### 3. 设置 OpenAI API 密钥 |
| 100 | +您可以在我们的网络界面中稍后设置它, |
| 101 | + |
| 102 | + |
| 103 | +或将其设置为环境变量: |
| 104 | +```bash |
| 105 | +export OPENAI_API_KEY="your_api_key_here" |
| 106 | +``` |
| 107 | + |
31 | 108 | ## 🔧 实现细节 |
32 | 109 |
|
33 | 110 | 我们使用 LangGraph 构建 QuantAgents 以确保灵活性和模块化。我们使用 gpt-4o 和 gpt-4o-mini 作为我们的深度思考和快速思考 LLM 进行实验。但是,出于测试目的,我们建议您使用 gpt-4o-mini 来节省成本,因为我们的框架会进行大量 API 调用。 |
@@ -116,45 +193,6 @@ final_state = trading_graph.graph.invoke(initial_state) |
116 | 193 |
|
117 | 194 | 每个 CSV 文件包含 4 小时蜡烛图数据,具有 OHLCV(开盘、最高、最低、收盘、成交量)信息,用于评估和回测目的。 |
118 | 195 |
|
119 | | -## 🛠️ 先决条件 |
120 | | - |
121 | | -- Python 3.10(强烈推荐用于兼容性) |
122 | | -- Conda(推荐)或 pip |
123 | | -- OpenAI API 密钥 |
124 | | -- TA-Lib 库 |
125 | | - |
126 | | -## 📦 安装 |
127 | | - |
128 | | -### 1. 创建并激活 Conda 环境 |
129 | | - |
130 | | -```bash |
131 | | -conda create -n quantagents python=3.10 |
132 | | -conda activate quantagents |
133 | | -``` |
134 | | - |
135 | | -### 2. 安装依赖 |
136 | | - |
137 | | -```bash |
138 | | -pip install -r requirements.txt |
139 | | -``` |
140 | | - |
141 | | -如果您遇到 TA-lib-python 的问题,请尝试: |
142 | | - |
143 | | -```bash |
144 | | -conda install -c conda-forge ta-lib |
145 | | -``` |
146 | | - |
147 | | -或访问 [TA-Lib Python 仓库](https://github.com/ta-lib/ta-lib-python) 获取详细的安装说明。 |
148 | | - |
149 | | -### 3. 设置 OpenAI API 密钥 |
150 | | -您可以在我们的网络界面中稍后设置它, |
151 | | - |
152 | | - |
153 | | -或将其设置为环境变量: |
154 | | -```bash |
155 | | -export OPENAI_API_KEY="your_api_key_here" |
156 | | -``` |
157 | | - |
158 | 196 | ## 🚀 使用 |
159 | 197 |
|
160 | 198 | ### 启动网络界面 |
@@ -191,7 +229,7 @@ python web_interface.py |
191 | 229 |
|
192 | 230 | ## 🙏 致谢 |
193 | 231 |
|
194 | | -此仓库基于 [**LangGraph**](https://github.com/langchain-ai/langgraph)、[**OpenAI**](https://github.com/openai/openai-python)、[**yfinance**](https://github.com/ranaroussi/yfinance)、[**Flask**](https://github.com/pallets/flask) 、[**tvdatafeed**](https://github.com/rongardF/tvdatafeed) 和 [**TechnicalAnalysisAutomation**](https://github.com/neurotrader888/TechnicalAnalysisAutomation/tree/main) 构建。 |
| 232 | +此仓库基于 [**LangGraph**](https://github.com/langchain-ai/langgraph)、[**OpenAI**](https://github.com/openai/openai-python)、[**yfinance**](https://github.com/ranaroussi/yfinance)、[**Flask**](https://github.com/pallets/flask)、[**TechnicalAnalysisAutomation**](https://github.com/neurotrader888/TechnicalAnalysisAutomation/tree/main) 和 [**tvdatafeed**](https://github.com/rongardF/tvdatafeed) 构建。 |
195 | 233 |
|
196 | 234 | ## ⚠️ 免责声明 |
197 | 235 |
|
|
0 commit comments