← Back to Skills Marketplace
gechengling

Security Bond Analysis

by lingfeng-19 · GitHub ↗ · v2.0.0 · MIT-0
cross-platform ✓ Security Clean
50
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install security-bond-analysis
Description
AI-powered bond analysis for China market including valuation, yield, duration, convexity, credit spread analysis, and bond portfolio management.
README (SKILL.md)

\r \r

Bond Analysis Expert / 债券分析专家\r

\r

English: AI-powered bond analysis expert — covers bond valuation, yield analysis, duration/convexity calculation, credit spread analysis, and bond portfolio management. Built for fixed income professionals.\r \r 中文: 债券分析专家——覆盖债券估值、收益率分析、久期/凸性计算、信用利差分析、债券组合管理。适用:固收分析师、债券交易员、组合管理人。\r \r ---\r \r

Industry Pain Points / 行业痛点\r

\r | Pain Point / 痛点 | Impact / 影响 | Solution / 本Skill解决方案 |\r |------------------|-------------|------------------------|\r | 收益率计算复杂 | 多种收益率指标容易混淆 | 标准化收益率计算框架 |\r | 信用分析耗时 | 发行主体众多,分析量大 | 模板化信用分析框架 |\r | 利率风险难测 | 久期/凸性概念抽象 | 可视化风险分析 |\r | 城投债信仰 | 城投刚兑预期与违约现实冲突 | 区域财政分析模型 |\r | 久期管理难 | 利率变动对组合影响大 | 久期匹配优化工具 |\r \r ---\r \r

Trigger Keywords / 触发关键词\r

\r English Triggers: bond analysis, yield curve, duration, convexity, credit spread, China bonds, fixed income, bond valuation, interest rate risk, credit risk\r \r 中文触发词(优先): 债券分析 / 收益率曲线 / 久期 / 凸性 / 信用利差 / 中国债券 / 固收 / 债券估值 / 利率风险 / 信用风险 / 国债 / 企业债 / 城投债 / 金融债 / 可转债 / 债券回购 / 债券评级 / YTM / 即期收益率 / 到期收益率\r \r ---\r \r

Core Capabilities / 核心能力\r

\r

1. Bond Valuation Engine / 债券估值引擎\r

\r

import numpy as np\r
import pandas as pd\r
\r
class BondAnalyzer:\r
    """债券分析引擎"""\r
    \r
    @staticmethod\r
    def calculate_price(face_value: float, coupon_rate: float, \r
                       ytm: float, years: int, \r
                       frequency: int = 2) -> float:\r
        """\r
        债券定价\r
        Args:\r
            face_value: 面值(元)\r
            coupon_rate: 年票面利率\r
            ytm: 到期收益率\r
            years: 剩余期限(年)\r
            frequency: 付息频率(1=年付,2=半年付)\r
        """\r
        n = years * frequency\r
        r_per_period = ytm / frequency\r
        c_per_period = (face_value * coupon_rate) / frequency\r
        \r
        # 现金流现值\r
        pv_coupons = sum([c_per_period / (1 + r_per_period) ** t \r
                         for t in range(1, n + 1)])\r
        pv_face = face_value / (1 + r_per_period) ** n\r
        \r
        return pv_coupons + pv_face\r
    \r
    @staticmethod\r
    def calculate_ytm(price: float, face_value: float,\r
                     coupon_rate: float, years: float,\r
                     frequency: int = 2) -> float:\r
        """\r
        计算到期收益率(YTM)- 牛顿迭代法\r
        """\r
        n = years * frequency\r
        c = (face_value * coupon_rate) / frequency\r
        \r
        # 初始猜测\r
        ytm = coupon_rate\r
        \r
        for _ in range(100):\r
            pv = sum([c / (1 + ytm/frequency) ** t \r
                     for t in range(1, n + 1)]) + face_value / (1 + ytm/frequency) ** n\r
            \r
            diff = price - pv\r
            \r
            # 导数(久期近似)\r
            duration = BondAnalyzer.calculate_duration(\r
                price, face_value, coupon_rate, ytm, years, frequency\r
            )\r
            dv = -duration / (1 + ytm/frequency) * diff\r
            \r
            ytm = ytm + diff / dv * 0.5\r
            \r
            if abs(diff) \x3C 1e-6:\r
                break\r
        \r
        return ytm\r
    \r
    @staticmethod\r
    def calculate_duration(price: float, face_value: float,\r
                          coupon_rate: float, ytm: float,\r
                          years: float, frequency: int = 2) -> float:\r
        """\r
        计算久期(Macauley Duration)\r
        """\r
        n = int(years * frequency)\r
        c = (face_value * coupon_rate) / frequency\r
        r = ytm / frequency\r
        \r
        # 加权平均到期时间\r
        weighted_time = sum([t * c / (1 + r) ** t for t in range(1, n + 1)])\r
        weighted_time += n * face_value / (1 + r) ** n\r
        \r
        return weighted_time / price / frequency  # 转换为年\r
    \r
    @staticmethod\r
    def calculate_convexity(price: float, face_value: float,\r
                          coupon_rate: float, ytm: float,\r
                          years: float, frequency: int = 2) -> float:\r
        """\r
        计算凸性\r
        """\r
        n = int(years * frequency)\r
        c = (face_value * coupon_rate) / frequency\r
        r = ytm / frequency\r
        \r
        weighted_sq = sum([t * (t + 1) * c / (1 + r) ** (t + 2) \r
                          for t in range(1, n + 1)])\r
        weighted_sq += n * (n + 1) * face_value / (1 + r) ** (n + 2)\r
        \r
        return weighted_sq / price / (frequency ** 2)\r
    \r
    @staticmethod\r
    def price_change_estimate(duration: float, convexity: float,\r
                             rate_change: float) -> dict:\r
        """\r
        利率变动对价格的影响估算\r
        """\r
        # 久期效应\r
        duration_effect = -duration * rate_change\r
        \r
        # 凸性效应\r
        convexity_effect = 0.5 * convexity * (rate_change ** 2)\r
        \r
        total_effect = duration_effect + convexity_effect\r
        \r
        return {\r
            "duration_effect": round(duration_effect * 100, 4),\r
            "convexity_effect": round(convexity_effect * 100, 4),\r
            "total_effect": round(total_effect * 100, 4),\r
            "approximate_new_price_pct": round((1 + total_effect) * 100, 4)\r
        }\r
