Skip to main content

Module bonds

Module bonds 

Expand description

Fixed-rate bonds, and the yield-space analytics a street quote is read in.

Yield space is a quoting convention, not a curve. A bond’s yield, duration and convexity depend on its cashflows, its day count and its compounding, and on nothing else — which is exactly why published figures for them reproduce across systems, and why the vendor tie-outs check these rather than a curve-discounted price.

§Duration and convexity are not written down here

The dirty price is one generic body. Modified duration is −P′/P and convexity is P″/P, so both are read off that body evaluated in second-order forward mode: seed the yield, price once, take the derivatives the mode computed. There is no analytic duration formula in this file to disagree with the pricing formula above it — the same argument that keeps a Black delta unwritten.

Modules§

linker
Street quote conventions for inflation-linked bonds.
zero_coupon
The zero-coupon bond: one payment, and three numbers all called “the yield”.

Structs§

AccrualAdjustment
A bond’s rolled accrual: the roll, and the unadjusted boundaries schedule was rolled from — what a schedule builder regenerates from, so a grid is never rebuilt off dates that have already moved.
Callability
One exercise right: a date, a price, and whose option it is.
CallableBond
A callable (or puttable) bond: a bullet host plus a schedule of exercise rights. Every field is passive contract data; an empty schedule is the bullet bond, and prices identically to it.
FixedRateBond
A fixed-rate bullet bond. Every field is passive contract data.
FloatingRateNote
A floating-rate note: coupons projecting an index, plus the face at maturity.
InflationLinkedBond
An inflation-linked bond: a real coupon on a nominal schedule, every flow scaled by I(lagged(t)) / I_base against a named price index.
YieldMoments
The price and its first two yield derivatives at one yield, from one second-order pricing pass. Every yield-space measure is a ratio of these, so a caller wanting duration, convexity, and DV01 together prices once and reads three numbers.
YieldSolve
A solved yield and the Newton steps it took.

Enums§

CallKind
Whether an exercise right belongs to the issuer or the holder.
CallPrice
The redemption price of one call entry. Passive contract data, like every other term a trade holds.
CallYieldError
Why a yield to a call could not be taken.
SpreadSolveError
Why a spread could not be implied from a price.
YieldSolveError
Why a yield solve produced no yield.

Constants§

POLE_STANDOFF 🔒
How far inside a pole the bracket starts, as a fraction of the pole’s distance from zero. Close enough that no realistic yield is excluded, far enough that the price there is finite in f64.
RECOVERY_GRID_DAYS
The recovery-integration step in days: a quarter, accurate to well under a basis point for bond-like hazard levels.
SPREAD_BRACKET 🔒
The bracket a z-spread is searched over — the same one the callable OAS uses, because at zero volatility they are solving for the same number.
SPREAD_ITERATION_CAP 🔒
Bisection over [−10%, 30%] reaches f64 resolution in about fifty halvings; the cap is the backstop.
YIELD_BRACKET 🔒
The nominal search bracket for a yield.
YIELD_ITERATION_CAP 🔒
The Newton backstop: bracketed Newton is never slower than bisection, and bisection over the nominal bracket reaches f64 resolution in about fifty halvings.
YIELD_TOLERANCE 🔒
The yield solve’s convergence, tighter than the shared default: a price is near 100, so the default’s relative residual of 1e-10 is 1e-8 per 100, which a yield read to 1e-12 cannot rest on — it was met only because Newton overshoots its own criterion. Converged when the price is within 1e-12 per 100 (a hundred times f64 resolution there), which pins the yield to about 1e-14 through a slope of a few hundred per 100, or when a step has stopped moving the yield at 1e-14. One Newton step more at most.

Functions§

