convex-bonds
Bond pricing and analytics for the Convex fixed income analytics library.
Overview
convex-bonds provides comprehensive bond analysis:
- Instruments: Fixed coupon bonds, zero coupon bonds
- Pricing: Present value, clean/dirty price, yield-to-maturity
- Cash Flows: Schedule generation with business day adjustments
- Risk: Duration, convexity, DV01, key rate durations
Features
Creating Bonds
use *;
use ;
use dec;
let bond = new
.isin
.coupon_rate // 2.5%
.maturity
.frequency
.currency
.day_count
.build
.unwrap;
Pricing
use BondPricer;
let settlement = from_ymd.unwrap;
// Price from yield
let result = price_from_yield.unwrap;
println!;
println!;
println!;
// Calculate YTM from price
let ytm = yield_to_maturity.unwrap;
Cash Flow Generation
use CashFlowGenerator;
let schedule = generate.unwrap;
for cf in schedule.iter
let accrued = accrued_interest.unwrap;
Calendar Integration
Use business day calendars for settlement and payment date adjustments:
use ;
let cal = new;
// Calculate settlement date (T+1)
let trade_date = from_ymd.unwrap;
let settlement = cal.settlement_date;
// Adjust payment dates
let adjusted = cal.adjust.unwrap;
Risk Analytics
use RiskCalculator;
let metrics = calculate.unwrap;
println!;
println!;
println!;
println!;
// Estimate price change for 50bp yield increase
let price_change = estimate_price_change;
Bond Types
FixedBond
Standard fixed coupon bond with:
- Periodic coupon payments
- Principal at maturity
- Configurable day count conventions
ZeroCouponBond
Discount bond with:
- No periodic coupons
- Single payment at maturity
- Issued below par
Installation
Add to your Cargo.toml:
[]
= "0.1"
License
This project is licensed under the MIT License - see the LICENSE file for details.