Skip to main content

create_sample_option_simplest

Function create_sample_option_simplest 

Source
pub fn create_sample_option_simplest(
    option_style: OptionStyle,
    side: Side,
) -> Options
Expand description

Creates a simplified sample option contract for testing or demonstration purposes.

This function generates an Options instance with pre-defined values, requiring only the specification of the option style (Call or Put) and market position (Long or Short). It uses Apple Inc. (AAPL) as the underlying security with standard parameters suitable for basic examples or testing scenarios.

§Parameters

  • option_style - Specifies whether the option is a Call or Put
  • side - Indicates whether the position is Long or Short

§Returns

Returns an Options instance with the following predefined values:

  • European-style option
  • AAPL as the underlying symbol
  • Strike price of $100.0
  • 30 days until expiration
  • 20% implied volatility (0.2)
  • Quantity of 1.0 contracts
  • Underlying price of $100.0
  • 5% risk-free rate
  • 1% dividend yield
  • No exotic parameters

§Examples

use optionstratlib_core::model::utils::create_sample_option_simplest;
use optionstratlib_core::model::{OptionStyle, Side};
let long_call = create_sample_option_simplest(OptionStyle::Call, Side::Long);
let short_put = create_sample_option_simplest(OptionStyle::Put, Side::Short);