act_365 🔒
The ACT/365 year fraction the ISE measures its final period on.
clean_price
The clean price per 100 face: dirty less accrued.
convexity
Convexity: P″/P.
curve_npv
The curve value of bond’s remaining flows: Σ amount·DF(date), face-scaled to the bond’s own face amount, in mode R.
curve_yield_at
The zero rate curve implies to date, expressed on basis.
dirty_price
The dirty price per 100 face at yield y, in mode R.
dirty_price_of_flows
The dirty price of already-built flows ((time, amount per 100) pairs, as FixedRateBond::timed_flows_per_100 produces) at yield y.
dirty_price_of_flows_overlaid
dirty_price_of_flows with a flat continuous overlay s on the discounting: each flow is scaled by exp(−s·t).
dirty_redemption 🔒
The dirty redemption per 100 face an exercise entry pays, or None when it is curve-dependent.
dv01
DV01 per 100 face: the price change for a one-basis-point yield move.
final_period_start 🔒
The start of the bond’s final coupon period.
forward_price_with
The forward dirty price per 100 face at t: the spot price carried to t on the financing (repo) curve.
fraction_alive 🔒
The fraction of the original face alive on date under a profile over schedule’s periods: the first period’s before issue, zero at or after maturity, the containing period’s otherwise. A repayment at a period boundary has happened on the boundary date itself.
g_spread
G-spread: the bond’s yield over the government curve’s zero rate at its maturity.
grid_back 🔒
The grid date k periods of months before anchor: the clamped month shift, promoted to the calendar last day of its month when the grid promotes. k = 1 from any boundary steps one period back on the grid.
i_spread
I-spread: the bond’s yield over the swap curve’s zero rate at its maturity.
in_final_coupon_period
Whether settlement falls inside the bond’s final coupon period — the branch that decides which arm of the ISE convention applies.
ise_simple_yield
The ISE simple yield (vendor calc type 1014) from a clean price.
japanese_simple_price
The clean price at a Japanese simple yield — the closed-form inverse of japanese_simple_yield.
japanese_simple_yield
The Japanese simple yield (vendor calc type 51, the JGB market’s primary quote) from a clean price: (c·100 + (100 − clean)/n) / clean.
macaulay_duration
Macaulay duration: the PV-weighted mean time to the bond’s remaining flows.
modified_duration
Modified duration: −P′/P.
moments 🔒
The price moments at y: (P, P′, P″), taken by the mode.
money_duration
Money duration at the bond’s own face: modified duration times the money price.
money_dv01
DV01 at the bond’s own face, in money rather than per 100.
promotes_to_month_end 🔒
Advance date by months, clamping into a short month.
pv_weighted_time
The t-weighted PV moment of flows: Σ t·PV(t) / Σ PV(t).
quoted_clean_price
The clean price bond quotes at a yield under kernel — the inverse of quoted_yield.
quoted_yield
The yield bond quotes at under kernel, from a clean price.
redemption_flows_per_100 🔒
The flows per 100 face of the scenario that redeems bond on date at redemption (a dirty amount per 100), as (time, amount) pairs measured from settlement.
risky_value
The survival-weighted value of flows plus a recovery-of-face leg.
risky_value_over 🔒
risky_value with the default intervals stated: recovery is walked over consecutive boundaries, each interval [t₀, t₁] paying R·F(t̄)·(S(t₀) − S(t₁)) on the face alive at its midpoint t̄ (whole days, rounded down) — in the mode, so a projected amount can stand for the face — discounted as timing says: from t̄ itself (AtDefault), from pays_on(t₁) — the scheduled payment date for a default in the interval (AtPeriodEnd) — or from pays_on of the last boundary (AtMaturity). The bond walks a RECOVERY_GRID_DAYS-day grid at default; a structured note walks its coupon periods at default; a credit-linked swap walks the curves’ node grid under its own timing.
shift_months 🔒
solve_bracket 🔒
The bracket a yield solve searches, given the basis it is quoted on.
solve_flat_spread 🔒
The flat continuous spread s for which Σ pvᵢ·exp(−s·τᵢ) equals target, over terms of (τ, amount·DF) snapshotted before the search — the one body the bond’s and the structured note’s z-spreads solve through.
spread_over_curve
The bond’s yield less curve’s zero rate at the bond’s maturity, both on basis.
validate_profile 🔒
Checks a notional profile: exactly one fraction per coupon period, the first 1.0, every entry finite, positive and no greater than the one before it. Shared by every bond that carries one, so the refusals read the same whichever product they come from.
yield_discount 🔒
The yield discount factor v(t) in mode R.
yield_from_dirty_price
The yield implied by a dirty price — yield_solve without the step count.
yield_moments
The YieldMoments of bond at yield y: one Jet2 pricing pass.
yield_sensitivity
∂y/∂P at a solved yield — the implicit-function derivative of the pricing relationship, for reattaching a passively-solved yield to the pricing mode.
yield_solve
The yield implied by a dirty price, by bracketed Newton.
yield_solve_of_flows
yield_solve over an already-built flow snapshot.
yield_to_call_of 🔒
The yield to a single exercise entry at dirty: the yield repricing the scenario that redeems on the entry’s date at the entry’s price.
yield_to_maturity_scenario_of 🔒
The yield to maturity scenario: redemption at par on the maturity date.
yield_to_worst_of 🔒
Yield to worst at dirty: the lowest yield over the redemption scenarios — maturity at par, together with every exercise date strictly after settlement — returned with the date attaining it.
z_spread_on_curve
The z-spread implied by a dirty price: the flat continuously-compounded spread s for which Σ aᵢ·DF(tᵢ)·exp(−s·τᵢ) equals the quote.