Cn index

From Undermybelt/hermes-skills · View interactive version

Cn index is an AI agent skill from the GitHub repository Undermybelt/hermes-skills. A股指数数据与申万行业分类。上证/深证指数行情、成分股权重、申万行业分类。 当用户询问"上证指数""深证成指""申万行业""成分股权重""指数行情"时触发。

How to use this skill

Skill file

CN Index — A股指数 + 申万行业分类

所有接口均为 V2 版本(/api/v2/...)。

Curl Setup

BASE="http://43.167.234.49:3101"
AUTH=(-H "X-API-Key: 123456" -H "Content-Type: application/json")

代码格式规则

| 规则 | 值 |

|------|-----|

| 参数名 | tsCode(日线/周线/月线/每日指标)、indexCode(成分股权重) |

| 代码格式 | 带交易所后缀 |

| 日期格式 | YYYYMMDD |

常用指数代码:

| 指数 | tsCode |

|------|--------|

| 上证指数 | 000001.SH |

| 深证成指 | 399001.SZ |

| 创业板指 | 399006.SZ |

| 沪深300 | 000300.SH |

| 中证500 | 000905.SH |


端点详情

GET /api/v2/cnstock/index/basic — 指数列表

| Parameter | Type | Required | Description |

|-----------|------|----------|-------------|

| market | string | No | SSE(上交所), SZSE(深交所) |

GET /api/v2/cnstock/index/daily — 指数日线

| Parameter | Type | Required | Description |

|-----------|------|----------|-------------|

| tsCode | string | Yes | 指数代码(如 000001.SH) |

| startDate | string | No | YYYYMMDD |

| endDate | string | No | YYYYMMDD |

| limit | int | No | 1-5000 (默认 100) |

GET /api/v2/cnstock/index/weekly — 指数周线

| Parameter | Type | Required | Description |

|-----------|------|----------|-------------|

| tsCode | string | Yes | 指数代码 |

| startDate | string | No | YYYYMMDD |

| endDate | string | No | YYYYMMDD |

| limit | int | No | 1-5000 |

GET /api/v2/cnstock/index/monthly — 指数月线

| Parameter | Type | Required | Description |

|-----------|------|----------|-------------|

| tsCode | string | Yes | 指数代码 |

| startDate | string | No | YYYYMMDD |

| endDate | string | No | YYYYMMDD |

| limit | int | No | 1-5000 |

GET /api/v2/cnstock/index/daily-basic — 指数每日指标

| Parameter | Type | Required | Description |

|-----------|------|----------|-------------|

| tsCode | string | Yes | 指数代码 |

| tradeDate | string | No | YYYYMMDD |

| startDate | string | No | YYYYMMDD |

| endDate | string | No | YYYYMMDD |

| limit | int | No | 1-5000 |

GET /api/v2/cnstock/index/weight — 成分股权重

| Parameter | Type | Required | Description |

|-----------|------|----------|-------------|

| indexCode | string | Yes | 指数代码 |

| tradeDate | string | No | YYYYMMDD |

| startDate | string | No | YYYYMMDD |

| endDate | string | No | YYYYMMDD |

| limit | int | No | 1-5000 |

GET /api/v2/cnstock/index/classify — 申万行业分类

| Parameter | Type | Required | Description |

|-----------|------|----------|-------------|

| src | string | No | 来源 |

| version | string | No | 版本 |

| limit | int | No | 数量限制 |


调用示例

# 上证指数最近日线
curl -sS "${AUTH[@]}" "$BASE/api/v2/cnstock/index/daily?tsCode=000001.SH&limit=5"

# 多指数并行
curl -sS "${AUTH[@]}" "$BASE/api/v2/cnstock/index/daily?tsCode=000001.SH&limit=5" &
curl -sS "${AUTH[@]}" "$BASE/api/v2/cnstock/index/daily?tsCode=399001.SZ&limit=5" &
wait

# 指数列表
curl -sS "${AUTH[@]}" "$BASE/api/v2/cnstock/index/basic?market=SSE"

# 成分股权重
curl -sS "${AUTH[@]}" "$BASE/api/v2/cnstock/index/weight?indexCode=000001.SH&limit=100"

# 申万行业分类
curl -sS "${AUTH[@]}" "$BASE/api/v2/cnstock/index/classify"

# 指数日线 + 每日指标并行
curl -sS "${AUTH[@]}" "$BASE/api/v2/cnstock/index/daily?tsCode=000001.SH&limit=10" &
curl -sS "${AUTH[@]}" "$BASE/api/v2/cnstock/index/daily-basic?tsCode=000001.SH&limit=10" &
wait

错误排查

| 错误 | 原因 | 修复 |

|------|------|------|

| 404 | 指数代码错误 | 检查 tsCode,如 000001.SH |

| 空数据 | tsCode / indexCode 混用 | index/weight 用 indexCode,其余用 tsCode |

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.