Skip to main content

DCF-skill

投行级 DCF + 相对估值 + SOTP 三方法估值引擎,专为 Trae MCP 数据源设计。

它能做什么

对任意公开市场股票(A 股 / 港股 / 美股)产出结构化估值报告:

  • DCF(5 年显式预测 + Gordon + Exit Multiple 双法 TV)
  • 相对估值(4-6 家可比公司 + median 多倍 + ±10-30% 调整)
  • SOTP(可选,2+ 业务分部)
  • 三方法综合(加权公允价 vs 当前价 + 隐含上行 / 下行)
  • 风险分析(3 个 Gate 检查 + Bull/Base/Bear 情景 + 5+ 关键风险)
  • 数据质量警告(自动检测 Beta 异常、估值字段过期、字段缺失)

快速开始

安装依赖(可选)

只有 yfinance 是可选的,Trae MCP 是 backend 调用,不需安装额外 Python 包。

pip install yfinance  # 可选,如果你的环境没有

命令行

# A 股
python -m src.cli --ticker 600519.SH

# 美股
python -m src.cli --ticker AAPL

# 港股
python -m src.cli --ticker 02899.HK

# A+H 双重上市矿业股,显式 AH 折价
python -m src.cli --ticker 601899.SH --ah-discount 0.20

# 自定义数据源 / 输出格式
python -m src.cli --ticker NVDA --source emoney_us --report md,json

Python 模块

from src.dcf_engine import Valuation
from src.industry_router import IndustryRouter

router = IndustryRouter()
defaults = router.get_defaults("AAPL")   # 自动判断 GICS 行业
v = Valuation(ticker="AAPL", data_source="emoney_us", defaults=defaults)
result = v.run()
print(result.summary())

在 Trae 中作为 Skill

把仓库克隆/复制到 Trae 工作区的 .trae/skills/dcf-valuation/ 下,Trae 会自动加载 SKILL.md 并匹配触发词。

数据源策略

标的 数据源 Fallback
A 股 东方财富 MCP(mx_ashare_finance_data + mx_stocks_screener) 通达信实时行情
港股 东方财富 MCP(mx_hk_finance_data) —
美股 东方财富 MCP(mx_us_finance_data) 通达信(部分 ticker)

所有数据来自 Trae 自带 MCP,无外部依赖。

执行步骤

按 references/methodology.md 严格执行 8 步,任意一步缺失会在报告中标注 ⚠:

Step 0  Data Quality Check(自动)
Step 1  Detection & Path Selection
Step 2  Defaults by GICS Industry
Step 3  Pull Data(营收 / 利润 / 三表 / 估值)
Step 4  DCF(5 年预测 + 双法 TV)
Step 5  Relative Valuation(可比公司 + 中位倍数 + 调整)
Step 6  SOTP(若适用)
Step 7  Combine(40/30/30)
Step 8  Output(Markdown + JSON)

每个 Step 详见 references/:

文件 内容
references/methodology.md 完整方法论,8 步详解
references/wacc_sanity_bands.md GICS 11 大类行业 WACC sanity band
references/industry_overrides.md 周期 / 高增长 / 稳态 3 大特征分类指导
references/mid_cycle_treatment.md 周期股 mid-cycle 平滑方法
references/terminal_value_methods.md 双法 TV(Gordon + Exit Multiple)+ 中点
references/dual_listed_discount.md A+H 双重上市折价规则

Gate 检查(自动)

Gate 条件 不满足后果
(a) WACC > g 折现率必须大于永续增长率 终止,提示 g 过高
(b) TV/EV ∈ [45%, 85%] 终值占 EV 比例 标注 ⚠,提示过度依赖终值
(c) WACC 行业 sanity band 按 GICS 行业 ±1pp 标注 ⚠,提示参数需复核

测试

pytest tests/

回归测试覆盖:

  • test_dcf_engine.py — DCF 计算正确性(Gordon、Exit、双法中点、敏感性)
  • test_data_sources.py — 数据源适配器契约(无实际网络访问)
  • test_industry_router.py — 行业路由(11 GICS × 3 特征)

实战案例

完整跑通的真实报告(2026-09-21):

License

MIT

Metadata

Release files for dcf-skill 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for dcf-skill 1.0.0
File Interpreter ABI Platform Actions
dcf_skill-1.0.0-py3-none-any.whl Python 3 none any Details for dcf_skill-1.0.0-py3-none-any.whl

Release files / dcf_skill-1.0.0-py3-none-any.whl

Download URL dcf_skill-1.0.0-py3-none-any.whl
Size 33.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c41fd4b70adcab96338ef2423faa11dc11da277bf3867e26b61c738c2376044a
BLAKE2b-256 checksum
How to use checksums
bda7fb0623fa8f5b8936c985855605c95b0ffec49f557ae133c0fe44a757326c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Security for dcf-skill 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page