Function yield_solve
pub fn yield_solve(
bond: &FixedRateBond,
dirty: f64,
settlement: NaiveDate,
basis: YieldBasis,
) -> Result<YieldSolve, YieldSolveError>Expand description
The yield implied by a dirty price, by bracketed Newton.
A passive kernel. A yield is a quoting convention read off a price, so
this takes and returns plain numbers. A caller wanting the solved yield to
carry the price’s sensitivity reattaches it with
yield_sensitivity rather than putting the iteration on a tape.
The flows are built once; each step prices them in first-order forward mode and takes the value and the slope off the same pass. Convergence is scale-free — a residual small relative to the price, or a step that has stopped moving the yield — so a ten-million-face bond converges in the same steps as a hundred-face one.
§Errors
YieldSolveError::Unbracketed when no yield in [−50%, 200%] produces
the price; YieldSolveError::Unconverged if the cap is reached.