```\r
\r
### 2. Credit Analysis Framework / 信用分析框架\r
\r
```markdown\r
## 信用债分析模板\r
\r
### 一、发债主体概况\r
| 项目 | 内容 |\r
|-----|------|\r
| 公司名称 | |\r
| 实际控制人 | |\r
| 主体评级 | |\r
| 行业分类 | |\r
| 主营业务 | |\r
\r
### 二、财务分析\r
```python\r
CREDIT_ANALYSIS_RATIOS = {\r
    "盈利能力": {\r
        "毛利率": ">30%为优质",\r
        "净利率": ">15%为优质",\r
        "ROE": ">10%为优质"\r
    },\r
    "偿债能力": {\r
        "资产负债率": "\x3C70%为稳健",\r
        "流动比率": ">1.5为稳健",\r
        "利息保障倍数": ">3倍为稳健"\r
    },\r
    "现金流": {\r
        "经营现金流/带息债务": ">15%为稳健",\r
        "经营现金流/资本支出": ">100%为稳健"\r
    }\r
}\r
```\r
\r
### 三、信用利差分析\r
```python\r
def analyze_credit_spread(bond_yield: float, treasury_yield: float,\r
                         rating: str) -> dict:\r
    """\r
    信用利差分析\r
    """\r
    spread = bond_yield - treasury_yield\r
    \r
    # 评级对应利差参考\r
    SPREAD_REFERENCE = {\r
        "AAA": 0.50,  # 50bp\r
        "AA+": 0.80,\r
        "AA": 1.20,\r
        "AA-": 1.50,\r
        "A+": 2.00,\r
        "A": 2.50\r
    }\r
    \r
    reference = SPREAD_REFERENCE.get(rating, 2.0)\r
    \r
    return {\r
        "credit_spread": round(spread * 100, 2),\r
        "reference_spread": reference,\r
        "relative_value": "低估" if spread \x3C reference else "高估",\r
        "spread_premium": round((spread - reference) * 100, 2)\r
    }\r
```\r
```\r
\r
### 3. Bond Portfolio Management / 债券组合管理\r
\r
```python\r
class BondPortfolio:\r
    """债券组合管理"""\r
    \r
    def __init__(self):\r
        self.bonds = []\r
    \r
    def add_bond(self, bond: dict):\r
        """添加债券"""\r
        # 计算关键指标\r
        bond["price"] = self._calculate_bond_price(bond)\r
        bond["ytm"] = self._calculate_ytm(bond)\r
        bond["duration"] = self._calculate_duration(bond)\r
        bond["convexity"] = self._calculate_convexity(bond)\r
        bond["dv01"] = bond["duration"] * bond["price"] / 100 / 100  # 每bp变化\r
        \r
        self.bonds.append(bond)\r
    \r
    def portfolio_duration(self) -> float:\r
        """组合久期"""\r
        total_value = sum(b["market_value"] for b in self.bonds)\r
        weighted_duration = sum(\r
            b["duration"] * b["market_value"] for b in self.bonds\r
        ) / total_value\r
        return weighted_duration\r
    \r
    def portfolio_credit_breakdown(self) -> dict:\r
        """组合信用分布"""\r
        breakdown = {}\r
        for bond in self.bonds:\r
            rating = bond.get("rating", "Unknown")\r
            if rating not in breakdown:\r
                breakdown[rating] = {"count": 0, "value": 0}\r
            breakdown[rating]["count"] += 1\r
            breakdown[rating]["value"] += bond.get("market_value", 0)\r
        \r
        return breakdown\r
    \r
    def interest_rate_risk(self, rate_shock: float) -> dict:\r
        """利率风险分析"""\r
        port_duration = self.portfolio_duration()\r
        \r
        # 纯久期效应\r
        duration_pnl = -port_duration * rate_shock / 100\r
        \r
        # 凸性调整\r
        port_convexity = sum(\r
            b["convexity"] * b["market_value"] for b in self.bonds\r
        ) / sum(b["market_value"] for b in self.bonds)\r
        convexity_pnl = 0.5 * port_convexity * (rate_shock/100) ** 2\r
        \r
        return {\r
            "portfolio_duration": round(port_duration, 3),\r
            "rate_shock_bp": round(rate_shock * 100, 0),\r
            "duration_pnl_pct": round(duration_pnl * 100, 2),\r
            "convexity_pnl_pct": round(convexity_pnl * 100, 2),\r
            "total_pnl_pct": round((duration_pnl + convexity_pnl) * 100, 2)\r
        }\r
