Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Avhz RustQuant AsianOption

From Leeroopedia


Knowledge Sources
Domains Exotic_Options, Quantitative_Finance
Last Updated 2026-02-07 19:00 GMT

Overview

Implements the AsianOption struct and its Payoff trait for computing the payoff of Asian options based on the average price of the underlying asset over a path.

Description

The AsianOption struct represents an exotic option whose payoff depends on the average price of the underlying asset over a specified period, rather than just its terminal value. It wraps an OptionContract and adds two additional parameters: the AveragingMethod (arithmetic or geometric, discrete or continuous) and an optional strike price.

The Payoff implementation accepts a Vec<f64> representing the price path of the underlying. The averaging method determines how the average is computed:

  • ArithmeticDiscrete: Simple arithmetic mean of all path values
  • GeometricDiscrete: Geometric mean (product raised to 1/n)
  • Continuous methods are declared but not yet implemented (will panic)

The payoff then depends on the StrikeFlag:

  • Fixed strike: Call pays max(average - K, 0); Put pays max(K - average, 0)
  • Floating strike: Call pays max(S_T - average, 0); Put pays max(average - S_T, 0)

The struct also uses the derive_builder crate to provide an AsianOptionBuilder for fluent construction.

Usage

Use this struct when computing the payoff of Asian options in Monte Carlo simulations or other path-dependent pricing frameworks.

Code Reference

Source Location

Signature

#[derive(Debug, Clone, Builder)]
pub struct AsianOption {
    pub contract: OptionContract,
    pub averaging_method: AveragingMethod,
    pub strike: Option<f64>,
}

impl AsianOption {
    pub fn new(contract: OptionContract, averaging_method: AveragingMethod, strike: Option<f64>) -> Self;
}

impl Payoff for AsianOption {
    type Underlying = Vec<f64>;
    fn payoff(&self, underlying: Self::Underlying) -> f64;
}

Import

use RustQuant::instruments::options::asian::AsianOption;

I/O Contract

Inputs

Name Type Required Description
contract OptionContract Yes The base option contract (type_flag, exercise_flag, strike_flag)
averaging_method AveragingMethod Yes Method of averaging: ArithmeticDiscrete, GeometricDiscrete, etc.
strike Option<f64> No Strike price; required for fixed-strike Asian options
underlying (payoff) Vec<f64> Yes Price path of the underlying asset

Outputs

Name Type Description
payoff() f64 The option payoff computed from the averaged path and strike/terminal values

Usage Examples

use RustQuant::instruments::options::asian::AsianOption;
use RustQuant::instruments::options::{OptionContract, TypeFlag, ExerciseFlag, StrikeFlag, AveragingMethod};
use RustQuant::instruments::Payoff;

let contract = OptionContract {
    type_flag: TypeFlag::Call,
    exercise_flag: ExerciseFlag::European { expiry: expiry_date },
    strike_flag: Some(StrikeFlag::Fixed),
    settlement_flag: None,
};

let asian = AsianOption::new(contract, AveragingMethod::ArithmeticDiscrete, Some(100.0));

let path = vec![98.0, 101.0, 103.0, 99.0, 105.0];
let payoff = asian.payoff(path);
// For fixed-strike call: max(average(path) - 100.0, 0.0)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment