A share correlation

From aifinlab/FinClaw · View interactive version

A share correlation is an AI agent skill from the GitHub repository aifinlab/FinClaw. A股相关性分析/联动关系/相关系数计算。当用户说"相关性"、"联动"、"correlation"、"XX和YY相关吗"、"哪些股票走势相似"、"分散化"、"对冲"、"beta"、"同涨同跌"、"相关性分析"、"相关系数"、"相关性矩阵"时触发。MUST USE when user asks about correlation analysis, correlation coefficient between stocks/sectors, or diversification analysis based on correlation. 计算个股/指数/行业之间的收益率相关系数、Beta值,分

How to use this skill

Skill file

A股相关性分析 (Correlation & Co-movement Analysis)

数据源

通过 cn-stock-data skill 获取数据:

计算工具:Python numpy/pandas

Workflow

Step 1: 获取历史K线(多标的)

Step 2: 计算相关系数矩阵(Correlation Matrix)

Step 3: Beta 计算

Step 4: 滚动相关性分析(Rolling Correlation)

Step 5: 输出分析结果

formal 风格:

  1. 分析概览:标的列表、数据区间、样本量
  2. 相关系数矩阵(热力图描述 + 数据表格)
  3. 关键配对分析(最强正相关、最强负相关、最弱相关各 top3)
  4. Beta 分析表(含 R-squared)
  5. 滚动相关性趋势分析
  6. 分散化建议:基于相关性矩阵,推荐低相关组合
  7. 风险提示

brief 风格(默认):

  1. 相关系数矩阵表格
  2. 一句话总结:关键联动关系 + Beta 特征
  3. 分散化结论:哪些标的适合同时持有
  4. 风险提示

注意事项

使用示例

示例 1: 基本使用

# 调用 skill
result = run_skill({
    "param1": "value1",
    "param2": "value2"
})

示例 2: 命令行使用

python scripts/run_skill.py --input data.json
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.