| Crates.io | convex-yas |
| lib.rs | convex-yas |
| version | 0.10.1 |
| created_at | 2025-12-07 17:32:33.561792+00 |
| updated_at | 2025-12-07 17:32:33.561792+00 |
| description | Bloomberg YAS (Yield Analysis System) replication for the Convex fixed income library |
| homepage | |
| repository | https://github.com/sujitn/convex |
| max_upload_size | |
| id | 1971972 |
| size | 141,608 |
Bloomberg YAS (Yield Analysis System) replication for the Convex fixed income analytics library.
convex-yas provides Bloomberg YAS-compatible analytics, designed to match Bloomberg's yield and spread calculations to production accuracy:
| Metric | Tolerance |
|---|---|
| Street Yield | +/- 0.00001% |
| True Yield | +/- 0.00001% |
| G-Spread | +/- 0.1 bps |
| Z-Spread | +/- 0.1 bps |
| Duration | +/- 0.001 |
| Convexity | +/- 0.001 |
Add this to your Cargo.toml:
[dependencies]
convex-yas = "0.1"
use convex_yas::{YasAnalysis, YasResult};
use convex_bonds::FixedRateBond;
use convex_curves::DiscountCurve;
let bond = FixedRateBond::builder()
.cusip("097023AH7")
.coupon_rate(dec!(0.075))
.maturity(Date::from_ymd(2025, 6, 15))
.frequency(Frequency::SemiAnnual)
.day_count(DayCount::Thirty360US)
.build()?;
let settlement = Date::from_ymd(2024, 4, 29);
let price = dec!(110.503);
let yas = YasAnalysis::new(&bond, price, settlement)
.with_treasury_curve(&treasury_curve)
.with_swap_curve(&swap_curve)
.analyze()?;
println!("Street Convention: {:.6}%", yas.street_yield.as_percent());
println!("True Yield: {:.6}%", yas.true_yield.as_percent());
println!("Current Yield: {:.3}%", yas.current_yield.as_percent());
println!("G-Spread: {:.1} bps", yas.g_spread.as_bps());
println!("Z-Spread: {:.1} bps", yas.z_spread.as_bps());
println!("Modified Duration: {:.3}", yas.modified_duration);
println!("Convexity: {:.3}", yas.convexity);
println!("Accrued Interest: ${:.2}", yas.accrued_interest);
use convex_yas::yields::{StreetYield, TrueYield, CurrentYield};
// Street convention yield
let street = StreetYield::calculate(&bond, price, settlement)?;
// True yield (adjusted for settlement)
let true_yield = TrueYield::calculate(&bond, price, settlement)?;
// Current yield
let current = CurrentYield::calculate(&bond, price)?;
use convex_yas::invoice::SettlementInvoice;
let invoice = SettlementInvoice::generate(
&bond,
price,
settlement,
notional: dec!(1_000_000),
)?;
println!("Principal: ${:.2}", invoice.principal);
println!("Accrued: ${:.2}", invoice.accrued);
println!("Total Due: ${:.2}", invoice.total);
use convex_yas::yields::MoneyMarketYield;
use convex_bonds::government::TreasuryBill;
let mm = MoneyMarketYield::calculate(&tbill, settlement)?;
println!("Discount Yield: {:.3}%", mm.discount_yield.as_percent());
println!("BEY: {:.3}%", mm.bond_equivalent_yield.as_percent());
This crate is validated against Bloomberg YAS for the following reference bonds:
This project is licensed under the MIT License - see the LICENSE file for details.