Exotic Options

class torchquantlib.core.asset_pricing.option.exotics.CurranAsianOption(option_type: str, average_type: str = 'arithmetic')[source]

Bases: ExoticOption

Price an Asian option using Curran’s approximation

forward(spot: Tensor, strike: Tensor, expiry: Tensor, volatility: Tensor, rate: Tensor, num_steps: int) Tensor[source]

Calculate the price using Curran’s approximation

class torchquantlib.core.asset_pricing.option.exotics.ExoticOption[source]

Bases: Module, ValidationMixin

Base class for exotic options

forward(*args, **kwargs) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class torchquantlib.core.asset_pricing.option.exotics.ValidationMixin[source]

Bases: object

Mixin class for validating parameters

static validate_option_type(option_type: str)[source]

Validate option type

static validate_parameters(volatility: Tensor, expiry: Tensor, num_paths: int | None = None)[source]

Validate option parameters

torchquantlib.core.asset_pricing.option.exotics.asian_option(option_type: str, spot: Tensor, strike: Tensor, expiry: Tensor, volatility: Tensor, rate: Tensor, num_paths: int, num_steps: int, average_type: str = 'arithmetic') Tensor[source]

Price an Asian option using Monte Carlo simulation

torchquantlib.core.asset_pricing.option.exotics.barrier_option(option_type: str, barrier_type: str, spot: Tensor, strike: Tensor, barrier: Tensor, expiry: Tensor, volatility: Tensor, rate: Tensor, num_paths: int, num_steps: int) Tensor[source]

Price a barrier option using Monte Carlo simulation

torchquantlib.core.asset_pricing.option.exotics.basket_option(spots: List[Tensor], weights: List[Tensor], strike: Tensor, expiry: Tensor, volatilities: List[Tensor], correlations: Tensor, rate: Tensor, option_type: str, num_paths: int) Tensor[source]

Price a basket option using Monte Carlo simulation

torchquantlib.core.asset_pricing.option.exotics.chooser_option(spot: Tensor, strike: Tensor, expiry: Tensor, volatility: Tensor, rate: Tensor, choose_time: Tensor) Tensor[source]

Price a chooser option using Black-Scholes formula

torchquantlib.core.asset_pricing.option.exotics.digital_option(option_type: str, spot: Tensor, strike: Tensor, expiry: Tensor, volatility: Tensor, rate: Tensor, payout: Tensor, num_paths: int) Tensor[source]

Price a digital option using Monte Carlo simulation

torchquantlib.core.asset_pricing.option.exotics.lookback_option(option_type: str, spot: Tensor, strike: Tensor, expiry: Tensor, volatility: Tensor, rate: Tensor, num_paths: int, strike_type: str = 'fixed') Tensor[source]

Price a lookback option using Monte Carlo simulation

torchquantlib.core.asset_pricing.option.exotics.quanto_option(spot: Tensor, strike: Tensor, expiry: Tensor, volatility: Tensor, fx_volatility: Tensor, correlation: Tensor, domestic_rate: Tensor, foreign_rate: Tensor, fx_rate: Tensor, num_paths: int) Tensor[source]

Price a quanto option using Monte Carlo simulation

torchquantlib.core.asset_pricing.option.exotics.rainbow_option(spots: List[Tensor], weights: List[Tensor], strike: Tensor, expiry: Tensor, volatilities: List[Tensor], correlations: Tensor, rate: Tensor, num_paths: int) Tensor[source]

Price a rainbow option using Monte Carlo simulation

This module provides implementations for various exotic options pricing models.

Barrier Option

torchquantlib.core.asset_pricing.option.exotics.barrier_option(option_type: str, barrier_type: str, spot: Tensor, strike: Tensor, barrier: Tensor, expiry: Tensor, volatility: Tensor, rate: Tensor, num_paths: int, num_steps: int) Tensor[source]

Price a barrier option using Monte Carlo simulation

Usage Example

import torch
from torchquantlib.core.asset_pricing.option.exotics import barrier_option

# Example inputs
option_type = 'call'
barrier_type = 'up-and-out'
spot = torch.tensor(100.0)
strike = torch.tensor(110.0)
barrier = torch.tensor(120.0)
expiry = torch.tensor(1.0)
volatility = torch.tensor(0.2)
rate = torch.tensor(0.05)
steps = 100

# Calculate barrier option price
price = barrier_option(option_type, barrier_type, spot, strike, barrier, expiry, volatility, rate, steps)
print(f"Barrier option price: {price.item():.4f}")

Chooser Option

torchquantlib.core.asset_pricing.option.exotics.chooser_option(spot: Tensor, strike: Tensor, expiry: Tensor, volatility: Tensor, rate: Tensor, choose_time: Tensor) Tensor[source]

Price a chooser option using Black-Scholes formula

Usage Example

import torch
from torchquantlib.core.asset_pricing.option.exotics import chooser_option

# Example inputs
spot = torch.tensor(100.0)
strike = torch.tensor(100.0)
expiry = torch.tensor(1.0)
volatility = torch.tensor(0.2)
rate = torch.tensor(0.05)
dividend = torch.tensor(0.02)

# Calculate chooser option price
price = chooser_option(spot, strike, expiry, volatility, rate, dividend)
print(f"Chooser option price: {price.item():.4f}")

Compound Option

Usage Example

import torch
from torchquantlib.core.asset_pricing.option.exotics import compound_option

# Example inputs
spot = torch.tensor(100.0)
strike1 = torch.tensor(110.0)
strike2 = torch.tensor(10.0)
expiry1 = torch.tensor(1.0)
expiry2 = torch.tensor(0.5)
volatility = torch.tensor(0.2)
rate = torch.tensor(0.05)
dividend = torch.tensor(0.02)

# Calculate compound option price
price = compound_option(spot, strike1, strike2, expiry1, expiry2, volatility, rate, dividend)
print(f"Compound option price: {price.item():.4f}")

Shout Option

Usage Example

import torch
from torchquantlib.core.asset_pricing.option.exotics import shout_option

# Example inputs
spot = torch.tensor(100.0)
strike = torch.tensor(100.0)
expiry = torch.tensor(1.0)
volatility = torch.tensor(0.2)
rate = torch.tensor(0.05)
dividend = torch.tensor(0.02)

# Calculate shout option price
price = shout_option(spot, strike, expiry, volatility, rate, dividend)
print(f"Shout option price: {price.item():.4f}")

Lookback Option

torchquantlib.core.asset_pricing.option.exotics.lookback_option(option_type: str, spot: Tensor, strike: Tensor, expiry: Tensor, volatility: Tensor, rate: Tensor, num_paths: int, strike_type: str = 'fixed') Tensor[source]

Price a lookback option using Monte Carlo simulation

Usage Example

import torch
from torchquantlib.core.asset_pricing.option.exotics import lookback_option

# Example inputs
option_type = 'call'
spot = torch.tensor(100.0)
strike = torch.tensor(100.0)
expiry = torch.tensor(1.0)
volatility = torch.tensor(0.2)
rate = torch.tensor(0.05)
steps = 100

# Calculate lookback option price
price = lookback_option(option_type, spot, strike, expiry, volatility, rate, steps)
print(f"Lookback option price: {price.item():.4f}")