Exotic Options
- 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, steps: int) Tensor[source]
Price a barrier option using a binomial tree model.
- Parameters:
option_type (str) – Type of option - either ‘call’ or ‘put’.
barrier_type (str) – Type of barrier - ‘up-and-out’, ‘down-and-out’, ‘up-and-in’, or ‘down-and-in’.
spot (Tensor) – Current price of the underlying asset.
strike (Tensor) – Strike price of the option.
barrier (Tensor) – Barrier price.
expiry (Tensor) – Time to expiration in years.
volatility (Tensor) – Volatility of the underlying asset.
rate (Tensor) – Risk-free interest rate (annualized).
steps (int) – Number of time steps in the binomial tree.
- Returns:
The price of the barrier option.
- Return type:
Tensor
- torchquantlib.core.asset_pricing.option.exotics.chooser_option(spot, strike, expiry, volatility, rate, dividend)[source]
Calculate the price of a chooser option.
A chooser option gives the holder the right to choose whether the option is a call or put at some point before expiration.
- Parameters:
spot (torch.Tensor) – The spot price of the underlying asset
strike (torch.Tensor) – The strike price of the option
expiry (torch.Tensor) – The time to expiry in years
volatility (torch.Tensor) – The volatility of the underlying asset
rate (torch.Tensor) – The risk-free interest rate
dividend (torch.Tensor) – The dividend yield
- Returns:
The price of the chooser option
- Return type:
torch.Tensor
- torchquantlib.core.asset_pricing.option.exotics.compound_option(spot, strike1, strike2, expiry1, expiry2, volatility, rate, dividend)[source]
Calculate the price of a compound option (an option on an option).
- Parameters:
spot (torch.Tensor) – The spot price of the underlying asset
strike1 (torch.Tensor) – The strike price of the underlying option
strike2 (torch.Tensor) – The strike price of the compound option
expiry1 (torch.Tensor) – The time to expiry of the underlying option in years
expiry2 (torch.Tensor) – The time to expiry of the compound option in years
volatility (torch.Tensor) – The volatility of the underlying asset
rate (torch.Tensor) – The risk-free interest rate
dividend (torch.Tensor) – The dividend yield
- Returns:
The price of the compound option
- Return type:
torch.Tensor
- torchquantlib.core.asset_pricing.option.exotics.lookback_option(option_type: str, spot: Tensor, strike: Tensor, expiry: Tensor, volatility: Tensor, rate: Tensor, steps: int) Tensor[source]
Price a lookback option using a binomial tree model.
A lookback option’s payoff depends on the optimal (maximum for call, minimum for put) price of the underlying asset during the option’s life.
- Parameters:
option_type (str) – Type of option - either ‘call’ or ‘put’.
spot (Tensor) – Current price of the underlying asset.
strike (Tensor) – Strike price of the option.
expiry (Tensor) – Time to expiration in years.
volatility (Tensor) – Volatility of the underlying asset.
rate (Tensor) – Risk-free interest rate (annualized).
steps (int) – Number of time steps in the binomial tree.
- Returns:
The price of the lookback option.
- Return type:
Tensor
- torchquantlib.core.asset_pricing.option.exotics.shout_option(spot, strike, expiry, volatility, rate, dividend)[source]
Calculate the price of a shout option.
A shout option allows the holder to “shout” once during the life of the option to lock in a minimum payoff.
- Parameters:
spot (torch.Tensor) – The spot price of the underlying asset
strike (torch.Tensor) – The strike price of the option
expiry (torch.Tensor) – The time to expiry in years
volatility (torch.Tensor) – The volatility of the underlying asset
rate (torch.Tensor) – The risk-free interest rate
dividend (torch.Tensor) – The dividend yield
- Returns:
The price of the shout option
- Return type:
torch.Tensor
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, steps: int) Tensor[source]
Price a barrier option using a binomial tree model.
- Parameters:
option_type (str) – Type of option - either ‘call’ or ‘put’.
barrier_type (str) – Type of barrier - ‘up-and-out’, ‘down-and-out’, ‘up-and-in’, or ‘down-and-in’.
spot (Tensor) – Current price of the underlying asset.
strike (Tensor) – Strike price of the option.
barrier (Tensor) – Barrier price.
expiry (Tensor) – Time to expiration in years.
volatility (Tensor) – Volatility of the underlying asset.
rate (Tensor) – Risk-free interest rate (annualized).
steps (int) – Number of time steps in the binomial tree.
- Returns:
The price of the barrier option.
- Return type:
Tensor
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, strike, expiry, volatility, rate, dividend)[source]
Calculate the price of a chooser option.
A chooser option gives the holder the right to choose whether the option is a call or put at some point before expiration.
- Parameters:
spot (torch.Tensor) – The spot price of the underlying asset
strike (torch.Tensor) – The strike price of the option
expiry (torch.Tensor) – The time to expiry in years
volatility (torch.Tensor) – The volatility of the underlying asset
rate (torch.Tensor) – The risk-free interest rate
dividend (torch.Tensor) – The dividend yield
- Returns:
The price of the chooser option
- Return type:
torch.Tensor
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
- torchquantlib.core.asset_pricing.option.exotics.compound_option(spot, strike1, strike2, expiry1, expiry2, volatility, rate, dividend)[source]
Calculate the price of a compound option (an option on an option).
- Parameters:
spot (torch.Tensor) – The spot price of the underlying asset
strike1 (torch.Tensor) – The strike price of the underlying option
strike2 (torch.Tensor) – The strike price of the compound option
expiry1 (torch.Tensor) – The time to expiry of the underlying option in years
expiry2 (torch.Tensor) – The time to expiry of the compound option in years
volatility (torch.Tensor) – The volatility of the underlying asset
rate (torch.Tensor) – The risk-free interest rate
dividend (torch.Tensor) – The dividend yield
- Returns:
The price of the compound option
- Return type:
torch.Tensor
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
- torchquantlib.core.asset_pricing.option.exotics.shout_option(spot, strike, expiry, volatility, rate, dividend)[source]
Calculate the price of a shout option.
A shout option allows the holder to “shout” once during the life of the option to lock in a minimum payoff.
- Parameters:
spot (torch.Tensor) – The spot price of the underlying asset
strike (torch.Tensor) – The strike price of the option
expiry (torch.Tensor) – The time to expiry in years
volatility (torch.Tensor) – The volatility of the underlying asset
rate (torch.Tensor) – The risk-free interest rate
dividend (torch.Tensor) – The dividend yield
- Returns:
The price of the shout option
- Return type:
torch.Tensor
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, steps: int) Tensor[source]
Price a lookback option using a binomial tree model.
A lookback option’s payoff depends on the optimal (maximum for call, minimum for put) price of the underlying asset during the option’s life.
- Parameters:
option_type (str) – Type of option - either ‘call’ or ‘put’.
spot (Tensor) – Current price of the underlying asset.
strike (Tensor) – Strike price of the option.
expiry (Tensor) – Time to expiration in years.
volatility (Tensor) – Volatility of the underlying asset.
rate (Tensor) – Risk-free interest rate (annualized).
steps (int) – Number of time steps in the binomial tree.
- Returns:
The price of the lookback option.
- Return type:
Tensor
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}")