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 LogOption

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


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

Overview

Implements three log-based contract types -- LogMoneynessContract, LogUnderlyingContract, and LogOption -- each with a Payoff trait implementation based on logarithmic transformations of the underlying price.

Description

This module defines three distinct log-based derivative contracts:

  • LogMoneynessContract: Pays ln(S/K) where S is the underlying price and K is the strike. This represents the log moneyness of the position and can be negative.
  • LogUnderlyingContract: Pays ln(S) regardless of the strike. The strike field is present for structural consistency but does not affect the payoff.
  • LogOption: Pays max(ln(S/K), 0), combining the log moneyness with an option floor at zero. This is essentially a call option on the log moneyness.

All three structs hold an OptionContract and a strike price. Their Payoff implementations accept a single f64 (the terminal underlying price) and return the computed payoff.

Usage

Use these contracts when working with variance swaps, log contracts, or other volatility-related derivatives where logarithmic payoffs are needed.

Code Reference

Source Location

Signature

#[derive(Debug, Clone)]
pub struct LogMoneynessContract {
    pub contract: OptionContract,
    pub strike: f64,
}

#[derive(Debug, Clone)]
pub struct LogUnderlyingContract {
    pub contract: OptionContract,
    pub strike: f64,
}

#[derive(Debug, Clone)]
pub struct LogOption {
    pub contract: OptionContract,
    pub strike: f64,
}

impl Payoff for LogMoneynessContract {
    type Underlying = f64;
    fn payoff(&self, underlying: Self::Underlying) -> f64; // ln(S/K)
}

impl Payoff for LogUnderlyingContract {
    type Underlying = f64;
    fn payoff(&self, underlying: Self::Underlying) -> f64; // ln(S)
}

impl Payoff for LogOption {
    type Underlying = f64;
    fn payoff(&self, underlying: Self::Underlying) -> f64; // max(ln(S/K), 0)
}

Import

use RustQuant::instruments::options::log::{LogMoneynessContract, LogUnderlyingContract, LogOption};

I/O Contract

Inputs

Name Type Required Description
contract OptionContract Yes The base option contract
strike f64 Yes The strike price (used in LogMoneynessContract and LogOption payoffs)
underlying (payoff) f64 Yes Terminal price of the underlying asset

Outputs

Name Type Description
payoff() (LogMoneynessContract) f64 ln(S/K) -- can be negative
payoff() (LogUnderlyingContract) f64 ln(S) -- log of the underlying price
payoff() (LogOption) f64 max(ln(S/K), 0) -- floored at zero

Usage Examples

use RustQuant::instruments::options::log::{LogMoneynessContract, LogOption};
use RustQuant::instruments::options::OptionContract;
use RustQuant::instruments::Payoff;

let contract = OptionContract { /* ... */ };

let log_moneyness = LogMoneynessContract {
    contract: contract.clone(),
    strike: 100.0,
};
let payoff = log_moneyness.payoff(110.0);
// ln(110/100) = ln(1.1) ~ 0.0953

let log_option = LogOption {
    contract,
    strike: 100.0,
};
let payoff_opt = log_option.payoff(90.0);
// max(ln(90/100), 0) = max(ln(0.9), 0) = 0.0 (floored)

Related Pages

Page Connections

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