pub fn create_sample_option(
option_style: OptionStyle,
side: Side,
underlying_price: Positive,
quantity: Positive,
strike_price: Positive,
volatility: Positive,
) -> OptionsExpand description
Creates a sample option contract with predefined parameters for testing or demonstration purposes.
This utility function simplifies the creation of option contracts by providing a standard configuration with reasonable defaults. It creates a European-style option with a 30-day expiration and a fixed risk-free rate of 5%.
§Parameters
option_style- Specifies whether the option is a Call or Put.side- Determines if the position is Long or Short.underlying_price- The current market price of the underlying asset.quantity- The number of contracts in the position.strike_price- The price at which the option holder can exercise the option.volatility- The implied volatility used for pricing the option.
§Returns
An Options struct configured with the specified parameters and sensible defaults.
§Examples
use optionstratlib_core::model::{OptionStyle, Side};
use positive::pos_or_panic;
use optionstratlib_core::model::utils::create_sample_option;
let option = create_sample_option(
OptionStyle::Call,
Side::Long,
pos_or_panic!(150.0), // underlying price
pos_or_panic!(10.0), // quantity
pos_or_panic!(155.0), // strike price
pos_or_panic!(0.25), // volatility (25%)
);