CN Security Code Resolver
Overview
Resolve Chinese security names into exchange-tradable codes with a deterministic first pass and a verifiable fallback. Use the bundled script to query Eastmoney's public suggest API, then return the best match with enough metadata for confirmation.
When to use
Use this skill when the task involves any of the following:
- - Find the code for a Chinese stock, ETF, LOF, REIT, or fund from its Chinese name
- Convert a portfolio/watchlist from names into tradable codes
- Confirm whether an instrument is A-share, ETF/fund, or another mainland market type
- Add exchange-aware identifiers such as
600938.SH, 510880.SH, or Eastmoney INLINECODE2
Do not use this skill for:
- - Real-time pricing or chart analysis
- Hong Kong, US, futures, or crypto symbols unless the user explicitly wants cross-market results
- Fundamental analysis beyond basic instrument identification
Workflow
1) Prefer the script first
Run the bundled resolver script:
CODEBLOCK0
Batch mode:
CODEBLOCK1
2) Read the best match carefully
Prefer rows where:
- -
Name exactly matches the queried Chinese name - INLINECODE4 matches user intent (
沪A, 深A, 基金, etc.) - INLINECODE8 /
QuoteID indicate mainland trading venue
For mainland cash equities and ETFs, map exchange suffixes as:
- - codes starting with
6, 5, or 9 → usually INLINECODE13 - codes starting with
0, 1, 2, or 3 → usually INLINECODE18
If the returned result is ambiguous, show the top 3 candidates and ask for confirmation instead of guessing.
3) Return a concise confirmation
Use this output shape when replying:
CODEBLOCK2
4) When updating files
When writing portfolio JSON or other structured files, prefer storing both:
- -
code: raw numeric code, e.g. INLINECODE20 - INLINECODE21 :
SH or SZ when it can be derived confidently
Optional enriched fields:
- - INLINECODE24
- INLINECODE25
- INLINECODE26
- INLINECODE27
Verification guidance
If the first result looks suspicious:
- - Re-run with the exact full Chinese name from the broker/app
- Inspect the top candidate list from the script
- Cross-check with a browser search only when necessary
Good verification signals:
- - Exact Chinese name match
- Expected category (for example ETF vs stock)
- Price range and portfolio context are consistent with the instrument type
Bundled resources
Script
- Queries Eastmoney suggest API
- Supports one or many names
- Returns ranked JSON results with exchange hints
Reference
- Documents the API endpoint, returned fields, and matching heuristics
Examples
CODEBLOCK3
Expected top result:
- -
600710 / 苏美达 / INLINECODE32
CODEBLOCK4
Expected top result:
- -
510880 / 红利ETF华泰柏瑞 / INLINECODE35
CODEBLOCK5
Expected top result:
- -
601808 / 中海油服 / INLINECODE38 - If other markets also appear elsewhere, prefer A-share unless the user asks otherwise
CN Security Code Resolver
概述
通过确定性初筛和可验证的备用方案,将中文证券名称解析为交易所可交易代码。使用内置脚本查询东方财富公开建议API,返回最佳匹配结果及足够的元数据以供确认。
使用场景
当任务涉及以下任何情况时使用此技能:
- - 根据中文名称查找中国股票、ETF、LOF、REIT或基金的代码
- 将投资组合/自选股列表从名称转换为可交易代码
- 确认某品种是否为A股、ETF/基金或其他内地市场类型
- 添加交易所标识符,如600938.SH、510880.SH或东方财富QuoteID
不适用于以下场景:
- - 实时定价或图表分析
- 香港、美国、期货或加密货币代码,除非用户明确要求跨市场结果
- 超出基础品种识别范围的基本面分析
工作流程
1) 优先使用脚本
运行内置解析脚本:
bash
python3 skills/cn-security-code-resolver/scripts/resolvecnsecurity.py 中国海油
批量模式:
bash
python3 skills/cn-security-code-resolver/scripts/resolvecnsecurity.py 红利ETF华泰柏瑞 苏美达 中国海油 海油发展 中海油服
2) 仔细阅读最佳匹配结果
优先选择以下行:
- - Name与查询的中文名称完全匹配
- SecurityTypeName符合用户意图(沪A、深A、基金等)
- MarketType / QuoteID表明为内地交易场所
对于内地现金股票和ETF,交易所后缀映射规则如下:
- - 以6、5或9开头的代码 → 通常为SH
- 以0、1、2或3开头的代码 → 通常为SZ
如果返回结果不明确,显示前3个候选结果并要求用户确认,而非自行猜测。
3) 返回简洁确认信息
回复时使用以下输出格式:
text
标的:中海油服
A股代码:601808
交易所:上交所
类型:沪A
标准代码:601808.SH
QuoteID:1.601808
4) 更新文件时
在写入投资组合JSON或其他结构化文件时,建议同时存储:
- - code:原始数字代码,例如601808
- exchangeSuffix:可明确推导时为SH或SZ
可选增强字段:
- - quoteId
- securityTypeName
- marketType
- source: eastmoney_suggest
验证指南
如果首次结果存疑:
- - 使用券商/应用中完整准确的中文名称重新运行
- 检查脚本输出的候选列表顶部结果
- 仅在必要时通过浏览器搜索进行交叉验证
良好的验证信号:
- - 中文名称完全匹配
- 预期类别(例如ETF与股票)
- 价格范围和投资组合上下文与品种类型一致
内置资源
脚本
- - scripts/resolvecnsecurity.py
- 查询东方财富建议API
- 支持单个或多个名称
- 返回带交易所提示的排序JSON结果
参考文档
- - references/eastmoney-api.md
- 记录API端点、返回字段及匹配启发式规则
示例
bash
python3 skills/cn-security-code-resolver/scripts/resolvecnsecurity.py 苏美达
预期最佳结果:
bash
python3 skills/cn-security-code-resolver/scripts/resolvecnsecurity.py 红利ETF华泰柏瑞
预期最佳结果:
- - 510880 / 红利ETF华泰柏瑞 / 基金
bash
python3 skills/cn-security-code-resolver/scripts/resolvecnsecurity.py 中海油服
预期最佳结果:
- - 601808 / 中海油服 / 沪A
- 如果其他市场也出现结果,除非用户另有要求,否则优先选择A股