报告类型典型用途关键章节首次覆盖报告 (Initiation)新覆盖公司首份深度报告全部章节 + DCF 估值季度业绩点评 (Earnings Update)财报发布后快速更新执行摘要 + KPI + 财务表 + 评级表行业深度报告 (Industry Deep Dive)子行业/赛道全景分析产业链 + 铲子股 + 情景分析买方投资备忘录 (Buy-side Memo)PM/IC 会议前简报论点图表 + 估值桥 + 敏感性估值专题 (Valuation Deep Dive)DCF / SOTP / 可比公司深度WACC + 敏感性 + 可比公司 + 估值桥管理层会前简报 (Pre-meeting Brief)路演/管理层会议准备论点图表 + 关键问题 + 风险
本生成器按照 Morgan Stanley 卖方研究报告标准模板,按以下顺序渲染全部章节(缺失数据字段自动跳过):
基于 matplotlib 的出版级图表渲染引擎:
DPI 300 高清输出
MS 8色调色板:Deep Navy / Medium Blue / Gold / Green / Orange / Red / Purple / Light Blue
4 种图表类型:
bar -- 收入&EBITDA 双柱对比图(含均值参考线 + 数值标签)line -- 毛利率/EBITDA利润率/净利率折线图(含面积填充 + 数据标签)pie -- 行业配置饼图(含最大扇区突出 + 图例)waterfall -- 估值桥梁图(当前价 -> 目标价归因拆解,含连接线)Source 水印:每张图表底部自动添加 "Source: Morgan Stanley Research"
降级机制:matplotlib 未安装时自动降级为文字占位
全局 Exhibit 计数器,按渲染顺序自动编号:
Exhibit 1: 标题 / Exhibit 2: 标题 ...make_report() 自动重置主题主色辅助色风格classic#0B2C5C 深蓝#C8A951 金色MS 传统深蓝+金
颜色体系包含 30+ 语义化颜色常量,覆盖:
zh -- 中文报告(章节标题中文)en -- 英文报告(章节标题英文)bilingual -- 双语报告(章节标题中英双语)python
from ms_research_report import make_report
data = {
"company_name": "极光资本控股",
"title_cn": "为下一个10倍科技周期,资本是瓶颈吗?",
"title_en": "Financing the Next 10x Tech Cycle",
"subtitle": "关键论点一句话:算力军备竞赛将重塑上游资本开支结构。",
"rating": "Overweight",
"target_price": 125.0,
"current_price": 98.5,
"date_str": "2026-06-12",
"analyst": "陈嘉怡 CFA",
"research_type": "Foundation",
"currency": "USD",
"key_takeaways": [
"算力需求在未来三年预计以 35% CAGR 扩张。",
"上游芯片与光模块厂商最受益。",
"估值溢价将集中于具备专有硅片与供应渠道的企业。",
],
"executive_summary": {
"thesis": ["论点1", "论点2", "论点3"],
"tp_and_upside": ["目标价 $125.0,上行 +27%。"],
"risks": ["风险1", "风险2"],
"catalysts": ["催化剂1", "催化剂2"],
},
"sections": [
{
"title_cn": "一、算力需求:结构性扩张",
"title_en": "I. Compute Demand",
"paragraphs": ["段落1", "段落2"],
"subsections": [
{"title": "1.1 子章节", "paragraphs": ["子段落1"]},
],
},
],
"metrics": [
{"value": "$5.2T", "unit": "TAM 2026E", "label": "市场规模"},
{"value": "35%", "unit": "CAGR '24-'28", "label": "复合增长"},
],
"financial_table": {
"headers": ["指标", "FY24", "FY25E", "FY26E", "FY27E"],
"rows": [
["营业收入 ($M)", "4,810", "5,230", "5,750", "6,520"],
["毛利率 (%)", "52.1", "54.0", "55.5", "56.8"],
["EBITDA ($M)", "1,210", "1,405", "1,580", "1,820"],
],
"highlight_rows": [3],
"auto_yoy": True,
"source": "Source: Morgan Stanley Research.",
},
"rating_table": [
["Ticker", "Rating", "Last Close", "Company", "Reason"],
["NVDA.O", "OW", "198.35", "Nvidia", "AI compute leader"],
],
}
make_report(data, "output/report.docx", theme="classic", language="zh")
bash
# 使用内置示例数据生成报告
python scripts/run.py -o output/test_report.docx
# 使用自定义 JSON 数据文件
python scripts/run.py -o output/my_report.docx -d data.json
标准报告的章节渲染顺序(缺失数据自动跳过):
text
封面页 (Cover Page)
|
目录 (Table of Contents)
|
Our Thesis in N Charts [可选]
|
执行摘要 (Executive Summary)
|
正文章节 (Sections) x N
|
KPI 指标块 (Key Metrics)
|
财务数据表 (Financial Table)
|
财务图表 (Financial Charts) [可选,需 matplotlib]
|
评级表格 (Rating Table)
|
60 铲子股列表 (Shovel Stocks)
|
产业链/价值链 (Value Chain) [可选]
|
铲子股详细列表 (Shovel Stocks List) [可选]
|
情景对比分析 (Scenario Comparison) [可选]
|
WACC 拆解 (WACC Breakdown) [可选]
|
敏感性分析矩阵 (Sensitivity Analysis) [可选]
|
可比公司分析 (Comparable Companies) [可选]
|
估值桥 (Valuation Bridge / Waterfall) [可选]
|
Exhibit 附录图表 [可选]
|
附录 (Appendix)
|
免责声明 (Disclosure)
字段类型必填说明company_namestr否公司名称(封面)title_cnstr推荐*中文标题(封面)title_enstr推荐*英文标题(封面)subtitlestr否副标题/一句话论点ratingstr否评级:Overweight / Equal-weight / Underweighttarget_pricefloat否目标价current_pricefloat否当前价格date_strstr否报告日期(YYYY-MM-DD)analyststr否分析师姓名analyst_titlestr否分析师头衔analyst_emailstr否分析师邮箱industrystr否行业名称entitystr否实体/部门名称research_typestr否研究类型:Foundation / Update / Flashcurrencystr否货币单位(默认 USD)languagestr否语言:zh / en / bilingual
*
title_cn和title_en至少提供一个。
字段类型说明key_takeawayslist[str]Key Takeaways 要点列表executive_summary.thesislist[str]投资论点executive_summary.tp_and_upsidelist[str]目标价与上行空间executive_summary.riskslist[str]风险因素executive_summary.catalystslist[str]催化剂
字段类型说明sectionslist[dict]章节列表sections[].title_cnstr中文标题sections[].title_enstr英文标题sections[].paragraphslist[str]段落文本(支持 • 要点)sections[].subsectionslist[dict]子章节(同结构)
字段类型说明metricslist[dict]KPI 卡片列表metrics[].valuestr指标值(如 "$5.2T")metrics[].unitstr单位(如 "TAM 2026E")metrics[].labelstr标签(如 "市场规模")
字段类型说明financial_table.headerslist[str]表头(指标 + 年份)financial_table.rowslist[list]数据行financial_table.highlight_rowslist[int]需高亮的行索引(0-based)financial_table.auto_yoybool是否自动计算 YoY 变化financial_table.sourcestr数据来源注释
字段类型说明rating_tablelist[list]二维表格,首行为表头
字段类型说明shovel_stockslist[dict]铲子股列表shovel_stocks[].rankint排名shovel_stocks[].companystr公司名称shovel_stocks[].tickerstr股票代码shovel_stocks[].productstr产品/服务shovel_stocks[].analyststr覆盖分析师shovel_stocks[].market_cap_mnfloat市值(百万)shovel_stocks[].perf_1y_pctfloat年度涨幅(%)
字段类型说明financial_chart.labelslist[str]年份标签financial_chart.revenuelist[float]收入数据financial_chart.ebitdalist[float]EBITDA 数据financial_chart.gross_marginlist[float]毛利率financial_chart.ebitda_marginlist[float]EBITDA 利润率financial_chart.net_marginlist[float]净利率
字段类型说明sectors_allocation.titlestr标题sectors_allocation.labelslist[str]行业标签sectors_allocation.valueslist[float]配置比例
字段类型说明thesis_chartslist[dict]论点图表列表thesis_charts[].titlestr图表标题thesis_charts[].typestr图表类型(bar/line/pie/waterfall)thesis_charts[].kpi_cardslist[dict]KPI 卡片thesis_charts[].kpi_cards[].valuestr卡片值thesis_charts[].kpi_cards[].labelstr卡片标签
字段类型说明value_chain.titlestr标题value_chain.layerslist[dict]产业链层级value_chain.layers[].namestr层级名称value_chain.layers[].itemslist[str]层级内项目
字段类型说明scenario_comparisondictBear/Base/Bull 情景数据waccdictWACC 拆解数据sensitivitydict敏感性分析矩阵数据compsdict可比公司数据valuation_bridgedict估值桥数据
字段类型说明exhibitslist[dict]Exhibit 图表列表exhibits[].image_pathstr图片路径exhibits[].titlestr图表标题appendix.contentstr附录内容disclosure.textstr免责声明文本
python
MS_PALETTE = [
'#1F3864', # Deep Navy -- 主色
'#2E75B6', # Medium Blue -- 辅色
'#C8A951', # Gold -- 强调
'#00AF50', # Green -- 正面
'#E37C2B', # Orange -- 中性
'#B91C1C', # Red -- 负面
'#6B4C9A', # Purple -- 辅助
'#4A90D9', # Light Blue -- 辅助
]
bar(双柱对比图)
python
{"type": "bar", "title": "Revenue vs EBITDA",
"labels": ["FY24", "FY25E", "FY26E"],
"revenue": [4810, 5230, 5750],
"ebitda": [1210, 1405, 1580]}
line(利润率折线图)
python
{"type": "line", "title": "Margin Trends",
"labels": ["FY24", "FY25E", "FY26E"],
"gross_margin": [52.1, 54.0, 55.5],
"ebitda_margin": [25.2, 26.9, 27.5],
"net_margin": [18.5, 19.8, 21.0]}
pie(行业配置饼图)
python
{"type": "pie", "title": "Sector Allocation",
"labels": ["半导体", "光模块", "IDC"],
"values": [40.0, 25.0, 10.0]}
waterfall(估值桥瀑布图)
python
{"type": "waterfall", "title": "Valuation Bridge",
"labels": ["Base Business", "Growth", "Multiple Expansion", "FX"],
"values": [15.0, 8.5, 3.0, 0.0],
"current": 98.5, "target": 125.0}
#E8E8E8Exhibit 编号系统使用全局计数器,按渲染顺序自动递增:
text
Exhibit 1: 收入与 EBITDA 对比
Exhibit 2: 利润率趋势
Exhibit 3: 行业配置
Exhibit 4: WACC 拆解
Exhibit 5: 估值桥
Exhibit 6: [附录图表标题]
make_report() 时计数器自动重置为 1_next_exhibit_label(title) -> "Exhibit N: title""Source: Morgan Stanley Research"当前支持 1 套主题,颜色体系包含 30+ 语义化常量:
颜色类别色值用途MS Navy#0B2C5C品牌主色、封面背景MS Gold#C8A951强调色、分隔线Brand Blue#00559F标题强调OW Green#1F7A3EOverweight 评级EW Orange#D97706Equal-weight 评级UW Red#B91C1CUnderweight 评级Deep Navy#1F3864DCF 主标题背景Medium Blue#2E75B6DCF 表头背景Input BG#FFF2CC输入假设行背景Calc BG#E2EFDA关键计算行背景Summary BG#D9E1F2汇总行背景CapEx BG#FCE4D6CapEx 行背景
make_report(data, output_path, theme, language)#主入口函数,生成完整的 MS 风格研究报告 DOCX。
python
def make_report(
data: Dict[str, Any], # 报告数据字典(所有字段可选)
output_path: str, # 输出 .docx 文件路径(需确保父目录存在)
theme: str = "classic", # 主题名称(当前仅支持 "classic")
language: str = "zh", # 语言:zh / en / bilingual
) -> str: # 返回 output_path
参数说明:
data -- 完整数据字典,字段均为可选。缺失字段对应章节自动跳过。output_path -- 输出路径。 调用者需确保父目录已存在。theme -- 主题名称,默认 "classic"(深蓝+金)。language -- 语言设置,默认 "zh"。章节标题按语言显示。返回值: 写入成功后返回 output_path。
核心渲染函数(供高级用户扩展参考):
函数功能_cover_page(doc, data, colors)封面页_toc_page(doc, data, colors)目录页_thesis_charts_section(doc, data, colors, paths)论点图表_executive_summary(doc, data, colors)执行摘要_section(doc, section, colors, ...)正文章节_kpi_blocks(doc, data, colors)KPI 指标块_financial_table(doc, data, colors)财务数据表_rating_table(doc, data, colors)评级表格_shovel_stocks(doc, data, colors)铲子股列表_value_chain_section(doc, data, colors)产业链_shovel_stocks_list(doc, data, colors)铲子股详细列表_scenario_comparison_section(doc, data, colors, lang)情景对比_wacc_section(doc, data, colors, lang)WACC 拆解_sensitivity_section(doc, data, colors, lang)敏感性分析_comps_section(doc, data, colors, lang)可比公司_valuation_bridge_section(doc, data, colors, lang)估值桥_exhibits_section(doc, data, colors)Exhibit 附录_appendix(doc, data, colors)附录_disclosure(doc, data, colors)免责声明_add_chart_image(doc, chart_data, colors, width)图表渲染+嵌入
包版本要求用途python-docx>= 0.8.11DOCX 文件生成(必需)matplotlib>= 3.5出版级图表渲染(可选,缺失时降级)Python>= 3.9类型注解支持
安装依赖:
bash
pip install python-docx>=0.8.11 matplotlib>=3.5
scripts/_sample_out/ 目录包含 3 份示例报告:
achp_report_zh.docx -- 中文版achp_report_en.docx -- 英文版achp_report_bilingual.docx -- 双语版text
ms-research-report/
SKILL.md # 本文档
scripts/
ms_research_report.py # 核心生成模块(~3600 行)
run.py # CLI 入口
_sample_out/ # 示例输出
achp_report_zh.docx
achp_report_en.docx
achp_report_bilingual.docx
output/ # 默认输出目录
Author: WANG DONG JIE ( @yjkj999999 | Clawhub)
Version: 1.1.0 | License: MIT | Category: Equity Research
适用于 CGMA/ACCA/CFA 持证人及卖方/买方分析师、基金经理。生成符合摩根士丹利出版标准的股票研究报告。