financial-report-analyzer
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese财报分析技能 (Financial Report Analyzer)
Financial Report Analyzer Skill
本技能旨在帮助 DB-GPT 系统化地分析上市公司财报,通过提取核心数据、计算财务比率、生成可视化图表并结合业务背景,产出高质量的财务分析报告。
This skill is designed to help DB-GPT systematically analyze the financial reports of listed companies. By extracting core data, calculating financial ratios, generating visual charts and combining with business background, it produces high-quality financial analysis reports.
核心工作流程
Core Workflow
-
数据提取与结构化:
- 使用 工具执行
execute_skill_script_file脚本,传入财报文件路径(scripts/extract_financials.py参数),自动提取营收、净利润、资产、负债等核心数值。file_path - 脚本支持 PDF 文件(通过 pdfplumber 解析)和纯文本文件,返回 JSON 格式的结构化数据。
- 使用
-
财务比率计算:
- 使用 执行
execute_skill_script_file,传入 Step 1 的 JSON 数据。scripts/calculate_ratios.py - 自动计算毛利率、净利率、ROE、资产负债率等关键指标,输出 30 个模板占位符键值。
- 参考 确保指标定义的准确性。
references/financial_metrics.md - 系统会自动保存返回的 JSON 结果(),后续 html_interpreter 会自动合并。
react_state["ratio_data"]
- 使用
-
图表生成:
- 使用 执行
execute_skill_script_file,传入 Step 1 的 JSON 数据。scripts/generate_charts.py - 自动生成 3 张可视化图表:
- :核心财务指标对比柱状图
financial_overview.png - :盈利能力指标横向条形图
profitability.png - :资产结构环形饼图
asset_structure.png
- 系统会自动将图片复制到静态目录并记录 URL 映射(),后续 html_interpreter 会自动合并。
react_state["image_url_map"]
- 使用
-
深度分析:
- 遵循 提供的框架,从盈利质量、偿债风险、营运效率和现金流四个维度进行深度剖析。
references/analysis_framework.md - 结合"经营情况讨论与分析"章节,解释业绩变动的核心驱动因素。
- 撰写以下 7 段分析文本:
- :盈利能力分析
PROFITABILITY_ANALYSIS - :偿债与风险分析
SOLVENCY_ANALYSIS - :营运效率分析
EFFICIENCY_ANALYSIS - :现金流与利润质量分析
CASHFLOW_ANALYSIS - :核心优势列表(HTML
ADVANTAGES_LIST格式)<li> - :主要风险列表(HTML
RISKS_LIST格式)<li> - :综合评价
OVERALL_ASSESSMENT
- 遵循
-
渲染报告:
- 调用 ,使用
html_interpreter模式:template_pathjson{ "template_path": "financial-report-analyzer/templates/report_template.html", "data": { "PROFITABILITY_ANALYSIS": "LLM撰写的盈利能力分析...", "SOLVENCY_ANALYSIS": "LLM撰写的偿债分析...", "EFFICIENCY_ANALYSIS": "LLM撰写的营运效率分析...", "CASHFLOW_ANALYSIS": "LLM撰写的现金流分析...", "ADVANTAGES_LIST": "<li>优势1</li><li>优势2</li>", "RISKS_LIST": "<li>风险1</li><li>风险2</li>", "OVERALL_ASSESSMENT": "LLM撰写的综合评价..." }, "title": "XX公司 2023年度财报分析报告" } - 重要:字典中只需传入你撰写的 7 段分析文本!后端会自动合并:
data- Step 2 的 30 个数据指标(COMPANY_NAME、REVENUE、NET_PROFIT 等)
- Step 3 的图表 URL(CHART_FINANCIAL_OVERVIEW、CHART_PROFITABILITY、CHART_ASSET_STRUCTURE)
- 绝对不要在 中包含数据指标或图表路径,否则 JSON 过大会导致截断。
data
- 调用
-
完成:
- 调用 返回 1-2 句话的简短摘要。
terminate - 报告会以卡片形式展示在左侧面板,用户点击卡片即可在右侧面板查看完整报告。
- 调用
-
Data Extraction and Structuring:
- Use the tool to run the
execute_skill_script_filescript, passing in the financial report file path (thescripts/extract_financials.pyparameter), to automatically extract core values such as revenue, net profit, assets, liabilities, etc.file_path - The script supports PDF files (parsed via pdfplumber) and plain text files, returning structured data in JSON format.
- Use the
-
Financial Ratio Calculation:
- Use to run
execute_skill_script_file, passing in the JSON data from Step 1.scripts/calculate_ratios.py - Automatically calculate key indicators such as gross profit margin, net profit margin, ROE, asset-liability ratio, etc., outputting 30 template placeholder key-value pairs.
- Refer to to ensure the accuracy of indicator definitions.
references/financial_metrics.md - The system will automatically save the returned JSON result (), which will be automatically merged by the html_interpreter later.
react_state["ratio_data"]
- Use
-
Chart Generation:
- Use to run
execute_skill_script_file, passing in the JSON data from Step 1.scripts/generate_charts.py - Automatically generate 3 visual charts:
- : Bar chart comparing core financial indicators
financial_overview.png - : Horizontal bar chart of profitability indicators
profitability.png - : Donut chart of asset structure
asset_structure.png
- The system will automatically copy the images to the static directory and record the URL mapping (), which will be automatically merged by the html_interpreter later.
react_state["image_url_map"]
- Use
-
In-depth Analysis:
- Follow the framework provided in to conduct in-depth analysis from four dimensions: profit quality, solvency risk, operational efficiency and cash flow.
references/analysis_framework.md - Combine the "Management Discussion and Analysis" section to explain the core driving factors of performance changes.
- Write the following 7 sections of analysis text:
- : Profitability Analysis
PROFITABILITY_ANALYSIS - : Solvency and Risk Analysis
SOLVENCY_ANALYSIS - : Operational Efficiency Analysis
EFFICIENCY_ANALYSIS - : Cash Flow and Profit Quality Analysis
CASHFLOW_ANALYSIS - : List of Core Advantages (in HTML
ADVANTAGES_LISTformat)<li> - : List of Main Risks (in HTML
RISKS_LISTformat)<li> - : Comprehensive Assessment
OVERALL_ASSESSMENT
- Follow the framework provided in
-
Report Rendering:
- Call using the
html_interpretermode:template_pathjson{ "template_path": "financial-report-analyzer/templates/report_template.html", "data": { "PROFITABILITY_ANALYSIS": "Profitability analysis written by LLM...", "SOLVENCY_ANALYSIS": "Solvency analysis written by LLM...", "EFFICIENCY_ANALYSIS": "Operational efficiency analysis written by LLM...", "CASHFLOW_ANALYSIS": "Cash flow analysis written by LLM...", "ADVANTAGES_LIST": "<li>Advantage 1</li><li>Advantage 2</li>", "RISKS_LIST": "<li>Risk 1</li><li>Risk 2</li>", "OVERALL_ASSESSMENT": "Comprehensive assessment written by LLM..." }, "title": "XX Company 2023 Annual Financial Report Analysis" } - Important: Only pass the 7 sections of analysis text in the dictionary! The backend will automatically merge:
data- 30 data indicators from Step 2 (COMPANY_NAME, REVENUE, NET_PROFIT, etc.)
- Chart URLs from Step 3 (CHART_FINANCIAL_OVERVIEW, CHART_PROFITABILITY, CHART_ASSET_STRUCTURE)
- Never include data indicators or chart paths in , otherwise the JSON will be too large and cause truncation.
data
- Call
-
Completion:
- Call to return a short summary of 1-2 sentences.
terminate - The report will be displayed as a card in the left panel, and users can click the card to view the full report in the right panel.
- Call
完整流程示例
Complete Workflow Example
Step 1: execute_skill_script_file(skill_name="financial-report-analyzer", script_file_name="extract_financials.py", args={"file_path": "/path/to/report.pdf"})
→ 返回 JSON: {"revenue": 10500000000, "net_profit": 1200000000, ...} (记为 raw_data)
Step 2: execute_skill_script_file(skill_name="financial-report-analyzer", script_file_name="calculate_ratios.py", args=<raw_data>)
→ 返回 30 个模板键值,系统自动记录到 react_state["ratio_data"]
Step 3: execute_skill_script_file(skill_name="financial-report-analyzer", script_file_name="generate_charts.py", args=<raw_data>)
→ 生成图表,系统自动复制到 /images/ 并记录 URL 映射
Step 4: (LLM 自行撰写 7 段深度分析文本)
Step 5: html_interpreter(template_path="financial-report-analyzer/templates/report_template.html", data={仅包含 7 段分析文本}, title="报告标题")
→ 后端自动合并数据指标 + 图表 URL + 分析文本,渲染完整报告
Step 6: terminate(result="简短摘要")Step 1: execute_skill_script_file(skill_name="financial-report-analyzer", script_file_name="extract_financials.py", args={"file_path": "/path/to/report.pdf"})
→ Returns JSON: {"revenue": 10500000000, "net_profit": 1200000000, ...} (recorded as raw_data)
Step 2: execute_skill_script_file(skill_name="financial-report-analyzer", script_file_name="calculate_ratios.py", args=<raw_data>)
→ Returns 30 template key-value pairs, which are automatically recorded to react_state["ratio_data"] by the system
Step 3: execute_skill_script_file(skill_name="financial-report-analyzer", script_file_name="generate_charts.py", args=<raw_data>)
→ Generates charts, the system automatically copies them to /images/ and records the URL mapping
Step 4: (LLM writes 7 sections of in-depth analysis text on its own)
Step 5: html_interpreter(template_path="financial-report-analyzer/templates/report_template.html", data={contains only 7 sections of analysis text}, title="Report Title")
→ Backend automatically merges data indicators + chart URLs + analysis text to render the complete report
Step 6: terminate(result="Short summary")资源使用说明
Resource Usage Instructions
- 脚本(均通过 执行):
execute_skill_script_file- :接收
scripts/extract_financials.py参数,读取财报文件(支持 PDF 和文本格式),提取核心财务数据。file_path - :计算财务比率,输出 30 个模板占位符键值。系统自动记录结果。
scripts/calculate_ratios.py - :生成 3 张可视化图表(matplotlib),系统自动处理图片复制。
scripts/generate_charts.py - :(备用)接收
scripts/fill_template.py、ratio_data、chart_paths三个参数,读取 HTML 模板并替换所有占位符。正常情况下不需要使用此脚本,因为 html_interpreter 的 template_path 模式会自动完成模板填充。analysis
- 参考:
- :包含公式定义。
references/financial_metrics.md - :包含分析逻辑。
references/analysis_framework.md
- 模板:
- :最终交付报告的 HTML 模板(必须严格遵循,不得删减章节或修改表格结构)。由 html_interpreter 的 template_path 参数自动读取并填充。
templates/report_template.html - :Markdown 版本,仅供参考结构说明。
templates/report_template.md
- Scripts (all executed via ):
execute_skill_script_file- : Accepts the
scripts/extract_financials.pyparameter, reads financial report files (supports PDF and text formats), and extracts core financial data.file_path - : Calculates financial ratios and outputs 30 template placeholder key-value pairs. The system automatically records the results.
scripts/calculate_ratios.py - : Generates 3 visual charts (using matplotlib), and the system automatically handles image copying.
scripts/generate_charts.py - : (Backup) Accepts three parameters
scripts/fill_template.py,ratio_data,chart_paths, reads the HTML template and replaces all placeholders. Normally, this script does not need to be used because the template_path mode of html_interpreter will automatically complete template filling.analysis
- References:
- : Contains formula definitions.
references/financial_metrics.md - : Contains analysis logic.
references/analysis_framework.md
- Templates:
- : HTML template for the final delivered report (must be strictly followed, do not delete sections or modify table structures). It is automatically read and filled by the template_path parameter of html_interpreter.
templates/report_template.html - : Markdown version, for structural reference only.
templates/report_template.md
注意事项
Notes
- 必须使用 执行脚本(不要用 shell_interpreter),因为
execute_skill_script_file会自动处理图片复制和数据记录。execute_skill_script_file - 脚本提取可能受排版影响,建议在计算前人工核对提取的关键数值。
- 始终关注"非经常性损益",以评估公司核心业务的真实盈利能力。
- 对比至少三年的历史数据,以识别趋势。
- 依赖 matplotlib,请确保环境中已安装该库。
generate_charts.py
- Must use to run scripts (do not use shell_interpreter), because
execute_skill_script_filewill automatically handle image copying and data recording.execute_skill_script_file - Script extraction may be affected by typesetting, so it is recommended to manually verify the extracted key values before calculation.
- Always pay attention to "non-recurring gains and losses" to evaluate the real profitability of the company's core business.
- Compare at least three years of historical data to identify trends.
- depends on matplotlib, please ensure that this library is installed in the environment.
generate_charts.py