SuperAPI AI Directory

a-stock-financial

Data & analytics

View repository

Updated 10-16 01:38

About this skill

A-share listed company financial statement query

Retrieve financial statements of A-share listed companies based on AkShare (Tonghuashun data source), support querying and exporting to Excel.

Dependencies

pip install akshare openpyxl

Stock code lookup

Do not use stock_zh_a_spot_em() to pull market-wide quotes (extremely slow, takes 1 minute+).

When the user says the company name instead of the code, just use WebSearch to search for "XX stock code".

Available data

Statement Number of columns Content
Balance sheet 80 columns Current/non-current assets, current/non-current liabilities, details of each equity item
Income statement 46 columns Revenue → various cost items → operating profit → net profit → earnings per share → comprehensive income
Cash flow statement 73 columns Cash flows from the three major activities under the direct method + supplementary information under the indirect method
Financial highlights 20+ indicators Net profit margin, gross profit margin, ROE, inventory turnover ratio, current ratio, etc.

Each statement supports 3 time dimensions:按报告期(most complete),按年度(multi-year comparison),按单季度

Workflow

1. Confirm parameters

  • Stock code: if the user provides a code, use it directly; if they say the company name, use WebSearch to search
  • Statement type: by default query all; if the user specifies, query only the corresponding statement (balance/income/cashflow/abstract)
  • Time dimension: default 按报告期, for annual report comparison use 按年度, for quarterly view use 按单季度
  • Mapping when the user says "last N years/last N periods":
    • "last 3 years" = --indicator 按年度 --last 3(take the most recent 3 fiscal years)
    • "last 4 periods" = --indicator 按报告期 --last 4(take the most recent 4 reporting periods, including quarterly reports/semi-annual reports/annual reports)
    • "2025 annual report" = --period 2025-12-31
    • "2025 third-quarter report" = --period 2025-09-30

2. Query statements

SCRIPT=~/.claude/skills/a-stock-financial/scripts/fetch_reports.py

# 查所有报表,按报告期,最近4期
python3 $SCRIPT <股票代码>

# 只查利润表,按年度,最近5年
python3 $SCRIPT <股票代码> --type income --indicator 按年度 --last 5

# 查资产负债表,指定报告期(只返回1期数据)
python3 $SCRIPT <股票代码> --type balance --period 2025-12-31

# 查财务摘要
python3 $SCRIPT <股票代码> --type abstract

# 输出为 JSON
python3 $SCRIPT <股票代码> --output json

--type optional:balance、income、cashflow、abstract、all(default) --indicator optional:按报告期(default),按年度、按单季度

3. Display results

Display key indicators in table form, and provide a brief financial analysis:

  • Revenue trend, profit margin changes
  • Asset-liability structure, solvency
  • Cash flow health
  • Year-over-year changes compared with previous years' data

4. Export to Excel (when the user requests it)

EXPORT=~/.claude/skills/a-stock-financial/scripts/export_excel.py

# 导出所有报告期(默认最近20期)
python3 $EXPORT <股票代码> <公司名称>

# 只导出2025年报(1期数据)
python3 $EXPORT 600326 西藏天路 --period 2025-12-31

# 导出最近3期
python3 $EXPORT 600326 西藏天路 --last 3

# 按年度导出,最近5年
python3 $EXPORT 600326 西藏天路 --indicator 按年度 --last 5

# 指定输出路径
python3 $EXPORT 600326 西藏天路 --output /tmp/财报.xlsx

The exported file contains 4 sheets: balance sheet, income statement, cash flow statement, financial highlights.

Notes

  • symbol is a 6-digit stock code (e.g. "600326"), without an exchange suffix
  • The data source is Tonghuashun, completely free and requires no token
  • The data unit is usually "100 million", with * being core indicator columns
  • If the Eastmoney API reports an error, the Tonghuashun API (_ths suffix) is a stable alternative

Author: nigo WeChat Official Account: 逆行的狗