Communitygithub.com

1278147072-cell/a-share-financial-factor-report-skill

Codex skill for A-share financial factor application reports

Works with~Claude CodeCodex CLI~Cursor
npx skills add 1278147072-cell/a-share-financial-factor-report-skill

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

A-Share Financial Factor Report

Use this skill to produce an applied Chinese report for finance coursework: a财务指标因子 report with real A-share data, Python-generated charts, factor construction, grouping, regression/Alpha discussion, machine-learning factor explanation, and a Word deliverable.

Standard Deliverables

Create these unless the user asks otherwise:

  • A .docx report in outputs/.
  • A Python script in outputs/ that rebuilds data, charts, and result files.
  • CSV data/results in outputs/.
  • PNG charts in outputs/.
  • Optional ZIP of code files when the user asks for “代码打包” or “代码文件形式输出”.

For DOCX work, also use the documents skill if available: generate with python-docx, render/verify when possible, and disclose if LibreOffice rendering is unavailable.

Workflow

  1. Choose or confirm the factor

    • If the user says “换一个指标”, choose a fresh factor not used in the thread.
    • Good choices: 毛利率质量、经营现金流质量、存货周转、应收账款质量、应付账款议价、ROE质量、资产负债率风险、收入增长质量、费用率控制、估值因子.
    • Avoid repeating companies and indicators unless the user requests continuity.
  2. Use real A-share data

    • Prefer 东方财富公开接口 when network is allowed.
    • For small案例, use 3-4 A-share listed companies with clear industry contrast.
    • For large-sample Alpha checks, use around 300 non-financial A-share companies to keep runtime manageable.
    • Exclude financial industries for operating factors unless the factor is explicitly financial-sector-specific.
    • State the data source as 东方财富公开财务接口 / 2024 年年度报告口径 when using the API.
  3. Construct the factor

    • Build 2-4 interpretable financial metrics.
    • Standardize metrics before combining.
    • Keep the formula simple and explain weights in plain Chinese.
    • Example: 质量因子 = 0.50 × 标准化核心指标 + 0.25 × 标准化辅助指标1 + 0.25 × 标准化辅助指标2
  4. Generate charts

    • At minimum: one core metric bar chart, one auxiliary metric bar chart, one factor scatter/ranking chart.
    • If doing Alpha: add grouping-return chart and Alpha/Beta coefficient chart.
    • Use Chinese titles and labels. Keep charts readable inside Word.
  5. Alpha validation

    • Follow the image requirement: do not only explain one company. Test whether the factor explains broad stock returns or price trends.
    • Group by factor into 5 groups, compare future returns.
    • Run OLS: Return = α + β × Factor + controls + ε
    • Use controls such as size, ROE, leverage, or valuation when available.
    • Interpret honestly:
      • If high group beats low group and β is significant/positive: say the factor shows positive Alpha evidence.
      • If α positive but β not significant: say market/sample intercept exists but the factor itself is not proven.
      • If grouping and regression conflict: explain both and choose a cautious conclusion.
  6. Machine-learning section

    • Include a conceptual ML factor-generation section even if no sklearn is installed.
    • Mention Lasso, Ridge, Random Forest, XGBoost as appropriate.
    • Explain that ML combines multiple financial features to predict future returns/ROE/cash-flow improvement.
    • Stress financial logic and out-of-sample validation to avoid overfitting.
  7. Report structure Use this nine-part structure for coursework:

    • 摘要、关键词
    • 一、研究背景与问题提出
    • 二、数据来源与处理口径
    • 三、指标构建与因子逻辑
    • 四、Python 图表与结果分析
    • 五、传统方法:分组与回归分析 / Alpha 检验
    • 六、机器学习方法生成综合因子
    • 七、公司案例解读
    • 八、投资应用建议与局限
    • 九、结论
    • 附件:数据与代码
  8. Length

    • If the user requests 5000/5500/5700 字以上, verify the final DOCX text length with python-docx.
    • Prefer concise expansion through methodology, Alpha interpretation, industry caveats, and ML workflow, not filler.

API Notes

Read references/eastmoney-fields.md when implementing or modifying data-fetching scripts.

Use scripts/factor_report_template.py as a starting point when creating a new metric script. Copy it into the workspace outputs/ or work/, then adapt:

  • company list and fields
  • factor formula
  • chart titles
  • report narrative

Common Interpretation Language

Use plain Chinese explanations:

  • “Alpha 是否存在” means whether the factor still creates excess return after controlling common variables.
  • “因子对 return 有解释力” means high/low factor groups show different future returns, or regression β is meaningful.
  • “不能证明 Alpha 存在” is acceptable and often better than overclaiming.
  • “该指标能解释经营质量,但短期不一定预测股价” is a valid cautious conclusion.

Final Response

Link the final .docx and key support files. Mention:

  • selected factor and companies
  • whether large-sample Alpha was tested
  • headline conclusion
  • generated code/data/chart files

Related Skills