返回 Skill 列表
extension
分类: 数据与分析无需 API Key

pbc-finance-analyzer

央行公开数据分析

person作者: user_caef9946hubcommunity

PBC Finance Data Analyzer

A comprehensive workflow for managing and analyzing PBC (People's Bank of China / 中国人民银行) financial statistics data. Covers data download, dashboard updates, report generation, and cloud deployment.

Mandatory Quality Rules (Enforced)

Every analysis report, Markdown brief, and data figure MUST meet these rules. Failure to comply = invalid deliverable.

Rule 1: Data Provenance

  • Every data point MUST trace back to a downloaded PBC xlsx file in the workspace
  • When citing a number in reports, include the source file name and release date. Example: "6月社融增量3.36万亿元(来源:2026_社融_增量统计表_0715.xlsx,2026-07-15发布)"
  • Never cite data from memory, search results, or external articles unless tagged as supplementary

Rule 2: Official Speech Sourcing

  • If referencing any policy speech or official statement (e.g., central bank governor, State Council), must link to the official PBC/State Council webpage as the primary source
  • Never cite second-hand reports (媒体转载) as the primary source
  • If the official source URL is unavailable, mark the citation with [二手来源] and the media link

Rule 3: Data Magnitude Validation

Before finalizing any report, run these checks against every key number:

  • Unit consistency: All 社融/信贷 figures in 亿元 (10^8), confirm no 万亿 (10^12) mixup
  • Cross-table consistency: The total loan stock from the credit table AND the社融存量 table should be within 1% (different statistical scopes). Flag if >5% divergence
  • Month-over-month sanity: No single-month change should exceed 3x the trailing 6-month average absolute change. If it does, re-read the source file to verify
  • Year-over-year sanity: Growth rates outside [-20%, +50%] for any major indicator should trigger a re-verification step before including in the report
  • Sum check: 1-6月 cumulative values must equal sum of individual months within rounding tolerance

Validation Checklist (Execute Before Delivering Reports)

□ Source column: Every table in the report has a "数据来源" note
□ Unit column: Every table header specifies units (亿元/万亿元/%)
□ Cross-check: 社融贷款 ≈ 信贷收支贷款 (flag if >5% gap)
□ Extreme check: No single-month flow >50,000亿 or < -10,000亿 without verification note
□ Consistency: Same metric cited in different sections has the same value
□ Update date: Report header shows data release date from PBC (not generation date)

After generating reports, run the Python validation script:

python scripts/validate_report.py {report_file}

If any check fails, fix the data before presenting to the user.

Workspace Setup (Cloud-Compatible)

The skill works in both local desktop and cloud mobile modes.

Local mode (Windows desktop)

Workspace: D:\WorkBuddy\央行分析 (already exists with full data)

Cloud mode (mobile / new environment)

The workspace needs bootstrapping. Before executing any sub-workflow:

  1. Detect the environment — if D:\WorkBuddy\央行分析 or ./央行分析 does not exist, it's cloud mode
  2. Create workspace directory (use relative path ./央行分析 for cloud portability)
  3. Copy assets/dashboard_template.html to the workspace as 金融数据看板.html (this template contains ALL historical data 2023-2026 embedded as JSON)
  4. Create charts/ subdirectory if needed
  5. Proceed with the requested sub-workflow

Path handling

  • In cloud mode, use relative paths: ./央行分析/金融数据看板.html, ./央行分析/2026年X月...
  • All xlsx files downloaded go to the workspace root
  • Use os.getcwd() + relative paths, never hardcode D:\

Progress Reporting (Important for Cloud Mode)

When running in cloud/mobile mode, the user cannot see progress. AT EVERY MAJOR STEP, send a brief status message to the user:

Init: 检测工作区... ✅ 已存在 / ⚡ 首次使用,正在初始化(复制历史数据底板)
Scan: 扫描 PBC 页面,查找新文件...
Found: 发现 N 个新文件 (社融 X, 货币 Y, 信贷 Z)
Download [1/N]: 社融增量统计表... ✅ (XX KB)
Download [2/N]: 货币供应量... ✅ (XX KB)
...
Download done: N/N
Parser: 正在提取数据...
Update: 更新看板 JSON... ✅ (新增M6数据)
Report: 生成 Word 报告... ✅
Brief: 生成 MD 快讯... ✅
Deploy: 部署到云端... ✅
Done: 全部完成!

If any step fails, report the error immediately with what went wrong and what remains to be done.

Workflow Overview

There are three main sub-workflows, plus initialization. Execute the one that matches the user's request:

Sub-workflow A: Download Latest Data

When the user asks to download/update PBC data:

  1. Read references/file_layout.md for the file naming conventions and URL structure
  2. Use WebFetch to check the 2026 category pages for new xlsx files with timestamps newer than what's already downloaded:
    • Social financing: https://www.pbc.gov.cn/diaochatongjisi/116219/116319/2026ntjsj/shrzgm/index.html
    • Money & banking: https://www.pbc.gov.cn/diaochatongjisi/116219/116319/2026ntjsj/hbtjgl/index.html
    • Credit funds: https://www.pbc.gov.cn/diaochatongjisi/116219/116319/2026ntjsj/jrjgxdsztj/index.html
  3. Compare the URL timestamps (e.g., 202607/ is newer than 202606/) against existing files in the workspace root directory
  4. For any new files found, download them using http.client.HTTPSConnection with ssl.PROTOCOL_TLS_CLIENT context (PBC blocks urllib.request since June 2026). See scripts/download_pbc.py for the exact download pattern.
  5. Save to D:\WorkBuddy\央行分析 with naming: 2026_{category}_{report}_{MMDD}.xlsx

After data download, ALWAYS ask the user whether to proceed with analysis/report generation.

Sub-workflow B: Update Dashboard and Generate Reports

When the user wants to update analysis with the latest data:

  1. Read the new data files using openpyxl to extract key indicators
  2. Update the HTML dashboard (D:\WorkBuddy\央行分析\金融数据看板.html):
    • Extract new monthly data for FLOW, CREDIT, and MONEY JSON constants
    • Replace the embedded JSON data in the HTML with updated values
    • Update the preset buttons and timestamp
  3. Generate a Word report at D:\WorkBuddy\央行分析\2026年X月金融数据全面分析报告.docx:
    • Structure: abstract + 7 chapters (social financing, structural evolution, money supply, credit depth, deposit structure, central bank balance sheet, comprehensive assessment)
    • Use python-docx with Chinese fonts (黑体/仿宋_GB2312/楷体_GB2312)
    • Include data tables
  4. Generate a Markdown brief at D:\WorkBuddy\央行分析\2026年X月金融数据快讯.md:
    • Financial journalist style: short paragraphs, bold key numbers
    • 3-4 signals with data + commentary

Sub-workflow C: Deploy to Cloud

When the user wants remote access:

  1. Create a deploy directory with the dashboard HTML renamed as index.html
  2. Use the workbuddy_cloudstudio_deploy tool to deploy it
  3. Present the share link to the user

Critical Technical Notes

PBC Website Access

The PBC website blocks standard urllib.request since June 2026. Use this pattern:

import ssl
from http.client import HTTPSConnection
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
ctx.check_hostname = False; ctx.verify_mode = ssl.CERT_NONE
conn = HTTPSConnection('www.pbc.gov.cn', timeout=30, context=ctx)
conn.request('GET', path, headers={'User-Agent': 'Mozilla/5.0 ...'})
r = conn.getresponse()
data = r.read()

However, WebFetch still works for browsing pages and finding links.

Data File Structure

  • Social financing tables: rows are months (2026.01 ... 2026.12), data starts around row 11
  • Credit tables: columns are months (1-12), with key rows for total loans, household loans, enterprise loans, and bill financing
  • Money supply tables: similar column structure

Dashboard Data Format

The HTML dashboard embeds three JSON objects:

  • FLOW: {year: {month: {flow: number, rmb_loan: number}}}
  • CREDIT: {year: {month: {total_loan, household, enterprise, bill}}}
  • MONEY: {year: {month: {M2, M0}}}

When updating, read the new xlsx files, extract the new monthly data point, and add it to these JSON objects. Use openpyxl with data_only=True.

Python Environment

  • Python: C:/Users/Admin/.workbuddy/binaries/python/versions/3.13.12/python.exe
  • Required packages: openpyxl, python-docx (both pre-installed)
  • Chart generation uses Chart.js CDN (in-browser), no matplotlib needed for dashboard