This skill is designed to help DB-GPT systematically analyze listed company financial reports, producing high-quality financial analysis reports by extracting core data, calculating financial ratios, generating visualization charts, and combining business background.
Core Workflow
-
Data Extraction and Structuring:
- Use the
execute_skill_script_filetool to execute thescripts/extract_financials.pyscript, passing in the financial report file path (file_pathparameter), to automatically extract core values such as revenue, net profit, assets, and liabilities. - The script supports PDF files (parsed via pdfplumber) and plain text files, returning structured data in JSON format.
- Use the
-
Financial Ratio Calculation:
- Use
execute_skill_script_fileto executescripts/calculate_ratios.py, passing in the JSON data from Step 1. - Automatically calculate key indicators such as gross margin, net margin, ROE, and debt-to-asset ratio, and output 30 template placeholder key-value pairs.
- Refer to
references/financial_metrics.mdto ensure the accuracy of indicator definitions. - The system will automatically save the returned JSON results(
react_state["ratio_data"]), and the subsequent html_interpreter will automatically merge them.
- Use
-
Chart Generation:
- Use
execute_skill_script_fileto executescripts/generate_charts.py, passing in the JSON data from Step 1. - Automatically generate 3 visualization charts:
financial_overview.png: bar chart comparing core financial indicatorsprofitability.png: horizontal bar chart of profitability indicatorsasset_structure.png: donut chart of asset structure
- The system will automatically copy the images to the static directory and record the URL mapping(
react_state["image_url_map"]), and the subsequent html_interpreter will automatically merge them.
- Use
-
In-Depth Analysis:
- Follow the framework provided by
references/analysis_framework.mdto conduct in-depth analysis from the four dimensions of earnings quality, solvency risk, operating efficiency, and cash flow. - Combine with the "Management Discussion and Analysis" section to explain the core drivers of performance changes.
- Write the following 7 sections of analysis text:
PROFITABILITY_ANALYSIS: Profitability AnalysisSOLVENCY_ANALYSIS: Solvency and Risk AnalysisEFFICIENCY_ANALYSIS: Operating Efficiency AnalysisCASHFLOW_ANALYSIS: Cash Flow and Profit Quality AnalysisADVANTAGES_LIST: Core Strengths List (HTML<li>format)RISKS_LIST: Major Risks List (HTML<li>format)OVERALL_ASSESSMENT: Overall Assessment
- Follow the framework provided by
-
Render Report:
- Call
html_interpreter, using thetemplate_pathmode:{ "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年度财报分析报告" } - Important:
dataIn the dictionary, you only need to pass in the 7 sections of analysis text you wrote! The backend will automatically merge:- The 30 data indicators from Step 2 (COMPANY_NAME, REVENUE, NET_PROFIT, etc.)
- The chart URLs from Step 3 (CHART_FINANCIAL_OVERVIEW, CHART_PROFITABILITY, CHART_ASSET_STRUCTURE)
- Absolutely do notinclude data indicators or chart paths in
data, otherwise the JSON will be too large and cause truncation.
- Call
-
Done:
- Call
terminateto return a brief summary of 1-2 sentences. - Reports will be displayed as cards in the left panel; users can click a 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="简短摘要")
Resource usage instructions
- Scripts(all executed via
execute_skill_script_file):scripts/extract_financials.py: receives thefile_pathparameter, reads the financial report file (supports PDF and text formats), and extracts core financial data.scripts/calculate_ratios.py: calculates financial ratios and outputs 30 template placeholder key-value pairs. The system automatically records the results.scripts/generate_charts.py: generates 3 visualization charts (matplotlib); the system automatically handles image copying.scripts/fill_template.py: (backup) receives theratio_data、chart_paths、analysisthree parameters, reads the HTML template, and replaces all placeholders. Under normal circumstances this script does not need to be used, because the template_path mode of html_interpreter automatically completes template filling.
- Reference:
references/financial_metrics.md: contains formula definitions.references/analysis_framework.md: contains the analysis logic.
- Template:
templates/report_template.html: the HTML template for the final delivered report (must strictly follow, and sections must not be deleted or table structures modified). It is automatically read and filled by the template_path parameter of html_interpreter.templates/report_template.md: Markdown version, for reference only as a structural explanation.
Notes
- Must use
execute_skill_script_fileto execute scripts (do not use shell_interpreter), becauseexecute_skill_script_fileautomatically handles image copying and data recording. - Script extraction may be affected by formatting; it is recommended to manually verify the key extracted values before calculation.
- Always pay attention to "non-recurring gains and losses" to assess the true profitability of the company's core business.
- Compare historical data for at least three years to identify trends.
generate_charts.pydepends on matplotlib; please ensure that this library is installed in the environment.