Dupire Local Volatility Model

class torchquantlib.models.local_volatility.dupire_local_volatility.DupireLocalVol(local_vol_func)[source]

Bases: StochasticModel

Dupire local volatility model.

This model extends the Black-Scholes model by allowing the volatility to be a function of both the underlying asset price and time. It is based on Dupire’s formula, which relates the local volatility to the implied volatility surface.

The model is described by the following stochastic differential equation: dS = μSdt + σ(S,t)SdW

where: S is the asset price μ is the drift (usually the risk-free rate) σ(S,t) is the local volatility function W is a Wiener process

Limitations:
  • Uses Euler discretization, which can be inaccurate for larger time steps or higher volatility.

  • Assumes a continuous-time model.

The Dupire Local Volatility model extends the Black-Scholes model by allowing the volatility to be a function of both the underlying asset price and time. It is based on Dupire’s formula, which relates the local volatility to the implied volatility surface.

The model is described by the following stochastic differential equation:

\[dS = \mu S dt + \sigma(S,t) S dW\]

where:

  • \(S\) is the asset price

  • \(\mu\) is the drift (usually the risk-free rate)

  • \(\sigma(S,t)\) is the local volatility function

  • \(W\) is a Wiener process

Methods

__init__(local_vol_func)[source]

Initialize the Dupire Local Volatility model.

Parameters:

local_vol_func (callable) – A function that takes (S, t, device) and returns local volatility σ(S, t). S can be a tensor of asset prices, and t is a scalar time value. The function should also handle the device.

simulate(S0, T, N, rate, steps=100)[source]

Simulate asset price paths using the Dupire Local Volatility model.

Parameters:
  • S0 (float) – Initial asset price.

  • T (float) – Time horizon for simulation.

  • N (int) – Number of simulation paths.

  • rate (float) – Risk-free interest rate.

  • steps (int) – Number of time steps in each path.

Returns:

Simulated asset prices at time T.

Return type:

torch.Tensor

Attributes

local_vol_func: callable

A function that takes \((S, t)\) and returns local volatility \(\sigma(S, t)\). \(S\) can be a tensor of asset prices, and \(t\) is a scalar time value.

Example Usage

import torch
from torchquantlib.models.local_volatility.dupire_local_volatility import DupireLocalVol

# Define a simple local volatility function
def local_vol_func(S, t):
    return 0.2 + 0.1 * torch.exp(-S / 100) + 0.05 * t

# Initialize the Dupire Local Volatility model
model = DupireLocalVol(local_vol_func)

# Simulate asset price paths
S0 = 100.0  # Initial asset price
T = 1.0     # Time horizon
N = 10000   # Number of simulation paths
steps = 252 # Number of time steps (e.g., daily steps for a year)

simulated_prices = model.simulate(S0, T, N, steps)

Note

The simulate method returns the final asset prices at time T. If you need the entire price path, you can modify the method to return the full S tensor.

See also

  • torchquantlib.models.stochastic_model.StochasticModel

  • Black-Scholes Model

__init__(local_vol_func)[source]

Initialize the Dupire Local Volatility model.

Parameters:

local_vol_func (callable) – A function that takes (S, t, device) and returns local volatility σ(S, t). S can be a tensor of asset prices, and t is a scalar time value. The function should also handle the device.

simulate(S0, T, N, rate, steps=100)[source]

Simulate asset price paths using the Dupire Local Volatility model.

Parameters:
  • S0 (float) – Initial asset price.

  • T (float) – Time horizon for simulation.

  • N (int) – Number of simulation paths.

  • rate (float) – Risk-free interest rate.

  • steps (int) – Number of time steps in each path.

Returns:

Simulated asset prices at time T.

Return type:

torch.Tensor