Skip to main content

Crate option_type

Crate option_type 

Source
Expand description

§Option Type

Option contract type definitions including standard and exotic options.

This crate provides the OptionType enum which classifies options contracts by their exercise characteristics and payoff structures:

  • Standard: European, American
  • Path-dependent: Asian, Barrier, Lookback, Cliquet
  • Multi-asset: Rainbow, Spread, Exchange
  • Structural: Compound, Chooser, Binary, Bermuda
  • Modified payoff: Power, Quanto

It also provides sub-type enums used within exotic option variants:

And the lightweight OptionBasicType struct for referencing core option properties.

All leaf enums use #[repr(u8)] for compact memory layout. Pure helper methods are annotated with #[must_use] and #[inline].

§Features

  • Full serde serialization/deserialization support
  • Optional utoipa support for OpenAPI schema generation (enable the utoipa feature)
  • Depends on financial_types for OptionStyle and Side
  • Depends on positive for Positive type-safe values
  • Depends on expiration_date for ExpirationDate

§Usage

use option_type::{OptionType, AsianAveragingType, BarrierType};

let european = OptionType::European;
let asian = OptionType::Asian {
    averaging_type: AsianAveragingType::Arithmetic,
};
let barrier = OptionType::Barrier {
    barrier_type: BarrierType::UpAndIn,
    barrier_level: 120.0,
    rebate: None,
};

assert_eq!(format!("{european}"), "European Option");
assert!(european.is_european());
assert!(asian.is_exotic());

Modules§

prelude
Prelude module for convenient imports.

Structs§

OptionBasicType
A structure representing the basic properties of an option in financial terms.

Enums§

AsianAveragingType
Describes how the average price is calculated for Asian options.
BarrierType
Describes the type of barrier for Barrier options.
BinaryType
Represents different types of binary options, which are financial instruments that provide a fixed payout based on whether certain conditions are met.
LookbackType
Describes the type of lookback option.
OptionType
Represents the type of option in a financial context.
RainbowType
Describes the type of rainbow option based on how multiple assets are combined.