bond-spread-analyzer
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "bond-spread-analyzer" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-591f3ccb48f6eb9f50b15c4633390b96068fb0dd4c03b807995bbd6508db8edd. Verify the upstream source and version against https://skillhub.cn/skills/user_b9c7ce87/bond-spread-analyzer before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Bond spread analyzer for government and local bonds: triggered when a user provides an Excel file containing time series of treasury and local bond yields across tenors and requests calculation of term spreads, instrument spreads, 3-year historical percentiles, and investment strategy suggestions. Typical triggers: 'treasury spread analysis', 'local bond spread', 'term spread', 'instrument spread', 'spread percentile', 'bond investment strategy'.
Introduction source: third_party · user_b9c7ce87 · 1.0.0 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Inputs and outputs
- Translation pending; see source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: bond-spread-analyzer
description: >
国债/地方债利差分析表构建工具。当用户提供包含国债和地方债各期限收益率时间序列的
Excel 文件,并要求计算期限利差、品种利差、近3年历史分位数、投资策略建议时触发。
典型触发语:国债利差分析、地方债利差、期限利差、品种利差、利差分位数、债券投资策略。
agent_created: trueBond Spread Analyzer
Overview
从 Wind 等数据源导出的国债/地方债收益率时间序列表出发,构建两个利差分析子表 (期限利差 + 品种利差),全部使用 Excel 公式引用基础数据表,并附加基于近3年 历史分位数的投资策略建议。
核心原则:基础数据表完全不动(Wind 每日自动向基础数据表插入新行,公式通过 INDEX/MATCH 按日期匹配,不依赖行位置)。
Trigger Scenarios
- 用户给了一个国债/地方债收益率 Excel,要求做利差分析
- 用户说"帮我计算期限利差、品种利差"
- 用户说"分析国债收益率曲线,看看哪些期限值得关注"
- 用户说"给这个表加上利差分位数和投资建议"
Source Data Assumptions
基础数据表(如 "基础数据-自动更新")结构:
Row 3-5: 标题/说明行
Row 6: 表头行
A: 日期
B: 国债3年 C: 国债5年 D: 国债7年
E: 国债10年 F: 国债20年 G: 国债30年
H: 地方债3年 I: 地方债5年 J: 地方债7年
K: 地方债10年 L: 地方债20年 M: 地方债30年
N: DR007(可选)
Row 7: 辅助行(可选)
Row 8+: 每日数据(最新日期在 Row 8,由近及远)
Output Structure
生成两个新子表,基础数据表原封不动:
期限利差表
| Row | 内容 |
|---|---|
| 1 | 标题:"国债&地方债 — 期限利差分析"(深蓝加粗,全宽合并,行高30) |
| 2 | 副标题/说明(灰字,全宽合并,行高20) |
| 3 | 数据区间说明(灰字,全宽合并) |
| 4 | 公式说明(浅灰,全宽合并) |
| 5 | 策略标题(白字深蓝底 #2F5496,合并 A5:C5,行高30) |
| 6 | 策略详情(深色字浅黄底 #FFF2CC,合并 A6:D6,行高155) |
| 7 | 表头:日期 + 16个指标名 |
| 8 | 近3年分位数行 |
| 9+ | 每日利差数据 |
16个指标:
- 国债:5Y-3Y, 7Y-3Y, 10Y-3Y, 10Y-5Y, 10Y-7Y, 20Y-10Y, 30Y-10Y, 30Y-20Y
- 地方债:同上 8 个
品种利差表
| Row | 内容 |
|---|---|
| 1 | 标题(深蓝加粗,全宽合并,行高30) |
| 2-4 | 说明行 |
| 5-6 | 策略建议 |
| 7 | 表头:日期 + 6个指标名 |
| 8 | 分位数 |
| 9+ | 每日数据 |
6个指标:品种利差 3年/5年/7年/10年/20年/30年
Workflow
Step 1: 读取源文件
确认基础数据表的 sheet 名、列结构、数据范围(首行、末行日期、总行数)。
使用 openpyxl 以 data_only=True 读取缓存值做计算验证,
以 data_only=False 读取并修改公式。
Step 2: 运行构建脚本
调用 scripts/build_spreads.py,参数:
python scripts/build_spreads.py \
--source "源文件路径" \
--output "输出文件路径" \
[--base-sheet "基础数据-自动更新"] \
[--term-sheet "期限利差"] \
[--variety-sheet "品种利差"]
脚本执行以下操作:
- 以
data_only=False加载源文件 - 创建 "期限利差" 和 "品种利差" 两个新 sheet
- 为每个数据单元格写入 INDEX/MATCH 公式,按日期从基础数据取数
- 写入近3年分位数公式(COUNTIF/COUNT)
- 设置
fullCalcOnLoad=True - 设置冻结窗格 B7
- 应用格式:宋体11号、表头灰底、数值 0.0000、日期 yyyy-mm-dd
Step 3: 计算分位数并生成策略
脚本按以下规则生成策略文本:
| 分位数范围 | 期限利差判断 | 品种利差判断 |
|---|---|---|
| < 10% | ★★偏窄→做陡 | ★★偏窄→超配地方债 |
| 10%-30% | ★偏窄→观望 | ★偏窄→低配转地方债 |
| 30%-70% | ▼适中→标配 | ▼适中→标配 |
| 70%-90% | ★偏宽→关注收窄 | ★偏宽→低配转国债 |
| > 90% | ★★偏宽→做平 | ★★偏宽→超配国债 |
策略文本写入各 sheet 的 Row 5/6,为静态文本(Wind 更新后需重新运行脚本刷新)。
Step 4: 验证
- 确认基础数据表未修改
- 抽查前几行的公式引用列是否匹配
- 抽查近3年分位数计算是否正确(>749个交易日窗口)
- 确认跨表引用
'基础数据-自动更新'!...未被误伤
Key Formula Patterns
日期引用(Row 9 开始)
=IF('基础数据-自动更新'!A8="","",'基础数据-自动更新'!A8)
利差计算(INDEX/MATCH 按日期匹配)
=IFERROR(IF(AND(
INDEX('基础数据-自动更新'!$C$8:$C$5000,MATCH($A9,'基础数据-自动更新'!$A$8:$A$5000,0))>0,
INDEX('基础数据-自动更新'!$E$8:$E$5000,MATCH($A9,'基础数据-自动更新'!$A$8:$A$5000,0))>0
), 减法, ""), "")
>0 检查用于处理地方债早期数据缺失的情况(INDEX 对空单元格返回 0)。
分位数公式(Row 8)
=IF(ISNUMBER(B9),COUNTIF(B9:B757,"<="&B9)/COUNT(B9:B757),"")
3年窗口约749个交易日(从 Row 9 到 Row 757),窗口大小取决于数据频率。
Formatting Conventions
参考用户在 国债地方债收益率_利差分析_含策略.xlsx 中的调整:
- 标题行:深蓝(#1F4E79),加粗,全宽合并,行高30
- 副标题:灰色(#666666),全宽合并,行高20
- 策略标题:白字(#FFFFFF)深蓝底(#2F5496),只合并 A5:C5(不遮数据列)
- 策略详情:深色字(#333333)浅黄底(#FFF2CC),合并 A6:D6,行高 140-155
- 数据表头:宋体11号加粗,灰底(#D9D9D9)
- 分位行:百分比格式(0.00%)
- 数据行:数值格式(0.0000),日期格式(yyyy-mm-dd)
- 冻结窗格:B7(策略区和日期列固定)
Resources
scripts/build_spreads.py
主构建脚本。完整的工作流程,包括读取源数据、创建利差子表、 写入公式、计算分位数、生成策略文本、应用格式。
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 专业金融分析工具,解决国债/地方债利差分析刚需
- 从 Wind 数据自动构建分析表,显著提升专业用户工作效率
Highlights
- 触发词覆盖全面,包含期限利差、品种利差、分位数等核心术语
- 典型触发语列举清晰,边界明确不易误触
Highlights
- 四步式完整工作流,Phase 划分清晰
- 输出结构、公式模式、格式规范详尽,端到端示例完整
Highlights
- 基础数据表完全不动,安全性高
- INDEX/MATCH 按日期匹配,不依赖行位置,适应 Wind 自动更新
- IFERROR 和 >0 检查处理异常情况,分位数计算窗口合理
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.