# Add to your Claude Code skills
git clone https://github.com/1517005260/stock-agentLast scanned: 6/19/2026
{
"issues": [],
"status": "PASSED",
"scannedAt": "2026-06-19T09:06:19.393Z",
"npmAuditRan": true,
"pipAuditRan": false,
"promptInjectionRan": true
}stock-agent is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by 1517005260. 基于LLM的股票投资助手. It has 100 GitHub stars.
Yes. stock-agent passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.
Clone the repository with "git clone https://github.com/1517005260/stock-agent" and add it to your Claude Code skills directory (see the Installation section above).
stock-agent is primarily written in Python. It is open-source under 1517005260 on GitHub, so you can review or fork the full source.
Yes. SkillsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh stock-agent against similar tools.
No comments yet. Be the first to share your thoughts!
Forked From:https://github.com/24mlight/A_Share_investment_Agent.git
课程项目用版:https://github.com/1517005260/AShareAgent
这是一个基于智能体(Agent)的 A 股投资决策系统,通过多个专业智能体协同工作,实现数据收集、分析、决策和风险管理的全流程自动化。系统采用模块化设计,每个智能体负责特定的分析任务,最终由 Portfolio Manager 综合各方分析结果做出交易决策。
本项目还另外嵌入了 MCP 分析模块,详见这个目录
系统由以下几个协同工作的智能体组成:
详细的智能体说明请查看 src/agents/README.md。
git clone https://github.com/1517005260/stock-agent.git
cd stock-agent
conda create -n stock python=3.10
conda activate stock
cd stock-agent/
pip install -r requirements.txt
pip install -e .
# 创建 .env 文件存放API密钥
cp .env.example .env
直接修改 .env 文件
打开 .env 文件,填入你的 API key:
OPENAI_COMPATIBLE_API_KEY=your_openai_compatible_api_key
OPENAI_COMPATIBLE_BASE_URL=https://api.example.com/v1
OPENAI_COMPATIBLE_MODEL=your_model_name
TUSHARE_TOKEN=your_tushare_api_key
主程序:
# 基本用法
python -m src.main --ticker 600054 --show-reasoning
# 多资产
python src/main.py --ticker 600519 --tickers "600519,000858,601398" --start-date 2023-01-01 --end-date 2023-12-31
# 指定日期范围
python -m src.main --ticker 600054 --start-date 2023-01-01 --end-date 2023-12-31 --show-reasoning
# 指定初始资金和新闻数量
python -m src.main --ticker 600054 --initial-capital 200000 --num-of-news 10
# 显示详细的总结报告
python -m src.main --ticker 600054 --summary
# 基本回测
python -m src.backtester --ticker 600054
# 指定回测时间范围
python -m src.backtester --ticker 600054 --start-date 2022-01-01 --end-date 2022-12-31
# 自定义初始资金
python -m src.backtester --ticker 600054 --initial-capital 500000
# 显示详细分析过程
python -m src.backtester --ticker 600054 --show-reasoning
# 生成汇总报告
python -m src.backtester --ticker 600054 --summary
--ticker: 股票代码(必需)--start-date: 回测开始日期(可选,格式为 YYYY-MM-DD,默认为结束日期前一年)--end-date: 回测结束日期(可选,格式为 YYYY-MM-DD,默认为昨天)--initial-capital: 初始资金(可选,默认为 100,000)--initial-position: 初始持仓数量(可选,默认为 0)--show-reasoning: 显示每日分析推理过程(可选)--summary: 显示回测结束后的汇总报告(可选)回测系统会输出以下信息:
test/test_backtest.py 是一个专门用于测试和验证回测框架功能的综合测试工具。它提供了多种测试模式,可以对比 AI Agent 策略与传统基准策略的表现,并生成详细的性能分析报告。
基准策略测试:测试多种传统投资策略
AI Agent 策略测试:测试本项目的智能投资代理策略
性能对比分析:生成详细的策略对比报告和排名
统计显著性检验:验证策略间的统计显著性差异
# 运行完整测试套件(默认3个月)
python test/test_backtest.py
# 指定股票代码
python test/test_backtest.py --ticker 600519
# 快速测试模式(3个月)
python test/test_backtest.py --quick --ticker 600054
# 中等测试模式(8个月)
python test/test_backtest.py --medium --ticker 600054
# 完整测试模式(2年)
python test/test_backtest.py --full --ticker 600054
# 自定义时间范围
python test/test_backtest.py --start-date 2023-01-01 --end-date 2023-12-31 --ticker 600054
# 仅测试 AI Agent 策略
python test/test_backtest.py --ai-only --ticker 600054
# 仅测试基准策略
python test/test_backtest.py --baseline-only --ticker 600054
# 运行全面比较分析
python test/test_backtest.py --comparison --ticker 600054
--quick: 快速测试模式(3 个月时间范围)--medium: 中等测试模式(8 个月时间范围)--full: 完整测试模式(2 年时间范围)--start-date: 自定义开始日期(YYYY-MM-DD 格式)--end-date: 自定义结束日期(YYYY-MM-DD 格式)--ticker: 股票代码(默认为 000001)--ai-only: 仅测试 AI Agent 策略--baseline-only: 仅测试基准策略--comparison: 运行全面比较测试测试工具会生成以下类型的报告:
性能对比表格:
AI Agent 专项分析:
统计显著性检验:
集成了本项目所有智能分析师的综合决策策略,包括:
==========================================
回测测试结果汇总
==========================================
测试配置:
时间范围: 2023-01-01 至 2023-03-31
测试时长: 89 天
股票代码: 600054
📊 策略表现排名:
排名 策略名称 收益率 夏普比率 最大回撤
1 AI_Agent 15.23% 1.245 8.45%
2 Momentum 12.67% 0.987 12.34%
3 Buy_Hold 8.91% 0.756 15.67%
4 Mean_Reversion 6.45% 0.543 18.23%
5 Moving_Average 4.32% 0.321 22.11%
6 Random_Walk -2.15% -0.123 25.67%
🎯 AI Agent表现分析:
📊 排名: 第1名 (共6个策略)
💰 收益率: 15.23%
📈 夏普比率: 1.245
📉 最大回撤: 8.45%
🔄 交易次数: 23
📊 与平均水平比较:
收益率差异: +7.57%
夏普比率差异: +0.621
回撤差异: -6.89%
综合评级: 优秀 ⭐⭐⭐
测试时间选择:
股票选择:
结果解读:
模型训练与评估:
# 训练深度学习模型
python -m model.train.train --ticker 600054 --model dl
# 训练所有模型
python -m model.train.train --ticker 600054 --model all
# 模型评估(划分训练、验证、测试集)
python -m model.train.train --ticker 600054 --model dl --action evaluate
# 自定义数据划分比例
python -m model.train.train --ticker 600054 --model dl --action evaluate --train-ratio 0.8 --val-ratio 0.1 --test-ratio 0.1
数据处理工具:
# 数据分析和技术指标计算
python -m src.tools.data_analyzer --ticker 600054
# 新闻获取测试
python -m src.tools.test_news_crawler
--ticker: 股票代码(必需)--tickers: 多个股票代码,逗号分隔(可选,用于多资产分析)--show-reasoning: 显示分析推理过程(可选,默认为 false)--summary: 显示汇总报告(可选,默认为 false)--initial-capital: 初始现金金额(可选,默认为 100,000)--initial-position: 初始持仓数量(可选,默认为 0)--num-of-news: 情绪分析使用的新闻数量(可选,默认为 5)--start-date: 分析开始日期(可选,格式为 YYYY-MM-DD,默认为结束日期前一年)--end-date: 分析结束日期(可选,格式为 YYYY-MM-DD,默认为昨天)系统会输出以下信息:
如果使用了--show-reasoning参数,还会显示每个智能体的详细分析过程。
如果使用了--summary参数,会在分析结束后显示一个格式化的汇总报告。
示例输出:
--- Finished Workflow Run ID: c94a353c-8d28-486e-b5e7-9e7f92a1b7c4 ---
2025-05-07 19:56:56 - structured_terminal - INFO -
════════════════════════════════════════════════════════════════════════════════
股票代码 600054 投资分析报告
════════════════════════════════════════════════════════════════════════════════
分析区间: 2023-01-01 至 2025-05-06
╔═══════════════════════════════════ 📈 技术分析分析 ═══════════════════════════════════╗
║ 信号: 📈 bullish
║ 置信度: 34%
║ ├─ signal: bullish
║ ├─ confidence: 0.3369
║ ├─ market_regime: mean_reverting
║ ├─ regime_confidence: 0.5000
║ ├─ strategy_weights:
║ ├─ trend: 0.2000
║ ├─ mean_reversion: 0.4500
║ ├─ momentum: 0.1500
║ ├─ volatility: 0.1500
║ └─ stat_arb: 0.0500
║ └─ strategy_signals:
║ ├─ trend_following:
║ ├─ signal: neutral
║ ├─ confidence: 0.5000
║ └─ metrics:
║ ├─ adx: 17.4486
║ └─ trend_strength: 0.1745
║ ├─ mean_reversion:
║ ├─ signal: neutral
║ ├─ confidence: 0.2400
║ └─ metrics:
║ ├─ z_score: -0.6314
║ ├─ price_vs_bb: 0.2563
║ ├─ rsi_14: 39.8467
║ ├─ rsi_28: 48.0707
║ ├─ avg_deviation: -0.0200
║ ├─ k_percent: 21.0145
║ ├─ d_percent: 17.7575
║ └─ signal_score: 0
║ ├─ momentum:
║ ├─ signal: neutral
║ ├─ confidence: 0.2000
║ └─ metrics:
║ ├─ momentum_1m: -0.0260
║ ├─ momentum_3m: 0.0782
║ ├─ momentum_6m: 0.0280
║ ├─ relative_strength: 0.0983
║ ├─ volume_trend: 0.8827
║ └─ divergence: -0.1343
║ ├─ volatility:
║ ├─ signal: bullish
║ ├─ confidence: 0.7000
║ └─ metrics:
║ ├─ historical_volatility: 0.4362
║ ├─ volatility_regime: 1.5622
║ ├─ volatility_z_score: 0.5622
║ ├─ atr_ratio: 0.0304
║ ├─ garch_vol_trend: -0.2795
║ ├─ garch_forecast_quality: 0.8000
║ └─ garch_results:
║ ├─ model_type: GARCH(1,1)
║ ├─ parameters:
║ ├─ omega: 0.0000
║ ├─ alpha: 0.1484
║ ├─ beta: 0.7570
║ └─ persistence: 0.9054
║ ├─ log_likelihood: 1424.2592
║ ├─ forecast:
║ ├─ 0.01934439715669238
║ ├─ 0.01947384175695497
║ ├─ 0.019590300231429235
║ ├─ 0.01969514513510902
║ ├─ 0.01978959022705738
║ ├─ 0.019874711562961323
║ ├─ 0.019951465249916377
║ ├─ 0.020020702495460313
║ ├─ 0.020083182443127238
║ └─ 0.02013958318202366
║ └─ forecast_annualized:
║ ├─ 0.307082784834438
║ ├─ 0.3091376541595679
║ ├─ 0.31098637512871713
║ ├─ 0.31265073637693247
║ ├─ 0.3141500057320084
║ ├─ 0.315501265048413
║ ├─ 0.3167196920557553
║ ├─ 0.31781879925478945
║ ├─ 0.31881063767551954
║ └─ 0.3197059716488009
║ └─ statistical_arbitrage:
║ ├─ signal: neutral
║ ├─ confidence: 0.5000
║ └─ metrics:
║ ├─ hurst_exponent: 0.00000
║ ├─ skewness: -0.8531
║