```\r
\r
---\r
\r
## Quick Command Templates / 快速指令模板\r
\r
**债券定价:**\r
```\r
计算债券价格:\r
- 面值:100元\r
- 票面利率:4%\r
- 到期收益率:3.5%\r
- 剩余期限:5年\r
- 付息频率:年付\r
```\r
\r
**久期分析:**\r
```\r
分析债券组合的久期风险:\r
- 组合总规模:1000万\r
- 利率上升50bp时的损益\r
```\r
\r
---\r
\r
## Disclaimer\r
\r
Bond analysis involves various risks including interest rate risk and credit risk. This skill provides analysis tools for educational purposes only and does not constitute investment advice.\r
Usage Guidance
This appears safe to install from a security perspective. Treat its bond and credit analysis as informational rather than guaranteed financial advice, and verify calculations before using them for real investment decisions.
Capability Analysis
Type: OpenClaw Skill Name: security-bond-analysis Version: 2.0.0 The skill bundle provides legitimate financial analysis tools for bond valuation, yield calculations, and portfolio risk management. The Python code in SKILL.md implements standard mathematical formulas for fixed income analysis (e.g., Macauley duration, convexity, and Newton's method for YTM) using numpy and pandas, with no evidence of data exfiltration, malicious execution, or prompt injection.
Capability Assessment
Purpose & Capability
The described purpose is bond valuation, yield, duration, convexity, credit spread, and portfolio analysis; the visible SKILL.md content matches that purpose with formulas, templates, and example Python snippets.
Instruction Scope
No artifact-backed evidence of prompt overrides, hidden control instructions, autonomous tool use, or instructions to bypass user intent was provided.
Install Mechanism
There is no install spec or runnable code, which keeps execution risk low; however, the package provenance is limited because the source is unknown and no homepage is listed.
Credentials
The artifacts do not request files, network access, environment variables, credentials, local profiles, or privileged system access.
Persistence & Privilege
No persistence, background process, account mutation, privileged path access, or long-running behavior is shown.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install security-bond-analysis
  3. After installation, invoke the skill by name or use /security-bond-analysis
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v2.0.0
**Major update: Expanded scope with full-featured bond analysis for the China market.** - Comprehensive bond valuation engine with price, YTM, duration, and convexity calculations. - Standardized frameworks for yield analysis, credit spread analysis, and credit rating evaluation. - Dedicated modules for managing and analyzing bond portfolios, including risk and credit exposure. - Enhanced support for China-specific bond types and market conventions, with relevant trigger keywords in both English and Chinese. - Clear documentation on industry pain points and how the skill addresses them.
Metadata
Slug security-bond-analysis
Version 2.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is Security Bond Analysis?

AI-powered bond analysis for China market including valuation, yield, duration, convexity, credit spread analysis, and bond portfolio management. It is an AI Agent Skill for Claude Code / OpenClaw, with 50 downloads so far.

How do I install Security Bond Analysis?

Run "/install security-bond-analysis" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Security Bond Analysis free?

Yes, Security Bond Analysis is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Security Bond Analysis support?

Security Bond Analysis is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Security Bond Analysis?

It is built and maintained by lingfeng-19 (@gechengling); the current version is v2.0.0.

💬 Comments