pub fn simulate_single_leg<S, X, Y>(
strategy: &S,
sim: &Simulator<X, Y>,
exit: ExitPolicy,
) -> Result<SimulationStatsResult, BacktestError>Expand description
Simulates a single-leg strategy across every walk of sim.
Prices the leg once for the opening premium, evaluates each walk with
SingleLegPathEvaluator on the rayon pool (emitting a debug event
per path and an info event at the end) and aggregates the results, in
walk order, with SimulationStatsResult::from_results. The paths are
independent, so the statistics are those of a serial run (#863).
§Errors
Returns a BacktestError when the strategy has no single leg, a
Black-Scholes price or an expiration P&L fails, a step cannot be read as
a price or carries a negative index, or the aggregate statistics
overflow. When several paths fail, the error is the lowest-indexed
path’s, as in a serial run; the other paths are still evaluated.