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§
- Accrual
Adjustment - A bond’s rolled accrual: the roll, and the unadjusted boundaries
schedulewas 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.
- Callable
Bond - 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.
- Fixed
Rate Bond - A fixed-rate bullet bond. Every field is passive contract data.
- Floating
Rate Note - A floating-rate note: coupons projecting an index, plus the face at maturity.
- Inflation
Linked Bond - An inflation-linked bond: a real coupon on a nominal schedule, every flow
scaled by
I(lagged(t)) / I_baseagainst a named price index. - Yield
Moments - 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.
- Yield
Solve - A solved yield and the Newton steps it took.
Enums§
- Call
Kind - Whether an exercise right belongs to the issuer or the holder.
- Call
Price - The redemption price of one call entry. Passive contract data, like every other term a trade holds.
- Call
Yield Error - Why a yield to a call could not be taken.
- Spread
Solve Error - Why a spread could not be implied from a price.
- Yield
Solve Error - 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%]reachesf64resolution 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
f64resolution 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
f64resolution 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 modeR. - curve_
yield_ at - The zero rate
curveimplies todate, expressed onbasis. - dirty_
price - The dirty price per 100 face at yield
y, in modeR. - dirty_
price_ of_ flows - The dirty price of already-built
flows((time, amount per 100)pairs, asFixedRateBond::timed_flows_per_100produces) at yieldy. - dirty_
price_ of_ flows_ overlaid dirty_price_of_flowswith a flat continuous overlayson the discounting: each flow is scaled byexp(−s·t).- dirty_
redemption 🔒 - The dirty redemption per 100 face an exercise entry pays, or
Nonewhen 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 toton the financing (repo) curve. - fraction_
alive 🔒 - The fraction of the original face alive on
dateunder a profile overschedule’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
kperiods ofmonthsbeforeanchor: the clamped month shift, promoted to the calendar last day of its month when the grid promotes.k = 1from 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
settlementfalls 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
datebymonths, clamping into a short month. - pv_
weighted_ time - The
t-weighted PV moment offlows:Σ t·PV(t) / Σ PV(t). - quoted_
clean_ price - The clean price
bondquotes at a yield underkernel— the inverse ofquoted_yield. - quoted_
yield - The yield
bondquotes at underkernel, from a clean price. - redemption_
flows_ 🔒per_ 100 - The flows per 100 face of the scenario that redeems
bondondateatredemption(a dirty amount per 100), as(time, amount)pairs measured fromsettlement. - risky_
value - The survival-weighted value of
flowsplus a recovery-of-face leg. - risky_
value_ 🔒over risky_valuewith the default intervals stated: recovery is walked over consecutiveboundaries, each interval[t₀, t₁]payingR·F(t̄)·(S(t₀) − S(t₁))on the face alive at its midpointt̄(whole days, rounded down) — in the mode, so a projected amount can stand for the face — discounted astimingsays: fromt̄itself (AtDefault), frompays_on(t₁)— the scheduled payment date for a default in the interval (AtPeriodEnd) — or frompays_onof the last boundary (AtMaturity). The bond walks aRECOVERY_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
sfor whichΣ pvᵢ·exp(−s·τᵢ)equalstarget, overtermsof(τ, 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 onbasis. - 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 modeR. - yield_
from_ dirty_ price - The yield implied by a dirty price —
yield_solvewithout the step count. - yield_
moments - The
YieldMomentsofbondat yieldy: oneJet2pricing pass. - yield_
sensitivity ∂y/∂Pat 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_solveover 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
sfor whichΣ aᵢ·DF(tᵢ)·exp(−s·τᵢ)equals the quote.