pub fn walk_steps<Y, E, F>(
walk_params: &WalkParams<Positive, Y>,
next_y: F,
) -> Result<Vec<Step<Positive, Y>>, E>Expand description
Runs a walk and materializes it as a vector of Steps, delegating the
construction of each y-value to next_y.
This is the shared driver behind generator_positive and, behind the
synthetic feature, optionstratlib_market::chains::generator_optionchain and
optionstratlib_market::series::generator_optionseries.
§Contract
- The returned vector always starts with
walk_params.init_step. - If the walker yields no values beyond the initial one (e.g. a size-1 walk), only the initial step is returned.
- The walk is truncated when the x-step reaches expiration
(
SimulationError::ExpirationReached) or whennext_yreturnsOk(None); any other step-advance error is propagated. - The result is truncated to at most
walk_params.sizesteps. - With
walk_params.seedset, the path, and therefore the result for a purenext_y, is identical on every run (seeWalkParams);walk_steps_parreturns the same steps.
§Parameters
walk_params- The walk configuration;walk_params.walk_typeselects the stochastic process viacrate::simulation::WalkTypeAble::generate_with_vol.next_y- Builds the y-value for one step from(new_price, step_volatility, advanced_x_step). ReturningOk(None)ends the walk gracefully at the previous step.
§Volatility
The volatility passed to next_y is per-step wherever the model provides
one: the simulated vol path for stochastic-volatility walk types
(Garch, Heston, Custom, Telegraph), an expanding-window estimate
free of look-ahead bias for Historical walks, and the walk type’s
constant volatility parameter otherwise.
§Returns
Ok(Vec<Step<Positive, Y>>)- The simulated walk.Err(E)- If the walker, the volatility estimation, the x-step advance, ornext_yfail.
§Errors
The driver is generic over its error type: every internal failure is a
SimulationError lifted into E via From, so the simulation layer
carries no chain-specific error types — the chain and series generators
simply instantiate E = ChainError. Walker errors include
SimulationError::InsufficientHistoricalData when a Historical walk
has fewer prices than walk_params.size; next_y errors are returned
verbatim.