Black-Karasinski Model

class torchquantlib.models.interest_rate.black_karasinski.BlackKarasinski(a_init=0.1, sigma_init=0.01, r0_init=0.03)[source]

Bases: StochasticModel

Black-Karasinski interest rate model.

This model describes the evolution of interest rates using the following stochastic differential equation: d(ln(r)) = (θ(t) - a * ln(r)) * dt + σ * dW

where: r is the short rate θ(t) is a function chosen to fit the initial term structure a is the mean reversion speed σ is the volatility W is a Wiener process

__init__(a_init=0.1, sigma_init=0.01, r0_init=0.03)[source]

Initialize the Black-Karasinski model.

Parameters:
  • a_init (float) – Initial value for mean reversion speed.

  • sigma_init (float) – Initial value for volatility.

  • r0_init (float) – Initial value for short rate.

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

Simulate interest rate paths using the Black-Karasinski model.

Parameters:
  • S0 (float) – Initial asset price (not used in this model, included for consistency).

  • T (float) – Time horizon for simulation.

  • N (int) – Number of simulation paths.

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

Returns:

Simulated interest rates at time T.

Return type:

torch.Tensor

_apply_constraints()[source]

Apply constraints to model parameters to ensure they remain in valid ranges.

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

Simulate interest rate paths using the Black-Karasinski model.

Parameters:
  • S0 (float) – Initial asset price (not used in this model, included for consistency).

  • T (float) – Time horizon for simulation.

  • N (int) – Number of simulation paths.

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

Returns:

Simulated interest rates at time T.

Return type:

torch.Tensor

Class Methods

__init__(a_init=0.1, sigma_init=0.01, r0_init=0.03)

Initialize the Black-Karasinski model.

param float a_init:

Initial value for mean reversion speed.

param float sigma_init:

Initial value for volatility.

param float r0_init:

Initial value for short rate.

simulate(S0, T, N, steps=100)

Simulate interest rate paths using the Black-Karasinski model.

param float S0:

Initial asset price (not used in this model, included for consistency).

param float T:

Time horizon for simulation.

param int N:

Number of simulation paths.

param int steps:

Number of time steps in each path.

return:

Simulated interest rates at time T.

rtype:

torch.Tensor

_apply_constraints()

Apply constraints to model parameters to ensure they remain in valid ranges.