Metadata-Version: 2.5
Name: callable-bond-analytics
Version: 0.1.0
Summary: Zero-network QuantLib callable & perpetual AT1 bond analytics: ACT/ACT ICMA cashflows, YTC, YTP/YTW with post-call reset stubs, Modified Duration, DV01, and par-swap I-spread / Treasury G-spread interpolation
Project-URL: Homepage, https://github.com/benjamin-di/callable-bond-analytics
Project-URL: Issues, https://github.com/benjamin-di/callable-bond-analytics/issues
Author: benjamin-di
License-Expression: MIT
License-File: LICENSE
Keywords: at1,bonds,duration,dv01,finance,fixed-income,g-spread,i-spread,quantlib,ytc,ytp,ytw
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Office/Business :: Financial :: Investment
Requires-Python: >=3.11
Requires-Dist: quantlib<2,>=1.35
Description-Content-Type: text/markdown

# callable-bond-analytics

Zero-network fixed-income analytics for callable and perpetual AT1 bonds powered by QuantLib:

- **Schedule & XIRR primitives (`callable_bond_analytics.schedule`)**: ACT/ACT ICMA coupon schedules, accrued interest, bisection ACT/365 `xirr`, standalone `ytc`, and DV01/MV-weighted `portfolio_yield_summary`.
- **QuantLib callable & perpetual pricing (`callable_bond_analytics.quantlib_pricing`)**:
  - `calculate`: ACT/ACT ICMA cashflows with unadjusted accrual periods and `Following` payment dates, off-cycle call-date accrued stubs, annual 30/360 Bond Basis comparison YTC, street YTC, Modified Duration, DV01 per 100, +200 bp dirty price shock, and repricing residual check.
  - `ytp_from_reset`: perpetual AT1 Yield-to-Perpetuity (YTP) and Yield-to-Worst (YTW) with exact mid-period coupon reset stub splitting.
  - `fixed_usd_ytm`: conventional 30/360 semiannual street YTM with German T+2 settlement.
- **Spread interpolation (`callable_bond_analytics.spreads`)**:
  - `interpolate_par_swap` / `add_spread`: provider-agnostic par IRS I-spread interpolation with business-day pillar adjustment, curve-lag disclosure, and strict no-extrapolation guards.
  - `treasury_g_spread`: linear Treasury par-yield G-spread interpolation without extrapolation.

## Installation

```bash
pip install callable-bond-analytics
```

## Quick Start

```python
from datetime import date
from callable_bond_analytics import calculate, ytp_from_reset, treasury_g_spread

terms = {
    "coupon": 0.065,
    "frequency": 2,
    "pay_anchors": [(5, 15), (11, 15)],
    "day_count": "ACT/ACT",
    "payment_convention": "Following",
    "payment_calendar": "TARGET",
    "settlement_days": 2,
    "first_call": "2030-05-15",
    "call_price": 100.0,
    "reset": {"date": "2030-05-15", "margin": 0.0425},
}

res = calculate(terms, clean=98.5, price_date=date(2026, 6, 1))
print(f"YTC: {res['ytc']:.4%}, ModDur: {res['modified_duration']:.2f}, DV01: {res['dv01_per_100']:.4f}")

ytw = ytp_from_reset(terms, clean=98.5, price_date=date(2026, 6, 1), reset_swap_rate=0.025)
print(f"YTP: {ytw['ytp']:.4%}, YTW: {ytw['ytw']:.4%} ({ytw['workout_regime']})")

g = treasury_g_spread(ytm=0.055, years=4.0, curve={2.0: 0.041, 5.0: 0.044})
print(f"G-spread: {g['g_spread_bps']:.1f} bp")
```

## License

MIT — see [LICENSE](LICENSE).
