Skip to main content

generator_positive

Function generator_positive 

Source
pub fn generator_positive(
    walk_params: &WalkParams<Positive, Positive>,
) -> Result<Vec<Step<Positive, Positive>>, SimulationError>
Expand description

Generates a vector of Steps containing Positive x-values and Positive y-values.

Simulates the stochastic process selected by walk_params.walk_type for a plain positive value (typically an underlying price) without rebuilding option chains.

§Contract (shared with optionstratlib_market::chains::generator_optionchain and

optionstratlib_market::series::generator_optionseries, both behind the synthetic feature)

  • 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); any other step-advance error is propagated.
  • The result is truncated to at most walk_params.size steps.

§Arguments

  • walk_params - A reference to the WalkParams struct containing the walk parameters.

§Returns

  • Ok(Vec<Step<Positive, Positive>>) - A vector of Steps representing the simulated walk.
  • Err(ChainError) - If the underlying simulator fails for any reason.

§Errors

Returns SimulationError if the random-walk generator fails — including SimulationError::InsufficientHistoricalData when a Historical walk has fewer prices than walk_params.size.