aj-stock-analysis

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

China 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 numpy
All script commands should be run in the project virtual environment.
bash
python3 -m venv .venv
source .venv/bin/activate
Install Dependencies:
bash
pip install tushare pandas numpy

Environment 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
说明:
  • .venv
    必须位于 skill 项目根目录下(不是全局目录)
  • import tushare
    失败,必须先执行上述 bootstrap,再继续后续分析流程
TUSHARE_TOKEN
/
BRAVE_API_KEY
建议保存在
~/.aj-skills/.env
,并在执行前先加载到当前 shell:
bash
set -a
source ~/.aj-skills/.env
set +a
说明:
  • 脚本不会自动读取
    ~/.aj-skills/.env
  • 必须通过 CLI 参数显式传入:
    --token "${TUSHARE_TOKEN}"
    --brave-api-key "${BRAVE_API_KEY}"
执行前参数预检(使用
test
命令):
bash
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 numpy
Notes:
  • .venv
    must be located in the root directory of the skill project (not a global directory)
  • If
    import tushare
    fails, the above bootstrap must be executed first before proceeding with subsequent analysis processes
TUSHARE_TOKEN
/
BRAVE_API_KEY
are recommended to be stored in
~/.aj-skills/.env
, and loaded into the current shell before execution:
bash
set -a
source ~/.aj-skills/.env
set +a
Notes:
  • 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
test
command):
bash
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; }
undefined
test -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
参数说明:
  • --scope
    : 筛选范围 (all/hs300/zz500/cyb/kcb/custom:600519,000858,...)
  • --pe-max/--pe-min
    : PE范围
  • --pb-max/--pb-min
    : PB范围
  • --roe-min
    : 最低ROE
  • --growth-min
    : 最低增长率
  • --debt-ratio-max
    : 最大资产负债率
  • --dividend-min
    : 最低股息率
  • --token
    : tushare token(必填)
  • --format
    : 输出格式 (json/table)
  • --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.json
Parameter Explanation:
  • --scope
    : Screening scope (all/hs300/zz500/cyb/kcb/custom:600519,000858,...)
  • --pe-max/--pe-min
    : PE range
  • --pb-max/--pb-min
    : PB range
  • --roe-min
    : Minimum ROE
  • --growth-min
    : Minimum growth rate
  • --debt-ratio-max
    : Maximum asset-liability ratio
  • --dividend-min
    : Minimum dividend yield
  • --token
    : tushare token (required)
  • --format
    : Output format (json/table)
  • --quiet
    : Silent mode
  • --output
    : Output file path

Step 3: Present Results

Step 3: Present Results

读取
screening_result.json
并以表格形式呈现给用户:
代码名称PEPBROE股息率评分
600519贵州茅台25.38.530.2%2.1%85

Read
screening_result.json
and present to the user in table format:
CodeNamePEPBROEDividend YieldScore
600519Kweichow Moutai25.38.530.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. 股票代码或名称
  2. 分析深度级别:
    • 摘要级:关键指标 + 投资结论(1页)
    • 标准级:财务分析 + 估值 + 行业对比 + 风险提示
    • 深度级:完整调研报告,包含历史数据追踪
Ask the user:
  1. Stock code or name
  2. 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"
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"
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"
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"
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"
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"

兼容模式(单命令抓取)保留如下:

