Function risk_with
pub fn risk_with<F>(
market: &MarketContext,
tape: &mut Tape<f64>,
value: F,
) -> Result<(f64, RiskVector), RiskError>Expand description
The risk pass. One forward pass, one seed, one reverse sweep, one collection.
The tape is borrowed rather than created, so a caller valuing the same book
repeatedly reuses one allocation: Tape::record clears the recording and
keeps the buffers, which is what makes a steady-state valuation allocate no
tape memory at all.
value is called once. Every trade in a book prices inside that one call, so
the sweep count does not depend on how many trades or curves there are — it
is one, always.
§Errors
RiskError::Pricing if the valuation failed, or the read-back’s own errors.
§Panics
Panics if another recording is already open on this thread — recordings do not nest.