Implementation:Avhz RustQuant LookbackOption
| Knowledge Sources | |
|---|---|
| Domains | Exotic_Options, Quantitative_Finance |
| Last Updated | 2026-02-07 19:00 GMT |
Overview
Implements the LookbackOption struct and its Payoff trait for computing the payoff of lookback options that depend on the extreme values of the underlying asset's price path.
Description
The LookbackOption struct represents an exotic option whose payoff depends on the maximum or minimum price attained by the underlying over the life of the option. It wraps an OptionContract and an optional strike price.
The Payoff implementation accepts a Vec<f64> representing the price path. It extracts the terminal value, the path maximum (S_max), and the path minimum (S_min), then computes the payoff based on the StrikeFlag:
- Fixed strike: Call pays max(S_max - K, 0); Put pays max(K - S_min, 0). The strike K must be provided.
- Floating strike (or no strike flag): Call pays max(S_T - S_min, 0); Put pays max(S_max - S_T, 0). The "strike" floats to the path extreme.
When no StrikeFlag is set, the behavior defaults to floating strike.
Usage
Use this struct when computing payoffs for lookback options in Monte Carlo simulations or other path-dependent pricing engines.
Code Reference
Source Location
- Repository: RustQuant
- File: crates/RustQuant_instruments/src/options/lookback.rs
- Lines: 1-54
Signature
#[derive(Debug, Clone)]
pub struct LookbackOption {
pub contract: OptionContract,
pub strike: Option<f64>,
}
impl Payoff for LookbackOption {
type Underlying = Vec<f64>;
fn payoff(&self, underlying: Self::Underlying) -> f64;
}
Import
use RustQuant::instruments::options::lookback::LookbackOption;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| contract | OptionContract | Yes | The base option contract (type_flag, strike_flag) |
| strike | Option<f64> | No | Strike price; required for fixed-strike lookback options |
| underlying (payoff) | Vec<f64> | Yes | Price path of the underlying asset |
Outputs
| Name | Type | Description |
|---|---|---|
| payoff() | f64 | Lookback payoff: fixed-strike uses S_max/S_min vs K; floating-strike uses S_T vs S_min/S_max |
Usage Examples
use RustQuant::instruments::options::lookback::LookbackOption;
use RustQuant::instruments::options::{OptionContract, TypeFlag, ExerciseFlag, StrikeFlag};
use RustQuant::instruments::Payoff;
let contract = OptionContract {
type_flag: TypeFlag::Call,
exercise_flag: ExerciseFlag::European { expiry: expiry_date },
strike_flag: Some(StrikeFlag::Floating),
settlement_flag: None,
};
let lookback = LookbackOption {
contract,
strike: None,
};
let path = vec![100.0, 95.0, 102.0, 98.0, 110.0];
let payoff = lookback.payoff(path);
// Floating call: max(S_T - S_min, 0) = max(110 - 95, 0) = 15.0