```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
    : 股票代码
  • --data-type
    : 数据类型 (basic/financial/valuation/holder/news/all)
  • --years
    : 获取多少年的历史数据
  • --token
    : tushare token(必填)
  • --with-news
    : 附加新闻与舆情
  • --news-days
    : 新闻窗口天数
  • --news-limit
    : 新闻最大条数
  • --news-sources
    : 新闻来源过滤(逗号分隔)
  • --news-provider
    : 新闻源 (auto/brave/tushare/rss)
  • --brave-api-key
    : Brave Search API Key(
    news-provider=brave
    时必填)
  • --with-realtime
    : 附加实时指标(趋势/确认/风险/筹码)
  • --with-event-window
    : 附加事件窗口分析(事件后1/3/5日反应)
  • --benchmark
    : 相对强弱基准指数 (hs300/zz500/zz1000/cyb/kcb)
  • --realtime-window
    : 实时指标计算窗口(日)
  • --event-window-pre
    : 事件窗口前置天数
  • --event-window-post
    : 事件窗口后验天数(逗号分隔)
  • --cache-ttl-min
    : 缓存有效期(分钟)
  • --format
    : 输出格式 (json/table)
  • --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:
  • --code
    : Stock code
  • --data-type
    : Data type (basic/financial/valuation/holder/news/all)
  • --years
    : Number of years of historical data to fetch
  • --token
    : tushare token (required)
  • --with-news
    : Attach news and sentiment data
  • --news-days
    : News window days
  • --news-limit
    : Maximum number of news items
  • --news-sources
    : News source filter (comma-separated)
  • --news-provider
    : News source (auto/brave/tushare/rss)
  • --brave-api-key
    : Brave Search API Key (required when
    news-provider=brave
    )
  • --with-realtime
    : Attach real-time indicators (trend/confirmation/risk/筹码)
  • --with-event-window
    : Attach event window analysis (1/3/5-day reaction after events)
  • --benchmark
    : Relative strength benchmark index (hs300/zz500/zz1000/cyb/kcb)
  • --realtime-window
    : Real-time indicator calculation window (days)
  • --event-window-pre
    : Event window pre-days
  • --event-window-post
    : Event window post-days (comma-separated)
  • --cache-ttl-min
    : Cache validity period (minutes)
  • --format
    : Output format (json/table)
  • --quiet
    : Silent mode
  • --output
    : Output file

可选:单独执行新闻舆情流程

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
    : 分模块目录(自动读取并聚合为分析输入)
  • --level
    : 分析深度 (summary/standard/deep)
  • --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
    : Input stock data file
  • --input-dir
    : Module-wise directory (auto-read and aggregate into analysis input)
  • --level
    : Analysis depth (summary/standard/deep)
  • --output
    : Output file

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
    : 股票数据文件
  • --methods
    : 估值方法 (dcf/ddm/relative/all)
  • --discount-rate
    : 折现率(%)
  • --terminal-growth
    : 永续增长率(%)
  • --growth-rate
    : 永续增长率兼容别名(%)
  • --margin-of-safety
    : 安全边际(%)
  • --format
    : 输出格式 (json/table)
  • --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:
  • --input
    : Stock data file
  • --methods
    : Valuation methods (dcf/ddm/relative/all)
  • --discount-rate
    : Discount rate (%)
  • --terminal-growth
    : Perpetual growth rate (%)
  • --growth-rate
    : Compatible alias for perpetual growth rate (%)
  • --margin-of-safety
    : Margin of safety (%)
  • --format
    : Output format (json/table)
  • --quiet
    : Silent mode
  • --output
    : Output file

Step 5: Generate Report

Step 5: Generate Report

读取分析结果,参考
templates/analysis_report.md
模板生成中文分析报告。
报告生成必检项(必须全部满足): 0. 最终报告必须落盘为 Markdown 文件(
.md
  1. 必须包含“新闻与舆情”章节
  2. 必须使用
    stock_data.json
    中的
    news_sentiment/news_items
    填充对应字段
  3. 若新闻抓取失败,需在报告中明确写出失败原因(来自
    news_sentiment.error
  4. 不允许省略模板中
    summary_title
    与“业绩与审计信号”章节
  5. stock_data.json
    包含
    realtime_metrics
    ,报告必须包含“实时指标看板”章节(趋势/确认/风险/筹码)
  6. stock_data.json
    包含
    event_window
    ,报告必须包含“事件窗口反应”内容(事件数、后1/3/5日收益、后1/3/5日超额收益)
  7. realtime_metrics
    存在,综合评分必须采用 财务40% + 实时60%(实时优先)
报告结构(标准级):
  1. 公司概况:基本信息、主营业务
  2. 财务健康:资产负债表分析
  3. 盈利能力:杜邦分析、利润率趋势
  4. 成长性分析:营收/利润增长趋势
  5. 实时指标看板:趋势/确认/风险/筹码
  6. 事件窗口分析:事件后收益与超额收益
  7. 估值分析:DCF/DDM/相对估值
  8. 风险提示:财务异常检测、股东减持
  9. 投资结论:综合评分、操作建议(实时优先)
报告标题规范:
  • summary_title
    使用格式:
    股票名称(股票代码):总结性结论
  • 示例:
    贵州茅台(600519):财务稳健,估值与风险匹配度较好
输出文件:
${stock_dir}/final_report.md
Read analysis results and generate a Chinese analysis report referring to the
templates/analysis_report.md
template.
Mandatory Inspection Items for Report Generation (All must be satisfied): 0. The final report must be saved as a Markdown file (
.md
)
  1. Must include the "News & Sentiment" chapter
  2. Must use
    news_sentiment/news_items
    from
    stock_data.json
    to fill corresponding fields
  3. If news fetching fails, clearly state the failure reason in the report (from
    news_sentiment.error
    )
  4. Must not omit the
    summary_title
    and "Performance & Audit Signals" chapters in the template
  5. If
    stock_data.json
    contains
    realtime_metrics
    , the report must include the "Real-time Indicator Dashboard" chapter (trend/confirmation/risk/筹码)
  6. If
    stock_data.json
    contains
    event_window
    , 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)
  7. If
    realtime_metrics
    exists, the comprehensive score must adopt 40% Financial + 60% Real-time (real-time priority)
Report Structure (Standard Level):
  1. Company Overview: Basic information, main business
  2. Financial Health: Balance sheet analysis
  3. Profitability: DuPont analysis, profit margin trends
  4. Growth Analysis: Revenue/profit growth trends
  5. Real-time Indicator Dashboard: Trend/confirmation/risk/筹码
  6. Event Window Analysis: Post-event returns and excess returns
  7. Valuation Analysis: DCF/DDM/Relative Valuation
  8. Risk Warning: Financial anomaly detection, shareholder reduction
  9. Investment Conclusion: Comprehensive score, operation suggestions (real-time priority)
Report Title Specification:
  • summary_title
    uses the format:
    Stock Name(Stock Code): Summary Conclusion
  • Example:
    Kweichow Moutai(600519): Financially Stable, Valuation and Risk Matching is Good
Output File:
${stock_dir}/final_report.md

Step 6: humanize Output

Step 6: Humanize Output

读取
${stock_dir}/final_report.md
,并调用
humanizer-zh
skill 进行润色和优化。
输出文件:
${stock_dir}/final_report_humanized.md

Read
${stock_dir}/final_report.md
and call the
humanizer-zh
skill for polishing and optimization.
Output File:
${stock_dir}/final_report_humanized.md

Workflow 3: Industry Comparison (行业对比)

Workflow 3: Industry Comparison

CLI方式(板块分析,推荐)

CLI Method (Sector Analysis, Recommended)

bash
undefined
bash
undefined

1) 获取板块数据

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"
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"
undefined
python scripts/sector_analyze.py \ --input "${stock_dir}/sector_data.json" \ --output "${stock_dir}/sector_analysis.json"
undefined

Step 1: Collect Comparison Targets

Step 1: Collect Comparison Targets

询问用户:
  1. 目标股票代码(可多个)
  2. 或者:行业分类 + 对比数量
Ask the user:
  1. Target stock codes (multiple allowed)
  2. 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.json
bash
python scripts/data_fetcher.py \\
    --codes "600519,000858,002304" \\
    --token "${TUSHARE_TOKEN}" \\
    --data-type comparison \\
    --output industry_data.json
Or fetch by industry:
bash
python scripts/data_fetcher.py \\
    --industry "Liquor" \\
    --token "${TUSHARE_TOKEN}" \\
    --top 10 \\
    --output industry_data.json

Step 3: Generate Comparison

Step 3: Generate Comparison

bash
python scripts/financial_analyzer.py \
    --input industry_data.json \
    --mode comparison \
    --output comparison_result.json
bash
python scripts/financial_analyzer.py \\
    --input industry_data.json \\
    --mode comparison \\
    --output comparison_result.json

Step 4: Present Comparison Table

Step 4: Present Comparison Table

指标贵州茅台五粮液洋河股份行业均值
PE25.318.215.622.4
ROE30.2%22.5%20.1%18.5%
毛利率91.5%75.2%72.3%65.4%
评分857875-

IndicatorKweichow MoutaiWuliangyeYanghe Co., Ltd.Industry Average
PE25.318.215.622.4
ROE30.2%22.5%20.1%18.5%
Gross Profit Margin91.5%75.2%72.3%65.4%
Score857875-

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.json
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.json

Step 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 MethodIntrinsic ValueCurrent PriceMargin of Safety PriceConclusion
DCF¥2,150¥1,680¥1,505Undervalued
DDM¥1,980¥1,680¥1,386Undervalued
Relative Valuation¥1,850¥1,680¥1,295Reasonable

Financial Anomaly Detection (财务异常检测)

Financial Anomaly Detection

在分析过程中自动检测以下异常信号:
Automatically detect the following anomaly signals during analysis:

检测项目

Detection Items

  1. 应收账款异常
    • 应收账款增速 > 营收增速 × 1.5
    • 应收账款周转天数大幅增加
  2. 现金流背离
    • 净利润持续增长但经营现金流下降
    • 现金收入比 < 80%
  3. 存货异常
    • 存货增速 > 营收增速 × 2
    • 存货周转天数大幅增加
  4. 毛利率异常
    • 毛利率波动 > 行业均值波动 × 2
    • 毛利率与同行严重偏离
  5. 关联交易
    • 关联交易占比过高(> 30%)
  6. 股东减持
    • 大股东近期减持公告
    • 高管集中减持
  1. Abnormal Accounts Receivable
    • Accounts receivable growth rate > Revenue growth rate × 1.5
    • Significant increase in accounts receivable turnover days
  2. Cash Flow Divergence
    • Sustained net profit growth but declining operating cash flow
    • Cash-to-income ratio < 80%
  3. Abnormal Inventory
    • Inventory growth rate > Revenue growth rate × 2
    • Significant increase in inventory turnover days
  4. Abnormal Gross Profit Margin
    • Gross profit margin volatility > Industry average volatility × 2
    • Severe deviation from peers' gross profit margin
  5. Related Party Transactions
    • High proportion of related party transactions (> 30%)
  6. 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

  1. 控股股东类型(国企/民企/外资)
  2. 股权集中度
  3. 近期增减持情况
  4. 质押比例

  1. Controlling shareholder type (SOE/Private Enterprise/Foreign Capital)
  2. Ownership concentration
  3. Recent increase/reduction situations
  4. 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
    --format table
    for quick terminal viewing
  • Use
    --quiet
    to disable process logs
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.md

Generate structured Chinese Markdown report, referring to
templates/analysis_report.md
.

Data 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
scripts/data_contract.py
. Analysis scripts will verify before running:
  • 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:
    performance_data
    (including
    forecast/express/audit/main_business
    )
  • Report field requirements:
    • financial_data.balance_sheet
      must be an array
    • financial_data.income_statement
      must be an array
    • financial_data.cash_flow
      must be an array

字段映射(Akshare -> Tushare)

Field Mapping (Akshare -> Tushare)

兼容语义当前字段(推荐)兼容别名/来源
PE(TTM)
valuation.latest.pe_ttm
valuation.latest.pe
PB
valuation.latest.pb
-
净利润
financial_data.income_statement[].净利润
n_income
经营现金流净额
financial_data.cash_flow[].经营活动产生的现金流量净额
n_cashflow_act
资本开支现金
financial_data.cash_flow[].购建固定资产、无形资产和其他长期资产支付的现金
c_pay_acq_const_fiolta
ROE
financial_indicators[].净资产收益率
roe
资产负债率
financial_indicators[].资产负债率
debt_to_assets

Compatible SemanticsCurrent Field (Recommended)Compatible Aliases/Source
PE(TTM)
valuation.latest.pe_ttm
valuation.latest.pe
PB
valuation.latest.pb
-
Net Profit
financial_data.income_statement[].净利润
n_income
Net Operating Cash Flow
financial_data.cash_flow[].经营活动产生的现金流量净额
n_cashflow_act
Capital Expenditure Cash
financial_data.cash_flow[].购建固定资产、无形资产和其他长期资产支付的现金
c_pay_acq_const_fiolta
ROE
financial_indicators[].净资产收益率
roe
Asset-Liability Ratio
financial_indicators[].资产负债率
debt_to_assets

Error Handling

Error Handling

网络错误

Network Errors

如果tushare数据获取失败,提示用户:
  1. 检查网络连接
  2. 稍后重试(可能是接口限流)
  3. 尝试更换数据源
If tushare data fetching fails, prompt the user:
  1. Check network connection
  2. Retry later (may be interface rate limiting)
  3. 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

  1. 数据时效性:财务数据以最新季报/年报为准,价格数据为当日收盘价;开启
    --with-realtime
    /
    --with-event-window
    时补充趋势与事件冲击的动态指标
  2. 投资建议:所有分析仅供参考,不构成投资建议
  3. 风险提示:始终包含风险提示,特别是财务异常检测结果
  4. 对比分析:单只股票分析时,自动包含行业均值对比
  5. 评分权重:实时数据存在时使用
    财务40% + 实时60%
    ;实时缺失时退化为财务分
  1. Data Timeliness: Financial data is based on the latest quarterly/annual report, price data is the closing price of the day; when
    --with-realtime
    /
    --with-event-window
    is enabled, supplement dynamic indicators of trends and event impacts
  2. Investment Advice: All analysis is for reference only and does not constitute investment advice
  3. Risk Warning: Always include risk warnings, especially the results of financial anomaly detection
  4. Comparison Analysis: When analyzing a single stock, automatically include industry average comparison
  5. Scoring Weight: Use
    40% Financial + 60% Real-time
    when real-time data exists; fallback to financial score when real-time data is missing

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 ",