$npx -y skills add agiprolabs/claude-trading-skills --skill fixed-income[STUB] Bond pricing, yield curves, duration and convexity analysis, and DeFi lending rate modeling
| 1 | # Fixed Income |
| 2 | |
| 3 | > **Status: STUB** — This skill provides a basic bond calculator and an overview of planned capabilities. Full implementation is awaiting community contribution. |
| 4 | |
| 5 | Fixed income analysis bridges traditional bond mathematics with DeFi lending rate modeling. Bond pricing fundamentals — present value of cash flows, yield curves, duration, and convexity — translate directly to analyzing DeFi lending protocols where depositors earn variable or fixed rates on crypto assets. |
| 6 | |
| 7 | On Solana, lending protocols like Marginfi, Kamino, and Solend offer variable-rate lending/borrowing. Understanding term structure and rate dynamics helps optimize yield farming strategies and compare opportunities across protocols. |
| 8 | |
| 9 | This skill is informational and analytical only. It does not provide financial advice or trading recommendations. |
| 10 | |
| 11 | --- |
| 12 | |
| 13 | ## Current Capabilities |
| 14 | |
| 15 | This stub includes a working bond calculator with price, yield-to-maturity, duration, and convexity computations. See `scripts/bond_calculator.py` for the implementation. |
| 16 | |
| 17 | ```python |
| 18 | def bond_price( |
| 19 | face: float, coupon_rate: float, ytm: float, periods: int, freq: int = 2 |
| 20 | ) -> float: |
| 21 | """Calculate bond price as present value of all cash flows. |
| 22 | |
| 23 | Args: |
| 24 | face: Face (par) value of the bond. |
| 25 | coupon_rate: Annual coupon rate (decimal, e.g., 0.05 for 5%). |
| 26 | ytm: Yield to maturity (annual, decimal). |
| 27 | periods: Number of coupon periods remaining. |
| 28 | freq: Coupon frequency per year (2 = semi-annual). |
| 29 | |
| 30 | Returns: |
| 31 | Bond price (dirty price). |
| 32 | """ |
| 33 | coupon = face * coupon_rate / freq |
| 34 | y = ytm / freq |
| 35 | pv_coupons = sum(coupon / (1 + y) ** t for t in range(1, periods + 1)) |
| 36 | pv_face = face / (1 + y) ** periods |
| 37 | return pv_coupons + pv_face |
| 38 | ``` |
| 39 | |
| 40 | Run the demo: |
| 41 | |
| 42 | ```bash |
| 43 | python scripts/bond_calculator.py --demo |
| 44 | ``` |
| 45 | |
| 46 | --- |
| 47 | |
| 48 | ## Planned Capabilities |
| 49 | |
| 50 | When fully implemented, this skill will cover: |
| 51 | |
| 52 | ### Bond Pricing |
| 53 | |
| 54 | | Concept | Description | |
| 55 | |---------|-------------| |
| 56 | | Clean/Dirty Price | Price excluding/including accrued interest | |
| 57 | | Accrued Interest | Interest earned since last coupon date | |
| 58 | | Day Count Conventions | 30/360, ACT/360, ACT/365, ACT/ACT | |
| 59 | | Zero-Coupon Bonds | Discount bonds with no periodic coupons | |
| 60 | |
| 61 | ### Yield Measures |
| 62 | |
| 63 | | Yield Measure | Use Case | |
| 64 | |---------------|----------| |
| 65 | | Yield to Maturity (YTM) | Total return if held to maturity | |
| 66 | | Current Yield | Annual coupon / price | |
| 67 | | Yield to Call | Return if called at first call date | |
| 68 | | Spread to Benchmark | Credit risk premium over risk-free rate | |
| 69 | |
| 70 | ### Duration and Convexity |
| 71 | |
| 72 | | Metric | Measures | |
| 73 | |--------|----------| |
| 74 | | Macaulay Duration | Weighted average time to cash flows | |
| 75 | | Modified Duration | Price sensitivity to yield changes | |
| 76 | | Effective Duration | Duration for bonds with embedded options | |
| 77 | | Convexity | Second-order price sensitivity | |
| 78 | | Dollar Duration (DV01) | Dollar change per 1bp yield move | |
| 79 | |
| 80 | ### Yield Curve Construction |
| 81 | |
| 82 | | Method | Description | |
| 83 | |--------|-------------| |
| 84 | | Bootstrap | Extract spot rates from par bond prices | |
| 85 | | Nelson-Siegel | Parametric model with level, slope, curvature | |
| 86 | | Nelson-Siegel-Svensson | Extended model with additional curvature term | |
| 87 | | Cubic Spline | Non-parametric interpolation | |
| 88 | |
| 89 | ### DeFi Lending Rate Analysis |
| 90 | |
| 91 | | Protocol | Chain | Type | |
| 92 | |----------|-------|------| |
| 93 | | Marginfi | Solana | Variable rate | |
| 94 | | Kamino | Solana | Variable rate | |
| 95 | | Solend | Solana | Variable rate | |
| 96 | | Aave | Ethereum/Multi | Variable + stable rate | |
| 97 | | Compound | Ethereum | Variable rate | |
| 98 | |
| 99 | Planned DeFi features: |
| 100 | - Lending rate time series analysis |
| 101 | - Supply/borrow APY comparison across protocols |
| 102 | - Utilization rate impact on lending rates |
| 103 | - Fixed vs variable rate comparison (when fixed-rate protocols available) |
| 104 | - Rate arbitrage opportunity detection |
| 105 | |
| 106 | --- |
| 107 | |
| 108 | ## Prerequisites |
| 109 | |
| 110 | ```bash |
| 111 | # For full implementation |
| 112 | uv pip install numpy scipy |
| 113 | |
| 114 | # For visualization |
| 115 | uv pip install matplotlib |
| 116 | ``` |
| 117 | |
| 118 | The included `scripts/bond_calculator.py` uses only the Python standard library and runs without any dependencies. |
| 119 | |
| 120 | --- |
| 121 | |
| 122 | ## Use Cases |
| 123 | |
| 124 | ### Yield Farming Comparison |
| 125 | Compare DeFi lending rates across protocols using fixed income analytics. Annualize variable rates, compute effective yields accounting for compounding frequency, and identify the most capital-efficient opportunities. |
| 126 | |
| 127 | ### Lending Rate Analysis |
| 128 | Track lending rates over time to understand rate dynamics. Identify periods of rate compression (low utilization) vs rate expansion (high utilization) to time deposits optimally. |
| 129 | |
| 130 | ### Rate Arbitrage |
| 131 | Borrow at lower rates on one protocol and lend at higher rates on another. Duration and convexity concepts help assess the risk of rate changes during the arbitrage holding period. |
| 132 | |
| 133 | ### Risk Assessment |
| 134 | Use duration to estimate how lending positions change in value as rates move. Higher duration means greater sensiti |