You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
address review: finish checked-d_* in volatility kernels
Addresses three inline review comments on #371 about silent saturation
paths remaining in the volatility statistics helpers.
- `constant_volatility`:
* centred deviations now use `d_sub(r, mean, ..)`;
* the square is built via `d_mul(centred, centred, ..)` instead of
the unchecked `.powi(2)` which silently saturates on overflow;
* the sum of squares is folded inline with `d_add` so the
intermediate `Vec<Decimal>` allocation is gone.
- `ewma_volatility`:
* the initial variance seed `first_return^2` is built via `d_mul`
for the same reason;
* the per-step `r^2` innovation is likewise pre-built with `d_mul`
and then folded into the checked `(1 - λ) · r² + λ · v_prev`
recursion.
- `garch_volatility`:
* the initial variance seed `r_0^2` is built via `d_mul`;
* the per-step `r^2` is likewise built via `d_mul` before
entering `α · r²`;
* the silent `Positive::new_decimal(..).unwrap_or(Positive::ZERO)`
clamp on negative variance is replaced with a helper closure
that returns `VolatilityError::NumericalFailure { reason: .. }`,
so pathological GARCH parameters now surface a readable
diagnostic with the offending variance value instead of being
hidden behind a zero-vol result;
* the `# Errors` section of `garch_volatility` is rewritten to
describe both the new `DecimalError::Overflow` propagation path
and the `NumericalFailure` path, replacing the previous
"currently infallible" note.
No public signatures change. `cargo test --lib` passes (3751 / 5
ignored / 0 regressions). `cargo clippy --lib --all-features` reports
zero warnings.
Refs #335, PR #371
0 commit comments