aj-stock-analysis
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseChina Stock Analysis Skill
China Stock Analysis Skill
基于价值投资理论的中国A股分析工具,面向低频交易的普通投资者。
A Chinese A-share analysis tool based on value investment theory, targeting ordinary investors with low-frequency trading.
When to Use
When to Use
当用户请求以下操作时调用此skill:
- 分析某只A股股票
- 筛选符合条件的股票
- 对比多只股票或行业内股票
- 计算股票估值或内在价值
- 查看股票的财务健康状况
- 检测财务异常风险
Call this skill when the user requests the following operations:
- Analyze a specific A-share stock
- Screen stocks that meet criteria
- Compare multiple stocks or stocks within an industry
- Calculate stock valuation or intrinsic value
- Check the financial health of a stock
- Detect financial anomaly risks
Prerequisites
Prerequisites
Python环境要求(必须使用venv)
Python Environment Requirements (venv is mandatory)
所有脚本命令都应在项目虚拟环境中运行。
bash
python3 -m venv .venv
source .venv/bin/activate安装依赖:
bash
pip install tushare pandas numpyAll script commands should be run in the project virtual environment.
bash
python3 -m venv .venv
source .venv/bin/activateInstall Dependencies:
bash
pip install tushare pandas numpyEnvironment Bootstrap(执行前必须自动完成)
Environment Bootstrap (Must be completed automatically before execution)
在运行任何脚本前,先在当前项目目录执行:
bash
cd <skill项目目录>
if [ ! -d ".venv" ]; then
python3 -m venv .venv
fi
source .venv/bin/activate
python3 -m pip install -U pip
python3 -m pip install tushare pandas numpy说明:
- 必须位于 skill 项目根目录下(不是全局目录)
.venv - 若 失败,必须先执行上述 bootstrap,再继续后续分析流程
import tushare
TUSHARE_TOKENBRAVE_API_KEY~/.aj-skills/.envbash
set -a
source ~/.aj-skills/.env
set +a说明:
- 脚本不会自动读取
~/.aj-skills/.env - 必须通过 CLI 参数显式传入:、
--token "${TUSHARE_TOKEN}"--brave-api-key "${BRAVE_API_KEY}"
执行前参数预检(使用 命令):
testbash
test -n "${TUSHARE_TOKEN}" || { echo "缺少 TUSHARE_TOKEN"; exit 1; }Before running any scripts, execute the following in the current project directory:
bash
cd <skill project directory>
if [ ! -d ".venv" ]; then
python3 -m venv .venv
fi
source .venv/bin/activate
python3 -m pip install -U pip
python3 -m pip install tushare pandas numpyNotes:
- must be located in the root directory of the skill project (not a global directory)
.venv - If fails, the above bootstrap must be executed first before proceeding with subsequent analysis processes
import tushare
TUSHARE_TOKENBRAVE_API_KEY~/.aj-skills/.envbash
set -a
source ~/.aj-skills/.env
set +aNotes:
- The script will not automatically read
~/.aj-skills/.env - Must be explicitly passed via CLI parameters: ,
--token "${TUSHARE_TOKEN}"--brave-api-key "${BRAVE_API_KEY}"
Pre-execution Parameter Check (using command):
testbash
test -n "${TUSHARE_TOKEN}" || { echo "Missing TUSHARE_TOKEN"; exit 1; }仅当使用 Brave 新闻源时检查
Check only when using Brave news source
test -n "${BRAVE_API_KEY}" || { echo "缺少 BRAVE_API_KEY(news-provider=brave 时必填)"; exit 1; }
undefinedtest -n "${BRAVE_API_KEY}" || { echo "Missing BRAVE_API_KEY (required when news-provider=brave)"; exit 1; }
undefined依赖检查
Dependency Check
在执行任何分析前,先检查tushare是否已安装:
bash
python3 -c "import tushare; print(tushare.__version__)"Before performing any analysis, check if tushare is installed:
bash
python3 -c "import tushare; print(tushare.__version__)"Core Modules
Core Modules
1. Stock Screener (股票筛选器)
1. Stock Screener
筛选符合条件的股票
Screen stocks that meet criteria
2. Financial Analyzer (财务分析器)
2. Financial Analyzer
个股深度财务分析
In-depth financial analysis of individual stocks
3. Industry Comparator (行业对比)
3. Industry Comparator
同行业横向对比分析
Horizontal comparison analysis within the same industry
4. Valuation Calculator (估值计算器)
4. Valuation Calculator
内在价值测算与安全边际计算
Intrinsic value measurement and margin of safety calculation
5. News & Sentiment (新闻与舆情)
5. News & Sentiment
抓取近期社会面新闻并生成舆情风险评估
Capture recent public news and generate sentiment risk assessment
Workflow 1: Stock Screening (股票筛选)
Workflow 1: Stock Screening
用户请求筛选股票时使用。
Used when the user requests stock screening.
Step 1: Collect Screening Criteria
Step 1: Collect Screening Criteria
向用户询问筛选条件。提供以下选项供用户选择或自定义:
估值指标:
- PE (市盈率): 例如 PE < 15
- PB (市净率): 例如 PB < 2
- PS (市销率): 例如 PS < 3
盈利能力:
- ROE (净资产收益率): 例如 ROE > 15%
- ROA (总资产收益率): 例如 ROA > 8%
- 毛利率: 例如 > 30%
- 净利率: 例如 > 10%
成长性:
- 营收增长率: 例如 > 10%
- 净利润增长率: 例如 > 15%
- 连续增长年数: 例如 >= 3年
股息:
- 股息率: 例如 > 3%
- 连续分红年数: 例如 >= 5年
财务安全:
- 资产负债率: 例如 < 60%
- 流动比率: 例如 > 1.5
- 速动比率: 例如 > 1
筛选范围:
- 全A股
- 沪深300成分股
- 中证500成分股
- 创业板/科创板
- 用户自定义列表
Ask the user for screening criteria. Provide the following options for selection or customization:
Valuation Metrics:
- PE (Price-to-Earnings Ratio): e.g., PE < 15
- PB (Price-to-Book Ratio): e.g., PB < 2
- PS (Price-to-Sales Ratio): e.g., PS < 3
Profitability:
- ROE (Return on Equity): e.g., ROE > 15%
- ROA (Return on Assets): e.g., ROA > 8%
- Gross Profit Margin: e.g., > 30%
- Net Profit Margin: e.g., > 10%
Growth:
- Revenue Growth Rate: e.g., > 10%
- Net Profit Growth Rate: e.g., > 15%
- Consecutive Growth Years: e.g., >= 3 years
Dividends:
- Dividend Yield: e.g., > 3%
- Consecutive Dividend Years: e.g., >= 5 years
Financial Safety:
- Asset-Liability Ratio: e.g., < 60%
- Current Ratio: e.g., > 1.5
- Quick Ratio: e.g., > 1
Screening Scope:
- All A-shares
- CSI 300 Constituents
- CSI 500 Constituents
- ChiNext/STAR Market
- User-defined list
Step 2: Execute Screening
Step 2: Execute Screening
bash
python scripts/stock_screener.py \
--scope "hs300" \
--token "${TUSHARE_TOKEN}" \
--pe-max 15 \
--roe-min 15 \
--debt-ratio-max 60 \
--dividend-min 2 \
--output screening_result.json参数说明:
- : 筛选范围 (all/hs300/zz500/cyb/kcb/custom:600519,000858,...)
--scope - : PE范围
--pe-max/--pe-min - : PB范围
--pb-max/--pb-min - : 最低ROE
--roe-min - : 最低增长率
--growth-min - : 最大资产负债率
--debt-ratio-max - : 最低股息率
--dividend-min - : tushare token(必填)
--token - : 输出格式 (json/table)
--format - : 静默模式
--quiet - : 输出文件路径
--output
bash
python scripts/stock_screener.py \\
--scope "hs300" \\
--token "${TUSHARE_TOKEN}" \\
--pe-max 15 \\
--roe-min 15 \\
--debt-ratio-max 60 \\
--dividend-min 2 \\
--output screening_result.jsonParameter Explanation:
- : Screening scope (all/hs300/zz500/cyb/kcb/custom:600519,000858,...)
--scope - : PE range
--pe-max/--pe-min - : PB range
--pb-max/--pb-min - : Minimum ROE
--roe-min - : Minimum growth rate
--growth-min - : Maximum asset-liability ratio
--debt-ratio-max - : Minimum dividend yield
--dividend-min - : tushare token (required)
--token - : Output format (json/table)
--format - : Silent mode
--quiet - : Output file path
--output
Step 3: Present Results
Step 3: Present Results
读取 并以表格形式呈现给用户:
screening_result.json| 代码 | 名称 | PE | PB | ROE | 股息率 | 评分 |
|---|---|---|---|---|---|---|
| 600519 | 贵州茅台 | 25.3 | 8.5 | 30.2% | 2.1% | 85 |
Read and present to the user in table format:
screening_result.json| Code | Name | PE | PB | ROE | Dividend Yield | Score |
|---|---|---|---|---|---|---|
| 600519 | Kweichow Moutai | 25.3 | 8.5 | 30.2% | 2.1% | 85 |
Workflow 2: Stock Analysis (个股分析)
Workflow 2: Stock Analysis
用户请求分析某只股票时使用。
Used when the user requests analysis of a specific stock.
Step 1: Collect Stock Information
Step 1: Collect Stock Information
询问用户:
- 股票代码或名称
- 分析深度级别:
- 摘要级:关键指标 + 投资结论(1页)
- 标准级:财务分析 + 估值 + 行业对比 + 风险提示
- 深度级:完整调研报告,包含历史数据追踪
Ask the user:
- Stock code or name
- Analysis depth level:
- Summary Level: Key indicators + investment conclusion (1 page)
- Standard Level: Financial analysis + valuation + industry comparison + risk warning
- In-depth Level: Complete research report including historical data tracking
Step 1.5: Prepare Output Directory
Step 1.5: Prepare Output Directory
单只股票分析时,skill 需要自动创建输出目录,命名规则:
${股票名称}_${股票代码}
示例:
bash
stock_dir="贵州茅台_600519"
mkdir -p "${stock_dir}"When analyzing a single stock, the skill needs to automatically create an output directory with the naming rule:
${stock_name}_${stock_code}
Example:
bash
stock_dir="Kweichow Moutai_600519"
mkdir -p "${stock_dir}"Step 2: Fetch Stock Data
Step 2: Fetch Stock Data
推荐使用“分模块抓取 + 聚合”流程(CLI解耦):
bash
mkdir -p "${stock_dir}/data"Recommended to use "module-wise fetch + aggregation" process (CLI decoupling):
bash
mkdir -p "${stock_dir}/data"1) 基础信息
1) Basic Information
python scripts/fetch_basic.py
--code "600519"
--token "${TUSHARE_TOKEN}"
--output "${stock_dir}/data/basic.json"
--code "600519"
--token "${TUSHARE_TOKEN}"
--output "${stock_dir}/data/basic.json"
python scripts/fetch_basic.py \
--code "600519" \
--token "${TUSHARE_TOKEN}" \
--output "${stock_dir}/data/basic.json"
2) 财务数据
2) Financial Data
python scripts/fetch_financial.py
--code "600519"
--token "${TUSHARE_TOKEN}"
--years 5
--output "${stock_dir}/data/financial.json"
--code "600519"
--token "${TUSHARE_TOKEN}"
--years 5
--output "${stock_dir}/data/financial.json"
python scripts/fetch_financial.py \
--code "600519" \
--token "${TUSHARE_TOKEN}" \
--years 5 \
--output "${stock_dir}/data/financial.json"
3) 估值与行情
3) Valuation & Market Data
python scripts/fetch_valuation.py
--code "600519"
--token "${TUSHARE_TOKEN}"
--output "${stock_dir}/data/valuation.json" python scripts/fetch_price.py
--code "600519"
--token "${TUSHARE_TOKEN}"
--days 180
--output "${stock_dir}/data/price.json"
--code "600519"
--token "${TUSHARE_TOKEN}"
--output "${stock_dir}/data/valuation.json" python scripts/fetch_price.py
--code "600519"
--token "${TUSHARE_TOKEN}"
--days 180
--output "${stock_dir}/data/price.json"
python scripts/fetch_valuation.py \
--code "600519" \
--token "${TUSHARE_TOKEN}" \
--output "${stock_dir}/data/valuation.json"
python scripts/fetch_price.py \
--code "600519" \
--token "${TUSHARE_TOKEN}" \
--days 180 \
--output "${stock_dir}/data/price.json"
4) 新闻舆情
4) News & Sentiment
python scripts/fetch_news_data.py
--code "600519"
--name "贵州茅台"
--days 7
--limit 20
--provider brave
--brave-api-key "${BRAVE_API_KEY}"
--output "${stock_dir}/data/news.json"
--code "600519"
--name "贵州茅台"
--days 7
--limit 20
--provider brave
--brave-api-key "${BRAVE_API_KEY}"
--output "${stock_dir}/data/news.json"
python scripts/fetch_news_data.py \
--code "600519" \
--name "Kweichow Moutai" \
--days 7 \
--limit 20 \
--provider brave \
--brave-api-key "${BRAVE_API_KEY}" \
--output "${stock_dir}/data/news.json"
5) 实时与事件窗口
5) Real-time & Event Window
python scripts/fetch_realtime.py
--code "600519"
--token "${TUSHARE_TOKEN}"
--benchmark hs300
--window 60
--output "${stock_dir}/data/realtime.json" python scripts/fetch_event_window.py
--code "600519"
--token "${TUSHARE_TOKEN}"
--name "贵州茅台"
--benchmark hs300
--pre-days 1
--post-days 1,3,5
--provider brave
--brave-api-key "${BRAVE_API_KEY}"
--output "${stock_dir}/data/event_window.json"
--code "600519"
--token "${TUSHARE_TOKEN}"
--benchmark hs300
--window 60
--output "${stock_dir}/data/realtime.json" python scripts/fetch_event_window.py
--code "600519"
--token "${TUSHARE_TOKEN}"
--name "贵州茅台"
--benchmark hs300
--pre-days 1
--post-days 1,3,5
--provider brave
--brave-api-key "${BRAVE_API_KEY}"
--output "${stock_dir}/data/event_window.json"
python scripts/fetch_realtime.py \
--code "600519" \
--token "${TUSHARE_TOKEN}" \
--benchmark hs300 \
--window 60 \
--output "${stock_dir}/data/realtime.json"
python scripts/fetch_event_window.py \
--code "600519" \
--token "${TUSHARE_TOKEN}" \
--name "Kweichow Moutai" \
--benchmark hs300 \
--pre-days 1 \
--post-days 1,3,5 \
--provider brave \
--brave-api-key "${BRAVE_API_KEY}" \
--output "${stock_dir}/data/event_window.json"
6) 聚合为分析输入
6) Aggregate into Analysis Input
python scripts/assemble_data.py
--input-dir "${stock_dir}/data"
--output "${stock_dir}/stock_data.json"
--input-dir "${stock_dir}/data"
--output "${stock_dir}/stock_data.json"
兼容模式(单命令抓取)保留如下:
```bash
python scripts/data_fetcher.py \
--code "600519" \
--token "${TUSHARE_TOKEN}" \
--data-type all \
--with-news \
--news-provider brave \
--brave-api-key "${BRAVE_API_KEY}" \
--with-realtime \
--with-event-window \
--benchmark hs300 \
--realtime-window 60 \
--event-window-pre 1 \
--event-window-post 1,3,5 \
--news-days 7 \
--news-limit 20 \
--years 5 \
--output "${stock_dir}/stock_data.json"参数说明:
- : 股票代码
--code - : 数据类型 (basic/financial/valuation/holder/news/all)
--data-type - : 获取多少年的历史数据
--years - : tushare token(必填)
--token - : 附加新闻与舆情
--with-news - : 新闻窗口天数
--news-days - : 新闻最大条数
--news-limit - : 新闻来源过滤(逗号分隔)
--news-sources - : 新闻源 (auto/brave/tushare/rss)
--news-provider - : Brave Search API Key(
--brave-api-key时必填)news-provider=brave - : 附加实时指标(趋势/确认/风险/筹码)
--with-realtime - : 附加事件窗口分析(事件后1/3/5日反应)
--with-event-window - : 相对强弱基准指数 (hs300/zz500/zz1000/cyb/kcb)
--benchmark - : 实时指标计算窗口(日)
--realtime-window - : 事件窗口前置天数
--event-window-pre - : 事件窗口后验天数(逗号分隔)
--event-window-post - : 缓存有效期(分钟)
--cache-ttl-min - : 输出格式 (json/table)
--format - : 静默模式
--quiet - : 输出文件
--output
python scripts/assemble_data.py \
--input-dir "${stock_dir}/data" \
--output "${stock_dir}/stock_data.json"
Compatibility mode (single command fetch) is retained as follows:
```bash
python scripts/data_fetcher.py \\
--code "600519" \\
--token "${TUSHARE_TOKEN}" \\
--data-type all \\
--with-news \\
--news-provider brave \\
--brave-api-key "${BRAVE_API_KEY}" \\
--with-realtime \\
--with-event-window \\
--benchmark hs300 \\
--realtime-window 60 \\
--event-window-pre 1 \\
--event-window-post 1,3,5 \\
--news-days 7 \\
--news-limit 20 \\
--years 5 \\
--output "${stock_dir}/stock_data.json"Parameter Explanation:
- : Stock code
--code - : Data type (basic/financial/valuation/holder/news/all)
--data-type - : Number of years of historical data to fetch
--years - : tushare token (required)
--token - : Attach news and sentiment data
--with-news - : News window days
--news-days - : Maximum number of news items
--news-limit - : News source filter (comma-separated)
--news-sources - : News source (auto/brave/tushare/rss)
--news-provider - : Brave Search API Key (required when
--brave-api-key)news-provider=brave - : Attach real-time indicators (trend/confirmation/risk/筹码)
--with-realtime - : Attach event window analysis (1/3/5-day reaction after events)
--with-event-window - : Relative strength benchmark index (hs300/zz500/zz1000/cyb/kcb)
--benchmark - : Real-time indicator calculation window (days)
--realtime-window - : Event window pre-days
--event-window-pre - : Event window post-days (comma-separated)
--event-window-post - : Cache validity period (minutes)
--cache-ttl-min - : Output format (json/table)
--format - : Silent mode
--quiet - : Output file
--output
可选:单独执行新闻舆情流程
Optional: Execute News & Sentiment Process Separately
bash
python scripts/news_fetcher.py --code 600519 --name 贵州茅台 --token "${TUSHARE_TOKEN}" --days 7 --limit 20 --provider brave --brave-api-key "${BRAVE_API_KEY}" --output "${stock_dir}/news.json"
python scripts/sentiment_analyzer.py --input "${stock_dir}/news.json" --output "${stock_dir}/sentiment.json"bash
python scripts/news_fetcher.py --code 600519 --name Kweichow Moutai --token "${TUSHARE_TOKEN}" --days 7 --limit 20 --provider brave --brave-api-key "${BRAVE_API_KEY}" --output "${stock_dir}/news.json"
python scripts/sentiment_analyzer.py --input "${stock_dir}/news.json" --output "${stock_dir}/sentiment.json"Step 3: Run Financial Analysis
Step 3: Run Financial Analysis
bash
python scripts/financial_analyzer.py \
--input "${stock_dir}/stock_data.json" \
--level standard \
--output "${stock_dir}/analysis_result.json"或直接读取分模块目录(自动聚合):
bash
python scripts/financial_analyzer.py \
--input-dir "${stock_dir}/data" \
--level standard \
--output "${stock_dir}/analysis_result.json"参数说明:
- : 输入的股票数据文件
--input - : 分模块目录(自动读取并聚合为分析输入)
--input-dir - : 分析深度 (summary/standard/deep)
--level - : 输出文件
--output
bash
python scripts/financial_analyzer.py \\
--input "${stock_dir}/stock_data.json" \\
--level standard \\
--output "${stock_dir}/analysis_result.json"Or directly read module-wise directory (auto-aggregation):
bash
python scripts/financial_analyzer.py \\
--input-dir "${stock_dir}/data" \\
--level standard \\
--output "${stock_dir}/analysis_result.json"Parameter Explanation:
- : Input stock data file
--input - : Module-wise directory (auto-read and aggregate into analysis input)
--input-dir - : Analysis depth (summary/standard/deep)
--level - : Output file
--output
Step 4: Calculate Valuation
Step 4: Calculate Valuation
bash
python scripts/valuation_calculator.py \
--input "${stock_dir}/stock_data.json" \
--methods dcf,ddm,relative \
--discount-rate 10 \
--growth-rate 8 \
--output "${stock_dir}/valuation_result.json"参数说明:
- : 股票数据文件
--input - : 估值方法 (dcf/ddm/relative/all)
--methods - : 折现率(%)
--discount-rate - : 永续增长率(%)
--terminal-growth - : 永续增长率兼容别名(%)
--growth-rate - : 安全边际(%)
--margin-of-safety - : 输出格式 (json/table)
--format - : 静默模式
--quiet - : 输出文件
--output
bash
python scripts/valuation_calculator.py \\
--input "${stock_dir}/stock_data.json" \\
--methods dcf,ddm,relative \\
--discount-rate 10 \\
--growth-rate 8 \\
--output "${stock_dir}/valuation_result.json"Parameter Explanation:
- : Stock data file
--input - : Valuation methods (dcf/ddm/relative/all)
--methods - : Discount rate (%)
--discount-rate - : Perpetual growth rate (%)
--terminal-growth - : Compatible alias for perpetual growth rate (%)
--growth-rate - : Margin of safety (%)
--margin-of-safety - : Output format (json/table)
--format - : Silent mode
--quiet - : Output file
--output
Step 5: Generate Report
Step 5: Generate Report
读取分析结果,参考 模板生成中文分析报告。
templates/analysis_report.md报告生成必检项(必须全部满足):
0. 最终报告必须落盘为 Markdown 文件()
.md- 必须包含“新闻与舆情”章节
- 必须使用 中的
stock_data.json填充对应字段news_sentiment/news_items - 若新闻抓取失败,需在报告中明确写出失败原因(来自 )
news_sentiment.error - 不允许省略模板中 与“业绩与审计信号”章节
summary_title - 若 包含
stock_data.json,报告必须包含“实时指标看板”章节(趋势/确认/风险/筹码)realtime_metrics - 若 包含
stock_data.json,报告必须包含“事件窗口反应”内容(事件数、后1/3/5日收益、后1/3/5日超额收益)event_window - 若 存在,综合评分必须采用 财务40% + 实时60%(实时优先)
realtime_metrics
报告结构(标准级):
- 公司概况:基本信息、主营业务
- 财务健康:资产负债表分析
- 盈利能力:杜邦分析、利润率趋势
- 成长性分析:营收/利润增长趋势
- 实时指标看板:趋势/确认/风险/筹码
- 事件窗口分析:事件后收益与超额收益
- 估值分析:DCF/DDM/相对估值
- 风险提示:财务异常检测、股东减持
- 投资结论:综合评分、操作建议(实时优先)
报告标题规范:
- 使用格式:
summary_title股票名称(股票代码):总结性结论 - 示例:
贵州茅台(600519):财务稳健,估值与风险匹配度较好
输出文件:
${stock_dir}/final_report.mdRead analysis results and generate a Chinese analysis report referring to the template.
templates/analysis_report.mdMandatory Inspection Items for Report Generation (All must be satisfied):
0. The final report must be saved as a Markdown file ()
.md- Must include the "News & Sentiment" chapter
- Must use from
news_sentiment/news_itemsto fill corresponding fieldsstock_data.json - If news fetching fails, clearly state the failure reason in the report (from )
news_sentiment.error - Must not omit the and "Performance & Audit Signals" chapters in the template
summary_title - If contains
stock_data.json, the report must include the "Real-time Indicator Dashboard" chapter (trend/confirmation/risk/筹码)realtime_metrics - If contains
stock_data.json, the report must include "Event Window Reaction" content (number of events, 1/3/5-day returns after events, 1/3/5-day excess returns after events)event_window - If exists, the comprehensive score must adopt 40% Financial + 60% Real-time (real-time priority)
realtime_metrics
Report Structure (Standard Level):
- Company Overview: Basic information, main business
- Financial Health: Balance sheet analysis
- Profitability: DuPont analysis, profit margin trends
- Growth Analysis: Revenue/profit growth trends
- Real-time Indicator Dashboard: Trend/confirmation/risk/筹码
- Event Window Analysis: Post-event returns and excess returns
- Valuation Analysis: DCF/DDM/Relative Valuation
- Risk Warning: Financial anomaly detection, shareholder reduction
- Investment Conclusion: Comprehensive score, operation suggestions (real-time priority)
Report Title Specification:
- uses the format:
summary_titleStock Name(Stock Code): Summary Conclusion - Example:
Kweichow Moutai(600519): Financially Stable, Valuation and Risk Matching is Good
Output File:
${stock_dir}/final_report.mdStep 6: humanize Output
Step 6: Humanize Output
读取 ,并调用 skill 进行润色和优化。
${stock_dir}/final_report.mdhumanizer-zh输出文件:
${stock_dir}/final_report_humanized.mdRead and call the skill for polishing and optimization.
${stock_dir}/final_report.mdhumanizer-zhOutput File:
${stock_dir}/final_report_humanized.mdWorkflow 3: Industry Comparison (行业对比)
Workflow 3: Industry Comparison
CLI方式(板块分析,推荐)
CLI Method (Sector Analysis, Recommended)
bash
undefinedbash
undefined1) 获取板块数据
1) Fetch Sector Data
python scripts/sector_fetcher.py
--sector-name "算力板块"
--token "${TUSHARE_TOKEN}"
--sector-file config/sector_computing_default.json
--output "${stock_dir}/sector_data.json"
--sector-name "算力板块"
--token "${TUSHARE_TOKEN}"
--sector-file config/sector_computing_default.json
--output "${stock_dir}/sector_data.json"
python scripts/sector_fetcher.py \
--sector-name "Computing Power Sector" \
--token "${TUSHARE_TOKEN}" \
--sector-file config/sector_computing_default.json \
--output "${stock_dir}/sector_data.json"
2) 生成板块分析结果 + Markdown报告
2) Generate Sector Analysis Results + Markdown Report
python scripts/sector_analyze.py
--input "${stock_dir}/sector_data.json"
--output "${stock_dir}/sector_analysis.json"
--input "${stock_dir}/sector_data.json"
--output "${stock_dir}/sector_analysis.json"
undefinedpython scripts/sector_analyze.py \
--input "${stock_dir}/sector_data.json" \
--output "${stock_dir}/sector_analysis.json"
undefinedStep 1: Collect Comparison Targets
Step 1: Collect Comparison Targets
询问用户:
- 目标股票代码(可多个)
- 或者:行业分类 + 对比数量
Ask the user:
- Target stock codes (multiple allowed)
- Or: Industry classification + number of comparisons
Step 2: Fetch Industry Data
Step 2: Fetch Industry Data
bash
python scripts/data_fetcher.py \
--codes "600519,000858,002304" \
--token "${TUSHARE_TOKEN}" \
--data-type comparison \
--output industry_data.json或按行业获取:
bash
python scripts/data_fetcher.py \
--industry "白酒" \
--token "${TUSHARE_TOKEN}" \
--top 10 \
--output industry_data.jsonbash
python scripts/data_fetcher.py \\
--codes "600519,000858,002304" \\
--token "${TUSHARE_TOKEN}" \\
--data-type comparison \\
--output industry_data.jsonOr fetch by industry:
bash
python scripts/data_fetcher.py \\
--industry "Liquor" \\
--token "${TUSHARE_TOKEN}" \\
--top 10 \\
--output industry_data.jsonStep 3: Generate Comparison
Step 3: Generate Comparison
bash
python scripts/financial_analyzer.py \
--input industry_data.json \
--mode comparison \
--output comparison_result.jsonbash
python scripts/financial_analyzer.py \\
--input industry_data.json \\
--mode comparison \\
--output comparison_result.jsonStep 4: Present Comparison Table
Step 4: Present Comparison Table
| 指标 | 贵州茅台 | 五粮液 | 洋河股份 | 行业均值 |
|---|---|---|---|---|
| PE | 25.3 | 18.2 | 15.6 | 22.4 |
| ROE | 30.2% | 22.5% | 20.1% | 18.5% |
| 毛利率 | 91.5% | 75.2% | 72.3% | 65.4% |
| 评分 | 85 | 78 | 75 | - |
| Indicator | Kweichow Moutai | Wuliangye | Yanghe Co., Ltd. | Industry Average |
|---|---|---|---|---|
| PE | 25.3 | 18.2 | 15.6 | 22.4 |
| ROE | 30.2% | 22.5% | 20.1% | 18.5% |
| Gross Profit Margin | 91.5% | 75.2% | 72.3% | 65.4% |
| Score | 85 | 78 | 75 | - |
Workflow 4: Valuation Calculator (估值计算)
Workflow 4: Valuation Calculator
Step 1: Collect Valuation Parameters
Step 1: Collect Valuation Parameters
询问用户估值参数(或使用默认值):
DCF模型参数:
- 折现率 (WACC): 默认10%
- 预测期: 默认5年
- 永续增长率: 默认3%
DDM模型参数:
- 要求回报率: 默认10%
- 股息增长率: 使用历史数据推算
相对估值参数:
- 对比基准: 行业均值 / 历史均值
Ask the user for valuation parameters (or use default values):
DCF Model Parameters:
- Discount Rate (WACC): Default 10%
- Forecast Period: Default 5 years
- Perpetual Growth Rate: Default 3%
DDM Model Parameters:
- Required Rate of Return: Default 10%
- Dividend Growth Rate: Derived from historical data
Relative Valuation Parameters:
- Comparison Benchmark: Industry average / Historical average
Step 2: Run Valuation
Step 2: Run Valuation
bash
python scripts/valuation_calculator.py \
--code "600519" \
--methods all \
--discount-rate 10 \
--terminal-growth 3 \
--forecast-years 5 \
--margin-of-safety 30 \
--output valuation.jsonbash
python scripts/valuation_calculator.py \\
--code "600519" \\
--methods all \\
--discount-rate 10 \\
--terminal-growth 3 \\
--forecast-years 5 \\
--margin-of-safety 30 \\
--output valuation.jsonStep 3: Present Valuation Results
Step 3: Present Valuation Results
| 估值方法 | 内在价值 | 当前价格 | 安全边际价格 | 结论 |
|---|---|---|---|---|
| DCF | ¥2,150 | ¥1,680 | ¥1,505 | 低估 |
| DDM | ¥1,980 | ¥1,680 | ¥1,386 | 低估 |
| 相对估值 | ¥1,850 | ¥1,680 | ¥1,295 | 合理 |
| Valuation Method | Intrinsic Value | Current Price | Margin of Safety Price | Conclusion |
|---|---|---|---|---|
| DCF | ¥2,150 | ¥1,680 | ¥1,505 | Undervalued |
| DDM | ¥1,980 | ¥1,680 | ¥1,386 | Undervalued |
| Relative Valuation | ¥1,850 | ¥1,680 | ¥1,295 | Reasonable |
Financial Anomaly Detection (财务异常检测)
Financial Anomaly Detection
在分析过程中自动检测以下异常信号:
Automatically detect the following anomaly signals during analysis:
检测项目
Detection Items
-
应收账款异常
- 应收账款增速 > 营收增速 × 1.5
- 应收账款周转天数大幅增加
-
现金流背离
- 净利润持续增长但经营现金流下降
- 现金收入比 < 80%
-
存货异常
- 存货增速 > 营收增速 × 2
- 存货周转天数大幅增加
-
毛利率异常
- 毛利率波动 > 行业均值波动 × 2
- 毛利率与同行严重偏离
-
关联交易
- 关联交易占比过高(> 30%)
-
股东减持
- 大股东近期减持公告
- 高管集中减持
-
Abnormal Accounts Receivable
- Accounts receivable growth rate > Revenue growth rate × 1.5
- Significant increase in accounts receivable turnover days
-
Cash Flow Divergence
- Sustained net profit growth but declining operating cash flow
- Cash-to-income ratio < 80%
-
Abnormal Inventory
- Inventory growth rate > Revenue growth rate × 2
- Significant increase in inventory turnover days
-
Abnormal Gross Profit Margin
- Gross profit margin volatility > Industry average volatility × 2
- Severe deviation from peers' gross profit margin
-
Related Party Transactions
- High proportion of related party transactions (> 30%)
-
Shareholder Reduction
- Recent reduction announcements by major shareholders
- Concentrated reduction by executives
风险等级
Risk Levels
- 🟢 低风险:无明显异常
- 🟡 中风险:1-2项轻微异常
- 🔴 高风险:多项异常或严重异常
- 🟢 Low Risk: No obvious anomalies
- 🟡 Medium Risk: 1-2 minor anomalies
- 🔴 High Risk: Multiple anomalies or severe anomalies
A-Share Specific Analysis (A股特色分析)
A-Share Specific Analysis
政策敏感度
Policy Sensitivity
根据行业分类提供政策相关提示:
- 房地产:房住不炒政策
- 新能源:补贴政策变化
- 医药:集采政策影响
- 互联网:反垄断、数据安全
Provide policy-related prompts based on industry classification:
- Real Estate: "Houses are for living, not for speculation" policy
- New Energy: Changes in subsidy policies
- Pharmaceuticals: Impact of volume-based procurement policies
- Internet: Anti-monopoly, data security
股东结构分析
Shareholder Structure Analysis
- 控股股东类型(国企/民企/外资)
- 股权集中度
- 近期增减持情况
- 质押比例
- Controlling shareholder type (SOE/Private Enterprise/Foreign Capital)
- Ownership concentration
- Recent increase/reduction situations
- Pledge ratio
Output Format
Output Format
JSON/Table输出格式
JSON/Table Output Format
- 默认
json - 可选 用于终端快速查看
--format table - 使用 可关闭过程日志
--quiet
所有脚本输出JSON格式,便于后续处理:
json
{
"code": "600519",
"name": "贵州茅台",
"analysis_date": "2025-01-25",
"level": "standard",
"summary": {
"score": 85,
"conclusion": "低估",
"recommendation": "建议关注"
},
"financials": { ... },
"valuation": { ... },
"risks": [ ... ]
}- Default
json - Optional for quick terminal viewing
--format table - Use to disable process logs
--quiet
All scripts output JSON format for easy subsequent processing:
json
{
"code": "600519",
"name": "Kweichow Moutai",
"analysis_date": "2025-01-25",
"level": "standard",
"summary": {
"score": 85,
"conclusion": "Undervalued",
"recommendation": "Recommended to pay attention"
},
"financials": { ... },
"valuation": { ... },
"risks": [ ... ]
}Markdown报告
Markdown Report
生成结构化的中文Markdown报告,参考 。
templates/analysis_report.mdGenerate structured Chinese Markdown report, referring to .
templates/analysis_report.mdData Contract
Data Contract
核心数据结构由 约束。分析脚本会在运行前校验:
scripts/data_contract.py- 顶层必需字段:
code/fetch_time/data_type/basic_info - 常用可选字段:
financial_data/financial_indicators/valuation/price/holder/dividend - 新闻相关字段:
news_items/news_sentiment - 业绩审计字段:(含
performance_data)forecast/express/audit/main_business - 报表字段要求:
- 必须是数组
financial_data.balance_sheet - 必须是数组
financial_data.income_statement - 必须是数组
financial_data.cash_flow
Core data structures are constrained by . Analysis scripts will verify before running:
scripts/data_contract.py- Required top-level fields:
code/fetch_time/data_type/basic_info - Common optional fields:
financial_data/financial_indicators/valuation/price/holder/dividend - News-related fields:
news_items/news_sentiment - Performance audit fields: (including
performance_data)forecast/express/audit/main_business - Report field requirements:
- must be an array
financial_data.balance_sheet - must be an array
financial_data.income_statement - must be an array
financial_data.cash_flow
字段映射(Akshare -> Tushare)
Field Mapping (Akshare -> Tushare)
| 兼容语义 | 当前字段(推荐) | 兼容别名/来源 |
|---|---|---|
| PE(TTM) | | |
| PB | | - |
| 净利润 | | |
| 经营现金流净额 | | |
| 资本开支现金 | | |
| ROE | | |
| 资产负债率 | | |
| Compatible Semantics | Current Field (Recommended) | Compatible Aliases/Source |
|---|---|---|
| PE(TTM) | | |
| PB | | - |
| Net Profit | | |
| Net Operating Cash Flow | | |
| Capital Expenditure Cash | | |
| ROE | | |
| Asset-Liability Ratio | | |
Error Handling
Error Handling
网络错误
Network Errors
如果tushare数据获取失败,提示用户:
- 检查网络连接
- 稍后重试(可能是接口限流)
- 尝试更换数据源
If tushare data fetching fails, prompt the user:
- Check network connection
- Retry later (may be interface rate limiting)
- Try switching data sources
股票代码无效
Invalid Stock Code
提示用户检查股票代码是否正确,提供可能的匹配建议。
Prompt the user to check if the stock code is correct, and provide possible matching suggestions.
数据不完整
Incomplete Data
对于新上市股票或财务数据不完整的情况,说明数据限制并基于可用数据进行分析。
For newly listed stocks or those with incomplete financial data, explain the data limitations and perform analysis based on available data.
Best Practices
Best Practices
- 数据时效性:财务数据以最新季报/年报为准,价格数据为当日收盘价;开启 /
--with-realtime时补充趋势与事件冲击的动态指标--with-event-window - 投资建议:所有分析仅供参考,不构成投资建议
- 风险提示:始终包含风险提示,特别是财务异常检测结果
- 对比分析:单只股票分析时,自动包含行业均值对比
- 评分权重:实时数据存在时使用 ;实时缺失时退化为财务分
财务40% + 实时60%
- Data Timeliness: Financial data is based on the latest quarterly/annual report, price data is the closing price of the day; when /
--with-realtimeis enabled, supplement dynamic indicators of trends and event impacts--with-event-window - Investment Advice: All analysis is for reference only and does not constitute investment advice
- Risk Warning: Always include risk warnings, especially the results of financial anomaly detection
- Comparison Analysis: When analyzing a single stock, automatically include industry average comparison
- Scoring Weight: Use when real-time data exists; fallback to financial score when real-time data is missing
40% Financial + 60% Real-time
Important Notes
Important Notes
- 所有分析基于公开财务数据,不涉及任何内幕信息
- 估值模型的参数假设对结果影响较大,需向用户说明
- A股市场受政策影响较大,定量分析需结合定性判断
- All analysis is based on public financial data and does not involve any insider information
- Parameter assumptions of valuation models have a significant impact on results, which should be explained to users
- The A-share market is greatly affected by policies, so quantitative analysis should be combined with qualitative judgments ",