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 PowerOption

From Leeroopedia


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

Overview

Implements four power-based derivative contracts -- PowerOption, PoweredOption, CappedPowerOption, and PowerContract -- each with distinct payoff formulas involving exponentiation of the underlying price.

Description

This module defines four related but distinct power-based derivative types:

  • PowerContract: A basic contract that pays (S/K)^p where S is the underlying price, K is the strike, and p is the power parameter. This always pays a positive amount.
  • PowerOption: An option where the underlying is raised to a power before the standard option payoff is applied. Call pays max(S^p - K, 0); Put pays max(K - S^p, 0).
  • PoweredOption: An option where the standard vanilla payoff is raised to a power. Call pays max(S - K, 0)^p; Put pays max(K - S, 0)^p. This amplifies the payoff non-linearly.
  • CappedPowerOption: Same as PowerOption but with a cap on the maximum payoff. The payoff is min(PowerOption_payoff, cap).

All four structs implement the Payoff trait with Underlying = f64 and provide new constructors. Each holds an OptionContract (except PowerContract), a strike, and a power parameter. CappedPowerOption additionally holds a cap value.

Usage

Use these structs when pricing or simulating power-based exotic derivatives. PowerOption and PoweredOption are common in structured products. CappedPowerOption is useful when the payoff needs to be bounded.

Code Reference

Source Location

Signature

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

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

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

#[derive(Debug, Clone, Copy)]
pub struct PowerContract {
    pub strike: f64,
    pub power: f64,
}

impl PowerOption { pub fn new(contract: OptionContract, strike: f64, power: f64) -> Self; }
impl PoweredOption { pub fn new(contract: OptionContract, strike: f64, power: f64) -> Self; }
impl CappedPowerOption { pub fn new(contract: OptionContract, strike: f64, power: f64, cap: f64) -> Self; }
impl PowerContract { pub fn new(strike: f64, power: f64) -> Self; }

impl Payoff for PowerContract { type Underlying = f64; fn payoff(&self, underlying: f64) -> f64; }
impl Payoff for PowerOption { type Underlying = f64; fn payoff(&self, underlying: f64) -> f64; }
impl Payoff for PoweredOption { type Underlying = f64; fn payoff(&self, underlying: f64) -> f64; }
impl Payoff for CappedPowerOption { type Underlying = f64; fn payoff(&self, underlying: f64) -> f64; }

Import

use RustQuant::instruments::options::power::{PowerOption, PoweredOption, CappedPowerOption, PowerContract};

I/O Contract

Inputs

Name Type Required Description
contract OptionContract Yes (except PowerContract) The base option contract (type_flag for Call/Put)
strike f64 Yes The strike price
power f64 Yes The exponent applied to the underlying or payoff
cap f64 Yes (CappedPowerOption only) Maximum payoff cap
underlying (payoff) f64 Yes Terminal price of the underlying asset

Outputs

Name Type Description
payoff() (PowerContract) f64 (S/K)^p
payoff() (PowerOption) f64 Call: max(S^p - K, 0); Put: max(K - S^p, 0)
payoff() (PoweredOption) f64 Call: max(S - K, 0)^p; Put: max(K - S, 0)^p
payoff() (CappedPowerOption) f64 min(PowerOption_payoff, cap)

Usage Examples

use RustQuant::instruments::options::power::{PowerOption, PoweredOption, CappedPowerOption};
use RustQuant::instruments::options::{OptionContract, TypeFlag, ExerciseFlag};
use RustQuant::instruments::Payoff;

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

// PowerOption: max(S^2 - 100, 0)
let power_opt = PowerOption::new(contract.clone(), 100.0, 2.0);
let payoff = power_opt.payoff(12.0);
// 12^2 - 100 = 144 - 100 = 44.0

// PoweredOption: max(S - 100, 0)^2
let powered_opt = PoweredOption::new(contract.clone(), 100.0, 2.0);
let payoff = powered_opt.payoff(110.0);
// (110 - 100)^2 = 100.0

// CappedPowerOption: min(max(S^2 - 100, 0), 50)
let capped = CappedPowerOption::new(contract, 100.0, 2.0, 50.0);
let payoff = capped.payoff(12.0);
// min(44.0, 50.0) = 44.0

Related Pages

Page Connections

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