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: dedup strategy trace! P&L and clarify Overflow doc
Two small correctness / docs fixes surfaced in the review on #371.
- `strategies::short_strangle::calculate_profit_at` and
`strategies::short_straddle::calculate_profit_at` were calling
`pnl_at_expiration` three times per leg: twice inside the `trace!`
argument list and once inside `d_sum`. Besides the wasted work
(`pnl_at_expiration` builds several `Position` clones and re-runs
premium and fee arithmetic), it meant the `trace!` snapshot and the
returned total could differ if any leg had intermittent errors or
side-effecting dependencies. Both implementations now compute
`call_pnl` / `put_pnl` once, feed them into `d_sum` to get `total`,
and use the three cached locals in the `trace!` line and the `Ok`
return.
- `DecimalError::Overflow` docs were reworded to match the actual
behaviour: the operands are part of the `#[error]` display
template and therefore visible in any formatted error string that
reaches downstream modules via the `#[from]` cascade. The previous
note claimed the operands were "never re-emitted through the
public API surface", which is incorrect. The doc now explicitly
points callers that need to redact operand values towards a
custom `Display` / match-and-reformat path.
No functional API change. `cargo test --lib` passes (3751 / 5
ignored / 0 regressions). `cargo clippy --lib --all-features`
reports zero warnings. `make pre-push` is clean.
Refs #335, PR #371
0 commit comments