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 Lookback Backend

From Leeroopedia
Revision as of 14:32, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Avhz_RustQuant_Lookback_Backend.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


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

Overview

Concrete tool for pricing lookback options via both closed-form analytics and Monte Carlo simulation provided by the RustQuant library.

Description

This module implements pricing for lookback options with either floating or fixed strike types. Floating-strike lookback calls have payoff max(S_T - S_min, 0) while puts have max(S_max - S_T, 0). Fixed-strike lookback calls use max(S_max - K, 0) and puts use max(K - S_min, 0). The LookbackOption struct provides two pricing methods: price_analytic() implements the closed-form solution using Gaussian CDF/PDF computations with cost-of-carry adjustments, and price_simulated() runs a Monte Carlo simulation via Geometric Brownian Motion (Euler-Maruyama discretization) to estimate option prices. Both methods return a tuple of (call_price, put_price).

Usage

Use when pricing lookback options -- either analytically for quick closed-form results, or via Monte Carlo simulation for validation and scenarios where the analytic form may not suffice.

Code Reference

Source Location

Signature

#[derive(Debug, Clone, Copy)]
pub enum LookbackStrike {
    Floating,
    Fixed,
}

#[derive(Debug, Clone, Copy)]
pub struct LookbackOption {
    pub initial_price: f64,
    pub risk_free_rate: f64,
    pub strike_price: Option<f64>,
    pub volatility: f64,
    pub time_to_maturity: f64,
    pub dividend_yield: f64,
    pub s_min: f64,
    pub s_max: f64,
    pub strike_type: LookbackStrike,
}

impl LookbackOption {
    #[must_use]
    pub fn price_analytic(&self) -> (f64, f64)

    #[must_use]
    pub fn price_simulated(&self, n_steps: usize, n_sims: usize, parallel: bool) -> (f64, f64)
}

Import

use RustQuant::instruments::{LookbackOption, LookbackStrike};

I/O Contract

Inputs

Name Type Required Description
initial_price f64 Yes Initial price of the underlying (S)
risk_free_rate f64 Yes Risk-free interest rate (r)
strike_price Option<f64> No Strike price for fixed-strike lookbacks; None for floating
volatility f64 Yes Volatility parameter (v)
time_to_maturity f64 Yes Time to expiry in years (T)
dividend_yield f64 Yes Continuous dividend yield (q)
s_min f64 Yes Minimum observed underlying price so far
s_max f64 Yes Maximum observed underlying price so far
strike_type LookbackStrike Yes Floating or Fixed strike type
n_steps usize For MC Number of simulation time steps
n_sims usize For MC Number of Monte Carlo simulation paths
parallel bool For MC Whether to run simulation in parallel

Outputs

Name Type Description
(call, put) (f64, f64) Tuple of call and put option prices

Usage Examples

use RustQuant::instruments::{LookbackOption, LookbackStrike};

let lookback = LookbackOption {
    initial_price: 50.0,
    s_max: 50.0,
    s_min: 50.0,
    time_to_maturity: 0.25,
    risk_free_rate: 0.1,
    dividend_yield: 0.0,
    volatility: 0.4,
    strike_price: None,
    strike_type: LookbackStrike::Floating,
};

// Closed-form prices
let (call_cf, put_cf) = lookback.price_analytic();

// Monte Carlo prices
let (call_mc, put_mc) = lookback.price_simulated(500, 10000, true);

Related Pages

Page Connections

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