Implementation:Avhz RustQuant OptionFlags
| Knowledge Sources | |
|---|---|
| Domains | Options, Quantitative_Finance |
| Last Updated | 2026-02-07 19:00 GMT |
Overview
Defines the enumeration types used across all option contracts in the library, including option type, exercise style, strike type, settlement type, averaging method, barrier type, and binary type flags.
Description
This module provides the complete set of enumeration types that parameterize option behavior throughout the instruments crate:
- TypeFlag: Call (value 1) or Put (value -1). The integer values enable use as sign multipliers in payoff formulas.
- ExerciseFlag: European (single expiry date), American (start and end date range), or Bermudan (vector of specific exercise dates). Includes an expiry() method that returns the terminal date for any variant.
- StrikeFlag: Fixed or Floating. Used by Asian and Lookback options to determine whether the strike is predetermined or derived from the path.
- SettlementFlag: Cash or Physical delivery at exercise.
- AveragingMethod: ArithmeticDiscrete, ArithmeticContinuous, GeometricDiscrete, or GeometricContinuous. Used by Asian options.
- BarrierType: UpAndOut, DownAndOut, UpAndIn, or DownAndIn. Used by Barrier options.
- BinaryType: AssetOrNothing or CashOrNothing. Used by Binary options.
All enums derive Debug and Clone (plus Copy where appropriate), making them lightweight value types.
Usage
Use these enums when constructing any OptionContract or option-specific struct. They are re-exported from the options module for convenient access.
Code Reference
Source Location
- Repository: RustQuant
- File: crates/RustQuant_instruments/src/options/option_flags.rs
- Lines: 1-125
Signature
#[derive(Debug, Clone, Copy)]
pub enum TypeFlag {
Call = 1,
Put = -1,
}
#[derive(Debug, Clone)]
pub enum ExerciseFlag {
European { expiry: Date },
American { start: Date, end: Date },
Bermudan { exercise_dates: Vec<Date> },
}
impl ExerciseFlag {
pub fn expiry(&self) -> Date;
}
#[derive(Debug, Clone, Copy)]
pub enum StrikeFlag { Fixed, Floating }
#[derive(Debug, Clone, Copy)]
pub enum SettlementFlag { Cash, Physical }
#[derive(Debug, Clone, Copy)]
pub enum AveragingMethod {
ArithmeticDiscrete,
ArithmeticContinuous,
GeometricDiscrete,
GeometricContinuous,
}
#[derive(Clone, Copy, Debug)]
pub enum BarrierType { UpAndOut, DownAndOut, UpAndIn, DownAndIn }
#[derive(Debug, Clone, Copy)]
pub enum BinaryType { AssetOrNothing, CashOrNothing }
Import
use RustQuant::instruments::options::option_flags::*;
// or import individually:
use RustQuant::instruments::options::option_flags::{TypeFlag, ExerciseFlag, StrikeFlag};
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| (enum variants) | -- | -- | These are enumeration types, not structs with inputs. Each variant is selected at construction time. |
Outputs
| Name | Type | Description |
|---|---|---|
| ExerciseFlag::expiry() | Date | Returns the terminal/expiry date for any exercise style variant |
Usage Examples
use RustQuant::instruments::options::option_flags::*;
use time::Date;
// TypeFlag as a sign multiplier
let call = TypeFlag::Call; // value: 1
let put = TypeFlag::Put; // value: -1
// ExerciseFlag with expiry extraction
let euro = ExerciseFlag::European { expiry: expiry_date };
let expiry = euro.expiry(); // returns expiry_date
let american = ExerciseFlag::American { start: start_date, end: end_date };
let expiry = american.expiry(); // returns end_date
// Barrier types
let barrier = BarrierType::UpAndOut;
// Averaging methods for Asian options
let avg = AveragingMethod::ArithmeticDiscrete;