Methods Module¶
Monte Carlo simulation and finite-difference grid infrastructure.
Paths¶
Path¶
- class pyquantlib.Path¶
Bases:
pybind11_objectSingle-factor random walk.
- __init__(timeGrid: TimeGrid, values: Array = Array([])) None¶
Constructs a path on the given time grid.
- time(i: SupportsInt | SupportsIndex) float¶
Returns time at index i.
- value(i: SupportsInt | SupportsIndex) float¶
Returns value at index i.
Single-factor price path storing values at discrete time points.
grid = ql.TimeGrid(1.0, 4) # 4 steps over 1 year
path = ql.Path(grid)
# Access values
path[0] # first value
path[-1] # last value
path.front() # same as path[0]
path.back() # same as path[-1]
len(path) # number of path values
path.timeGrid() # underlying TimeGrid
MultiPath¶
- class pyquantlib.MultiPath¶
Bases:
pybind11_objectCorrelated multiple asset paths.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(nAsset: SupportsInt | SupportsIndex, timeGrid: TimeGrid) -> None
Constructs paths for nAsset assets on the given time grid.
__init__(paths: collections.abc.Sequence[Path]) -> None
Constructs from a vector of single-asset paths.
Correlated multi-asset paths, each sharing the same time grid.
grid = ql.TimeGrid(1.0, 4)
mp = ql.MultiPath(2, grid) # 2 assets
mp[0] # Path for first asset
mp[1] # Path for second asset
mp.assetNumber() # 2
mp.pathSize() # number of time points
len(mp) # same as assetNumber()
Sample Types¶
- class pyquantlib.SamplePath¶
Bases:
pybind11_objectWeighted path sample (value + weight).
- __init__(*args, **kwargs)¶
- property value¶
Sample path.
- property weight¶
Sample weight.
- class pyquantlib.SampleMultiPath¶
Bases:
pybind11_objectWeighted multi-path sample (value + weight).
- __init__(*args, **kwargs)¶
- property value¶
Sample multi-path.
- property weight¶
Sample weight.
Weighted path samples returned by path generators. Each has value (the path) and weight (the sample weight).
Brownian Bridge¶
BrownianBridge¶
- class pyquantlib.BrownianBridge¶
Bases:
pybind11_objectBuilds Wiener process paths using Gaussian variates.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(steps: SupportsInt | SupportsIndex) -> None
Constructs a bridge with the given number of unit-time steps.
__init__(timeGrid: TimeGrid) -> None
Constructs a bridge from a time grid.
__init__(times: collections.abc.Sequence[SupportsFloat | SupportsIndex]) -> None
Constructs a bridge from step times.
- transform(input: collections.abc.Sequence[SupportsFloat | SupportsIndex]) list[float]¶
Transforms random variates into Brownian bridge path variations.
Builds Wiener process paths using Gaussian variates via bridge construction (variance reduction).
# From number of steps
bb = ql.BrownianBridge(10)
# From time grid
grid = ql.TimeGrid(1.0, 10)
bb = ql.BrownianBridge(timeGrid=grid)
# Transform random variates into bridge path
import random
variates = [random.gauss(0, 1) for _ in range(bb.size())]
output = bb.transform(variates)
# Inspect bridge construction
bb.bridgeIndex() # construction order
bb.leftWeight() # interpolation weights
bb.stdDeviation() # step standard deviations
Path Generators¶
GaussianPathGenerator¶
- class pyquantlib.GaussianPathGenerator¶
Bases:
pybind11_objectSingle-factor path generator using pseudo-random Gaussian variates.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(process: base.StochasticProcess, length: SupportsFloat | SupportsIndex, timeSteps: SupportsInt | SupportsIndex, generator: GaussianRandomSequenceGenerator, brownianBridge: bool) -> None
Constructs from process, time length, steps, and generator.
__init__(process: base.StochasticProcess, timeGrid: TimeGrid, generator: GaussianRandomSequenceGenerator, brownianBridge: bool) -> None
Constructs from process, time grid, and generator.
- antithetic() SamplePath¶
Generates the antithetic path sample.
- next() SamplePath¶
Generates the next path sample.
Single-factor path generator using pseudo-random Gaussian variates (Mersenne Twister).
process = ql.BlackScholesMertonProcess(spot, div, rf, vol)
rsg = ql.GaussianRandomSequenceGenerator(
ql.UniformRandomSequenceGenerator(10, ql.MersenneTwisterUniformRng(42))
)
gen = ql.GaussianPathGenerator(process, 1.0, 10, rsg, False)
sample = gen.next() # SamplePath
path = sample.value # Path object
weight = sample.weight # sample weight
anti = gen.antithetic() # antithetic sample
GaussianSobolPathGenerator¶
- class pyquantlib.GaussianSobolPathGenerator¶
Bases:
pybind11_objectSingle-factor path generator using Sobol low-discrepancy variates.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(process: base.StochasticProcess, length: SupportsFloat | SupportsIndex, timeSteps: SupportsInt | SupportsIndex, generator: GaussianLowDiscrepancySequenceGenerator, brownianBridge: bool) -> None
Constructs from process, time length, steps, and generator.
__init__(process: base.StochasticProcess, timeGrid: TimeGrid, generator: GaussianLowDiscrepancySequenceGenerator, brownianBridge: bool) -> None
Constructs from process, time grid, and generator.
- antithetic() SamplePath¶
Generates the antithetic path sample.
- next() SamplePath¶
Generates the next path sample.
Single-factor path generator using Sobol low-discrepancy variates.
sobol_rsg = ql.GaussianLowDiscrepancySequenceGenerator(
ql.SobolRsg(10)
)
gen = ql.GaussianSobolPathGenerator(process, 1.0, 10, sobol_rsg, True)
GaussianMultiPathGenerator¶
- class pyquantlib.GaussianMultiPathGenerator¶
Bases:
pybind11_objectMulti-factor path generator using pseudo-random Gaussian variates.
- __init__(process: base.StochasticProcess, timeGrid: TimeGrid, generator: GaussianRandomSequenceGenerator, brownianBridge: bool = False) None¶
Constructs from process, time grid, and generator.
- antithetic() SampleMultiPath¶
Generates the antithetic multi-path sample.
- next() SampleMultiPath¶
Generates the next multi-path sample.
Multi-factor path generator using pseudo-random Gaussian variates.
heston = ql.HestonProcess(rf, div, spot, 0.04, 1.0, 0.04, 0.5, -0.7)
grid = ql.TimeGrid(1.0, 50)
rsg = ql.GaussianRandomSequenceGenerator(
ql.UniformRandomSequenceGenerator(
heston.factors() * 50, ql.MersenneTwisterUniformRng(42)
)
)
gen = ql.GaussianMultiPathGenerator(heston, grid, rsg)
sample = gen.next() # SampleMultiPath
mp = sample.value # MultiPath
spot_path = mp[0] # Path for spot
var_path = mp[1] # Path for variance
GaussianSobolMultiPathGenerator¶
- class pyquantlib.GaussianSobolMultiPathGenerator¶
Bases:
pybind11_objectMulti-factor path generator using Sobol low-discrepancy variates.
- __init__(process: base.StochasticProcess, timeGrid: TimeGrid, generator: GaussianLowDiscrepancySequenceGenerator, brownianBridge: bool = False) None¶
Constructs from process, time grid, and generator.
- antithetic() SampleMultiPath¶
Generates the antithetic multi-path sample.
- next() SampleMultiPath¶
Generates the next multi-path sample.
Multi-factor path generator using Sobol low-discrepancy variates.
Brownian Generators¶
Low-level generators for producing correlated Brownian increments. Used internally by MC engines and SLV models.
MTBrownianGenerator¶
- class pyquantlib.MTBrownianGenerator¶
Bases:
BrownianGeneratorMersenne-Twister Brownian generator.
- __init__(factors: SupportsInt | SupportsIndex, steps: SupportsInt | SupportsIndex, seed: SupportsInt | SupportsIndex = 0) None¶
Constructs from dimensions and optional seed.
Mersenne-Twister-based Brownian generator.
gen = ql.MTBrownianGenerator(factors=2, steps=10, seed=42)
weight, variates = gen.nextStep() # single time step
path = gen.nextPath() # full path weight
MTBrownianGeneratorFactory¶
- class pyquantlib.MTBrownianGeneratorFactory¶
Bases:
BrownianGeneratorFactoryFactory for Mersenne-Twister Brownian generators.
- __init__(seed: SupportsInt | SupportsIndex = 0) None¶
Constructs with optional seed.
SobolBrownianGenerator¶
- class pyquantlib.SobolBrownianGenerator¶
Bases:
BrownianGeneratorSobol Brownian generator with Brownian bridging.
- __init__(factors: SupportsInt | SupportsIndex, steps: SupportsInt | SupportsIndex, ordering: Ordering, seed: SupportsInt | SupportsIndex = 0, directionIntegers: SobolRsg.DirectionIntegers = <DirectionIntegers.Jaeckel: 1>) None¶
Constructs a Sobol Brownian generator.
Sobol-based Brownian generator with configurable ordering.
gen = ql.SobolBrownianGenerator(
factors=2, steps=10,
ordering=ql.Ordering.Steps,
)
SobolBrownianGeneratorFactory¶
- class pyquantlib.SobolBrownianGeneratorFactory¶
Bases:
BrownianGeneratorFactoryFactory for Sobol Brownian generators.
- __init__(ordering: Ordering, seed: SupportsInt | SupportsIndex = 0, directionIntegers: SobolRsg.DirectionIntegers = <DirectionIntegers.Jaeckel: 1>) None¶
Constructs a Sobol Brownian generator factory.
Burley2020SobolBrownianGenerator¶
- class pyquantlib.Burley2020SobolBrownianGenerator¶
Bases:
BrownianGeneratorScrambled Sobol Brownian generator with Brownian bridging.
- __init__(factors: SupportsInt | SupportsIndex, steps: SupportsInt | SupportsIndex, ordering: Ordering, seed: SupportsInt | SupportsIndex = 42, directionIntegers: SobolRsg.DirectionIntegers = <DirectionIntegers.Jaeckel: 1>, scrambleSeed: SupportsInt | SupportsIndex = 43) None¶
Constructs a scrambled Sobol Brownian generator.
Scrambled Sobol Brownian generator (Burley 2020 hash-based Owen scrambling).
Burley2020SobolBrownianGeneratorFactory¶
- class pyquantlib.Burley2020SobolBrownianGeneratorFactory¶
Bases:
BrownianGeneratorFactoryFactory for scrambled Sobol Brownian generators.
- __init__(ordering: Ordering, seed: SupportsInt | SupportsIndex = 42, directionIntegers: SobolRsg.DirectionIntegers = <DirectionIntegers.Jaeckel: 1>, scrambleSeed: SupportsInt | SupportsIndex = 43) None¶
Constructs a scrambled Sobol Brownian generator factory.
FDM Enums¶
FdmSchemeDesc¶
- class pyquantlib.FdmSchemeDesc¶
Bases:
pybind11_objectFinite difference scheme descriptor.
- static CraigSneyd() FdmSchemeDesc¶
Craig-Sneyd scheme.
- static CrankNicolson() FdmSchemeDesc¶
Crank-Nicolson scheme.
- static Douglas() FdmSchemeDesc¶
Douglas scheme (same as Crank-Nicolson in 1D).
- static ExplicitEuler() FdmSchemeDesc¶
Explicit Euler scheme.
- static Hundsdorfer() FdmSchemeDesc¶
Hundsdorfer scheme.
- static ImplicitEuler() FdmSchemeDesc¶
Implicit Euler scheme.
- static MethodOfLines(eps: SupportsFloat | SupportsIndex = 0.001, relInitStepSize: SupportsFloat | SupportsIndex = 0.01) FdmSchemeDesc¶
Method of lines scheme.
- static ModifiedCraigSneyd() FdmSchemeDesc¶
Modified Craig-Sneyd scheme.
- static ModifiedHundsdorfer() FdmSchemeDesc¶
Modified Hundsdorfer scheme.
- static TrBDF2() FdmSchemeDesc¶
TR-BDF2 scheme.
- __init__(type: FdmSchemeType, theta: SupportsFloat | SupportsIndex, mu: SupportsFloat | SupportsIndex) None¶
Constructs with scheme type, theta, and mu.
- property mu¶
- property theta¶
- property type¶
Finite difference scheme descriptors used by FD engines and the Heston SLV FDM calibration.
FdmHestonGreensFctAlgorithm¶
- class pyquantlib.FdmHestonGreensFctAlgorithm¶
Bases:
pybind11_objectAlgorithm for Heston Fokker-Planck Green’s function.
Members:
ZeroCorrelation
Gaussian
SemiAnalytical
- __init__(value: SupportsInt | SupportsIndex) None¶
- Gaussian = <FdmHestonGreensFctAlgorithm.Gaussian: 1>¶
- SemiAnalytical = <FdmHestonGreensFctAlgorithm.SemiAnalytical: 2>¶
- ZeroCorrelation = <FdmHestonGreensFctAlgorithm.ZeroCorrelation: 0>¶
- FdmHestonGreensFctAlgorithm.name -> str
- property value¶
Algorithm for computing Heston Fokker-Planck Green’s functions: ZeroCorrelation, Gaussian, SemiAnalytical.
FdmSquareRootFwdOpTransformationType¶
- class pyquantlib.FdmSquareRootFwdOpTransformationType¶
Bases:
pybind11_objectCoordinate transformation for square-root process FD scheme.
Members:
Plain
Power
Log
- __init__(value: SupportsInt | SupportsIndex) None¶
- Log = <FdmSquareRootFwdOpTransformationType.Log: 2>¶
- Plain = <FdmSquareRootFwdOpTransformationType.Plain: 0>¶
- Power = <FdmSquareRootFwdOpTransformationType.Power: 1>¶
- FdmSquareRootFwdOpTransformationType.name -> str
- property value¶
Coordinate transformation for the square-root forward operator: Plain, Power, Log.
FDM Grid Infrastructure¶
Layout, iterators, and meshers for multi-dimensional finite-difference grids.
FdmLinearOpIterator¶
- class pyquantlib.FdmLinearOpIterator¶
Bases:
pybind11_objectIterator for a FDM linear operator layout.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(index: SupportsInt | SupportsIndex = 0) -> None
Constructs with a flat index.
__init__(dim: collections.abc.Sequence[SupportsInt | SupportsIndex]) -> None
Constructs from grid dimensions.
__init__(dim: collections.abc.Sequence[SupportsInt | SupportsIndex], coordinates: collections.abc.Sequence[SupportsInt | SupportsIndex], index: SupportsInt | SupportsIndex) -> None
Constructs from dimensions, coordinates, and flat index.
- notEqual(other: FdmLinearOpIterator) bool¶
Returns true if iterators differ.
Iterator over grid points in an FDM layout. Tracks flat index and multi-dimensional coordinates.
layout = ql.FdmLinearOpLayout([5, 3])
it = layout.begin()
it.index() # 0
it.coordinates() # [0, 0]
it.increment()
it.index() # 1
it.coordinates() # [1, 0]
FdmLinearOpLayout¶
- class pyquantlib.FdmLinearOpLayout¶
Bases:
pybind11_objectMemory layout of a FDM linear operator grid.
- __init__(dim: collections.abc.Sequence[SupportsInt | SupportsIndex]) None¶
Constructs from grid dimensions.
- begin() FdmLinearOpIterator¶
Returns an iterator to the first element.
- end() FdmLinearOpIterator¶
Returns an iterator past the last element.
- index(coordinates: collections.abc.Sequence[SupportsInt | SupportsIndex]) int¶
Returns the flat index for given coordinates.
- iter_neighbourhood(iterator: FdmLinearOpIterator, i: SupportsInt | SupportsIndex, offset: SupportsInt | SupportsIndex) FdmLinearOpIterator¶
Returns a neighbour iterator in dimension i.
- neighbourhood(*args, **kwargs)¶
Overloaded function.
neighbourhood(iterator: FdmLinearOpIterator, i: SupportsInt | SupportsIndex, offset: SupportsInt | SupportsIndex) -> int
Returns neighbour flat index in dimension i.
neighbourhood(iterator: FdmLinearOpIterator, i1: SupportsInt | SupportsIndex, offset1: SupportsInt | SupportsIndex, i2: SupportsInt | SupportsIndex, offset2: SupportsInt | SupportsIndex) -> int
Returns neighbour flat index in dimensions i1 and i2.
Memory layout for multi-dimensional FDM grids. Supports Python iteration.
layout = ql.FdmLinearOpLayout([5, 3])
len(layout) # 15
layout.dim() # [5, 3]
layout.spacing() # stride vector
for it in layout:
print(it.index(), it.coordinates())
Fdm1dMesher¶
- class pyquantlib.Fdm1dMesher¶
Bases:
pybind11_objectBase class for one-dimensional FDM meshers.
- __init__(size: SupportsInt | SupportsIndex) None¶
Constructs a 1D mesher of the given size.
- dminus(index: SupportsInt | SupportsIndex) float¶
Returns the backward difference at index.
- dplus(index: SupportsInt | SupportsIndex) float¶
Returns the forward difference at index.
- location(index: SupportsInt | SupportsIndex) float¶
Returns the location at index.
Base class for one-dimensional FDM meshers. All 1D meshers below inherit from this.
mesher = ql.Uniform1dMesher(0.0, 1.0, 5)
mesher.locations() # grid point locations
mesher.dplus(0) # forward difference at index 0
mesher.dminus(1) # backward difference at index 1
Uniform1dMesher¶
- class pyquantlib.Uniform1dMesher¶
Bases:
Fdm1dMesherOne-dimensional uniform grid mesher.
- __init__(start: SupportsFloat | SupportsIndex, end: SupportsFloat | SupportsIndex, size: SupportsInt | SupportsIndex) None¶
Constructs a uniform grid from start to end.
Uniform grid between start and end values.
Concentrating1dMesher¶
- class pyquantlib.Concentrating1dMesher¶
Bases:
Fdm1dMesherOne-dimensional mesher concentrating around critical points.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(start: SupportsFloat | SupportsIndex, end: SupportsFloat | SupportsIndex, size: SupportsInt | SupportsIndex, cPoint: object = None, requireCPoint: bool = False) -> None
Constructs with optional concentration point (location, density).
__init__(start: SupportsFloat | SupportsIndex, end: SupportsFloat | SupportsIndex, size: SupportsInt | SupportsIndex, cPoints: collections.abc.Sequence[tuple[SupportsFloat | SupportsIndex, SupportsFloat | SupportsIndex, bool]], tol: SupportsFloat | SupportsIndex = 1e-08) -> None
Constructs with multiple concentration points.
Grid concentrating points around one or more critical points.
# Single concentration point at 100.0 with density 0.1
mesher = ql.Concentrating1dMesher(50.0, 150.0, 100, cPoint=(100.0, 0.1))
# Multiple concentration points
mesher = ql.Concentrating1dMesher(
50.0, 150.0, 100,
cPoints=[(100.0, 0.1, False), (120.0, 0.05, False)]
)
Predefined1dMesher¶
- class pyquantlib.Predefined1dMesher¶
Bases:
Fdm1dMesherOne-dimensional mesher from predefined grid points.
- __init__(x: collections.abc.Sequence[SupportsFloat | SupportsIndex]) None¶
Constructs from explicit grid locations.
Mesher from user-supplied grid points.
FdmBlackScholesMesher¶
- class pyquantlib.FdmBlackScholesMesher¶
Bases:
Fdm1dMesherOne-dimensional mesher for the Black-Scholes process (in ln(S)).
- static processHelper(s0: QuoteHandle, rTS: YieldTermStructureHandle, qTS: YieldTermStructureHandle, vol: SupportsFloat | SupportsIndex) GeneralizedBlackScholesProcess¶
Creates a GeneralizedBlackScholesProcess from basic inputs.
- __init__(size: SupportsInt | SupportsIndex, process: GeneralizedBlackScholesProcess, maturity: SupportsFloat | SupportsIndex, strike: SupportsFloat | SupportsIndex, xMinConstraint: object = None, xMaxConstraint: object = None, eps: SupportsFloat | SupportsIndex = 0.0001, scaleFactor: SupportsFloat | SupportsIndex = 1.5, cPoint: object = None, dividendSchedule: collections.abc.Sequence[base.Dividend] = [], fdmQuantoHelper: FdmQuantoHelper = None, spotAdjustment: SupportsFloat | SupportsIndex = 0.0) None¶
Constructs a Black-Scholes mesher.
One-dimensional mesher for the Black-Scholes process (in ln(S)).
process = ql.BlackScholesMertonProcess(spot, div, rf, vol)
mesher = ql.FdmBlackScholesMesher(100, process, 1.0, 100.0)
FdmHestonVarianceMesher¶
- class pyquantlib.FdmHestonVarianceMesher¶
Bases:
Fdm1dMesherOne-dimensional variance mesher for the Heston model.
- __init__(size: SupportsInt | SupportsIndex, process: HestonProcess, maturity: SupportsFloat | SupportsIndex, tAvgSteps: SupportsInt | SupportsIndex = 10, epsilon: SupportsFloat | SupportsIndex = 0.0001, mixingFactor: SupportsFloat | SupportsIndex = 1.0) None¶
Constructs a Heston variance mesher.
Variance dimension mesher for Heston models with volatility estimate.
heston = ql.HestonProcess(rf, div, spot, 0.04, 1.0, 0.04, 0.5, -0.7)
mesher = ql.FdmHestonVarianceMesher(10, heston, 1.0)
mesher.volaEstimate() # estimated volatility
FdmHestonLocalVolatilityVarianceMesher¶
- class pyquantlib.FdmHestonLocalVolatilityVarianceMesher¶
Bases:
Fdm1dMesherVariance mesher for the Heston model with local volatility.
- __init__(size: SupportsInt | SupportsIndex, process: HestonProcess, leverageFct: base.LocalVolTermStructure, maturity: SupportsFloat | SupportsIndex, tAvgSteps: SupportsInt | SupportsIndex = 10, epsilon: SupportsFloat | SupportsIndex = 0.0001, mixingFactor: SupportsFloat | SupportsIndex = 1.0) None¶
Constructs a Heston local vol variance mesher.
Heston variance mesher incorporating local volatility leverage.
FdmCEV1dMesher¶
- class pyquantlib.FdmCEV1dMesher¶
Bases:
Fdm1dMesherOne-dimensional mesher for the CEV model.
- __init__(size: SupportsInt | SupportsIndex, f0: SupportsFloat | SupportsIndex, alpha: SupportsFloat | SupportsIndex, beta: SupportsFloat | SupportsIndex, maturity: SupportsFloat | SupportsIndex, eps: SupportsFloat | SupportsIndex = 0.0001, scaleFactor: SupportsFloat | SupportsIndex = 1.5, cPoint: object = None) None¶
Constructs a CEV mesher.
One-dimensional mesher for the CEV model.
FdmSimpleProcess1dMesher¶
- class pyquantlib.FdmSimpleProcess1dMesher¶
Bases:
Fdm1dMesherOne-dimensional mesher for a generic stochastic process.
- __init__(size: SupportsInt | SupportsIndex, process: base.StochasticProcess1D, maturity: SupportsFloat | SupportsIndex, tAvgSteps: SupportsInt | SupportsIndex = 10, epsilon: SupportsFloat | SupportsIndex = 0.0001, mandatoryPoint: object = None) None¶
Constructs from a 1D stochastic process.
Generic one-dimensional mesher for any 1D stochastic process.
FdmMesherComposite¶
- class pyquantlib.FdmMesherComposite¶
Bases:
FdmMesherComposite multi-dimensional mesher built from 1D meshers.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(meshers: collections.abc.Sequence[Fdm1dMesher]) -> None
Constructs from a vector of 1D meshers.
__init__(layout: FdmLinearOpLayout, meshers: collections.abc.Sequence[Fdm1dMesher]) -> None
Constructs from a layout and vector of 1D meshers.
__init__(mesher: Fdm1dMesher) -> None
Constructs a 1D composite mesher.
__init__(m1: Fdm1dMesher, m2: Fdm1dMesher) -> None
Constructs a 2D composite mesher.
__init__(m1: Fdm1dMesher, m2: Fdm1dMesher, m3: Fdm1dMesher) -> None
Constructs a 3D composite mesher.
__init__(m1: Fdm1dMesher, m2: Fdm1dMesher, m3: Fdm1dMesher, m4: Fdm1dMesher) -> None
Constructs a 4D composite mesher.
- getFdm1dMeshers() list[Fdm1dMesher]¶
Returns the underlying 1D meshers.
Composite multi-dimensional mesher built from 1D meshers.
# 2D grid from two 1D meshers
m1 = ql.FdmBlackScholesMesher(100, process, 1.0, 100.0)
m2 = ql.FdmHestonVarianceMesher(10, heston, 1.0)
mesher = ql.FdmMesherComposite(m1, m2)
mesher.layout() # FdmLinearOpLayout
mesher.getFdm1dMeshers() # underlying 1D meshers
FdmQuantoHelper¶
- class pyquantlib.FdmQuantoHelper¶
Bases:
ObservableHelper storing market data for FDM quanto adjustment.
- __init__(rTS: base.YieldTermStructure, fTS: base.YieldTermStructure, fxVolTS: base.BlackVolTermStructure, equityFxCorrelation: SupportsFloat | SupportsIndex, exchRateATMlevel: SupportsFloat | SupportsIndex) None¶
Constructs from rate curves, FX vol, correlation, and FX rate.
- quantoAdjustment(*args, **kwargs)¶
Overloaded function.
quantoAdjustment(equityVol: SupportsFloat | SupportsIndex, t1: SupportsFloat | SupportsIndex, t2: SupportsFloat | SupportsIndex) -> float
Returns the quanto adjustment for scalar equity volatility.
quantoAdjustment(equityVol: Array, t1: SupportsFloat | SupportsIndex, t2: SupportsFloat | SupportsIndex) -> Array
Returns the quanto adjustment for an Array of equity volatilities.
- property equityFxCorrelation¶
- property exchRateATMlevel¶
- property fTS¶
- property fxVolTS¶
- property rTS¶
Helper for applying quanto adjustments in FDM pricing.
FDM Boundary Conditions¶
BoundaryConditionSide¶
- class pyquantlib.BoundaryConditionSide¶
Bases:
pybind11_objectBoundary condition side.
Members:
- __init__(value: SupportsInt | SupportsIndex) None¶
- Lower = <BoundaryConditionSide.Lower: 2>¶
- None_ = <BoundaryConditionSide.None_: 0>¶
- Upper = <BoundaryConditionSide.Upper: 1>¶
- BoundaryConditionSide.name -> str
- property value¶
Side of the domain for boundary conditions: None_, Upper, Lower.
FdmBoundaryCondition¶
- class pyquantlib.FdmBoundaryCondition¶
Bases:
pybind11_objectBoundary condition for FDM operators.
- __init__(*args, **kwargs)¶
- setTime(t: SupportsFloat | SupportsIndex) None¶
Sets the current time for time-dependent conditions.
Abstract boundary condition for FDM operators. Used in boundary condition sets passed to schemes.
FDM Operators¶
Building Block Operators¶
TripleBandLinearOp¶
- class pyquantlib.TripleBandLinearOp¶
Bases:
FdmLinearOpTriple-band (tridiagonal) linear operator.
- __init__(direction: SupportsInt | SupportsIndex, mesher: FdmMesher) None¶
Constructs from direction and mesher.
- add(*args, **kwargs)¶
Overloaded function.
add(m: TripleBandLinearOp) -> TripleBandLinearOp
Adds another triple-band operator.
add(u: Array) -> TripleBandLinearOp
Adds a diagonal array.
- axpyb(a: Array, x: TripleBandLinearOp, y: TripleBandLinearOp, b: Array) None¶
Computes a*x + y + b (in-place).
- mult(u: Array) TripleBandLinearOp¶
Left-multiplies by a diagonal matrix.
- multR(u: Array) TripleBandLinearOp¶
Right-multiplies by a diagonal matrix.
- solve_splitting(r: Array, a: SupportsFloat | SupportsIndex, b: SupportsFloat | SupportsIndex = 1.0) Array¶
Solves the splitting step.
Tridiagonal (triple-band) linear operator on one grid dimension.
mesher = ql.FdmMesherComposite(ql.Uniform1dMesher(0.0, 1.0, 10))
op = ql.TripleBandLinearOp(0, mesher)
result = op.apply(array)
result = op.solve_splitting(rhs, a, b)
op2 = op.mult(array)
op3 = op.add(other_op)
FirstDerivativeOp¶
- class pyquantlib.FirstDerivativeOp¶
Bases:
TripleBandLinearOpFirst derivative operator on an FDM grid.
- __init__(direction: SupportsInt | SupportsIndex, mesher: FdmMesher) None¶
Constructs from direction and mesher.
Central first-derivative operator (inherits from TripleBandLinearOp).
d_dx = ql.FirstDerivativeOp(0, mesher)
gradient = d_dx.apply(values)
SecondDerivativeOp¶
- class pyquantlib.SecondDerivativeOp¶
Bases:
TripleBandLinearOpSecond derivative operator on an FDM grid.
- __init__(direction: SupportsInt | SupportsIndex, mesher: FdmMesher) None¶
Constructs from direction and mesher.
Central second-derivative operator (inherits from TripleBandLinearOp).
d2_dx2 = ql.SecondDerivativeOp(0, mesher)
laplacian = d2_dx2.apply(values)
NinePointLinearOp¶
- class pyquantlib.NinePointLinearOp¶
Bases:
FdmLinearOpNine-point linear operator for 2D FDM grids.
- __init__(d0: SupportsInt | SupportsIndex, d1: SupportsInt | SupportsIndex, mesher: FdmMesher) None¶
Constructs from two directions and a mesher.
- mult(u: Array) NinePointLinearOp¶
Left-multiplies by a diagonal matrix.
Nine-point cross-derivative operator on two grid dimensions.
SecondOrderMixedDerivativeOp¶
- class pyquantlib.SecondOrderMixedDerivativeOp¶
Bases:
NinePointLinearOpSecond-order mixed derivative operator for 2D FDM grids.
- __init__(d0: SupportsInt | SupportsIndex, d1: SupportsInt | SupportsIndex, mesher: FdmMesher) None¶
Constructs from two directions and a mesher.
Second-order mixed partial derivative operator (inherits from NinePointLinearOp).
d2_dxdy = ql.SecondOrderMixedDerivativeOp(0, 1, mesher)
Process Operators¶
Process-specific PDE operators, all inheriting from FdmLinearOpComposite. These encode the drift, diffusion, and cross terms for a given stochastic process. Constructed from a mesher and the corresponding process; the inherited methods (size, setTime, apply, apply_mixed, apply_direction, solve_splitting, preconditioner) are called internally by FDM schemes.
FdmBlackScholesOp¶
- class pyquantlib.FdmBlackScholesOp¶
Bases:
FdmLinearOpCompositeBlack-Scholes FDM operator.
- __init__(mesher: FdmMesher, process: GeneralizedBlackScholesProcess, strike: SupportsFloat | SupportsIndex, localVol: bool = False, illegalLocalVolOverwrite: object = None, direction: SupportsInt | SupportsIndex = 0, quantoHelper: FdmQuantoHelper = None) None¶
Constructs a Black-Scholes operator.
Black-Scholes PDE operator.
op = ql.FdmBlackScholesOp(mesher, process, strike=100.0)
FdmBlackScholesFwdOp¶
- class pyquantlib.FdmBlackScholesFwdOp¶
Bases:
FdmLinearOpCompositeBlack-Scholes Fokker-Planck forward operator.
- __init__(mesher: FdmMesher, process: GeneralizedBlackScholesProcess, strike: SupportsFloat | SupportsIndex, localVol: bool = False, illegalLocalVolOverwrite: object = None, direction: SupportsInt | SupportsIndex = 0) None¶
Constructs a Black-Scholes forward operator.
Black-Scholes forward (Fokker-Planck) operator.
Fdm2dBlackScholesOp¶
- class pyquantlib.Fdm2dBlackScholesOp¶
Bases:
FdmLinearOpCompositeTwo-dimensional Black-Scholes FDM operator.
- __init__(mesher: FdmMesher, p1: GeneralizedBlackScholesProcess, p2: GeneralizedBlackScholesProcess, correlation: SupportsFloat | SupportsIndex, maturity: SupportsFloat | SupportsIndex, localVol: bool = False, illegalLocalVolOverwrite: object = None) None¶
Constructs a 2D Black-Scholes operator.
Two-dimensional correlated Black-Scholes operator.
FdmHestonOp¶
- class pyquantlib.FdmHestonOp¶
Bases:
FdmLinearOpCompositeHeston stochastic volatility FDM operator.
- __init__(mesher: FdmMesher, hestonProcess: HestonProcess, quantoHelper: FdmQuantoHelper = None, leverageFct: base.LocalVolTermStructure = None, mixingFactor: SupportsFloat | SupportsIndex = 1.0) None¶
Constructs a Heston operator.
Heston stochastic volatility PDE operator.
op = ql.FdmHestonOp(mesher, heston_process)
FdmHestonFwdOp¶
- class pyquantlib.FdmHestonFwdOp¶
Bases:
FdmLinearOpCompositeHeston Fokker-Planck forward operator.
- __init__(mesher: FdmMesher, process: HestonProcess, type: FdmSquareRootFwdOpTransformationType = <FdmSquareRootFwdOpTransformationType.Plain: 0>, leverageFct: base.LocalVolTermStructure = None, mixingFactor: SupportsFloat | SupportsIndex = 1.0) None¶
Constructs a Heston forward operator.
Heston forward (Fokker-Planck) operator.
FdmHestonHullWhiteOp¶
- class pyquantlib.FdmHestonHullWhiteOp¶
Bases:
FdmLinearOpCompositeHeston-Hull-White FDM operator.
- __init__(mesher: FdmMesher, hestonProcess: HestonProcess, hwProcess: HullWhiteProcess, equityShortRateCorrelation: SupportsFloat | SupportsIndex) None¶
Constructs a Heston-Hull-White operator.
Three-factor Heston plus Hull-White operator.
FdmBatesOp¶
- class pyquantlib.FdmBatesOp¶
Bases:
FdmLinearOpCompositeBates (Heston + jumps) FDM operator.
- __init__(mesher: FdmMesher, batesProcess: BatesProcess, bcSet: collections.abc.Sequence[FdmBoundaryCondition], integroIntegrationOrder: SupportsInt | SupportsIndex, quantoHelper: FdmQuantoHelper = None) None¶
Constructs a Bates operator.
Bates (Heston + jumps) PDE operator.
FdmHullWhiteOp¶
- class pyquantlib.FdmHullWhiteOp¶
Bases:
FdmLinearOpCompositeHull-White interest rate FDM operator.
- __init__(mesher: FdmMesher, model: QuantLib::HullWhite, direction: SupportsInt | SupportsIndex) None¶
Constructs a Hull-White operator.
Hull-White short-rate PDE operator.
FdmG2Op¶
- class pyquantlib.FdmG2Op¶
Bases:
FdmLinearOpCompositeG2++ two-factor interest rate FDM operator.
- __init__(mesher: FdmMesher, model: QuantLib::G2, direction1: SupportsInt | SupportsIndex, direction2: SupportsInt | SupportsIndex) None¶
Constructs a G2 operator.
Two-factor Gaussian short-rate (G2) PDE operator.
FdmCEVOp¶
- class pyquantlib.FdmCEVOp¶
Bases:
FdmLinearOpCompositeConstant Elasticity of Variance FDM operator.
- __init__(mesher: FdmMesher, rTS: base.YieldTermStructure, f0: SupportsFloat | SupportsIndex, alpha: SupportsFloat | SupportsIndex, beta: SupportsFloat | SupportsIndex, direction: SupportsInt | SupportsIndex) None¶
Constructs a CEV operator.
Constant Elasticity of Variance PDE operator.
FdmSabrOp¶
- class pyquantlib.FdmSabrOp¶
Bases:
FdmLinearOpCompositeSABR stochastic volatility FDM operator.
- __init__(mesher: FdmMesher, rTS: base.YieldTermStructure, f0: SupportsFloat | SupportsIndex, alpha: SupportsFloat | SupportsIndex, beta: SupportsFloat | SupportsIndex, nu: SupportsFloat | SupportsIndex, rho: SupportsFloat | SupportsIndex) None¶
Constructs a SABR operator.
SABR stochastic volatility PDE operator.
FdmLocalVolFwdOp¶
- class pyquantlib.FdmLocalVolFwdOp¶
Bases:
FdmLinearOpCompositeLocal volatility Fokker-Planck forward operator.
- __init__(mesher: FdmMesher, spot: base.Quote, rTS: base.YieldTermStructure, qTS: base.YieldTermStructure, localVol: base.LocalVolTermStructure, direction: SupportsInt | SupportsIndex = 0) None¶
Constructs a local volatility forward operator.
Local volatility forward (Fokker-Planck) operator.
FdmSquareRootFwdOp¶
- class pyquantlib.FdmSquareRootFwdOp¶
Bases:
FdmLinearOpCompositeSquare-root process Fokker-Planck forward operator.
- __init__(mesher: FdmMesher, kappa: SupportsFloat | SupportsIndex, theta: SupportsFloat | SupportsIndex, sigma: SupportsFloat | SupportsIndex, direction: SupportsInt | SupportsIndex, type: FdmSquareRootFwdOpTransformationType = <FdmSquareRootFwdOpTransformationType.Plain: 0>) None¶
Constructs a square-root forward operator.
- lowerBoundaryFactor(type: FdmSquareRootFwdOpTransformationType = <FdmSquareRootFwdOpTransformationType.Plain: 0>) float¶
Returns the lower boundary factor.
- upperBoundaryFactor(type: FdmSquareRootFwdOpTransformationType = <FdmSquareRootFwdOpTransformationType.Plain: 0>) float¶
Returns the upper boundary factor.
- v(i: SupportsInt | SupportsIndex) float¶
Returns the transformed value at index i.
Square-root (CIR) forward operator, used in Heston SLV calibration.
FdmOrnsteinUhlenbeckOp¶
- class pyquantlib.FdmOrnsteinUhlenbeckOp¶
Bases:
FdmLinearOpCompositeOrnstein-Uhlenbeck process FDM operator.
- __init__(mesher: FdmMesher, process: OrnsteinUhlenbeckProcess, rTS: base.YieldTermStructure, direction: SupportsInt | SupportsIndex = 0) None¶
Constructs an Ornstein-Uhlenbeck operator.
Ornstein-Uhlenbeck mean-reverting PDE operator.
FDM Schemes¶
Time-stepping schemes for evolving the PDE solution backward (or forward) in time. All schemes share the same interface:
scheme.setStep(dt) # set time step size
array = scheme.step(array, t) # advance one step from time t
The step method returns the modified array (Python copy semantics).
ExplicitEulerScheme¶
- class pyquantlib.ExplicitEulerScheme¶
Bases:
pybind11_objectExplicit Euler time-stepping scheme.
- __init__(map: FdmLinearOpComposite, bcSet: collections.abc.Sequence[FdmBoundaryCondition] = []) None¶
Constructs from operator and boundary conditions.
- setStep(dt: SupportsFloat | SupportsIndex) None¶
Sets the time step size.
- step(a: Array, t: SupportsFloat | SupportsIndex) Array¶
Applies one time step and returns the modified array.
Forward Euler (explicit) time stepping.
ImplicitEulerScheme¶
- class pyquantlib.ImplicitEulerScheme¶
Bases:
pybind11_objectImplicit Euler time-stepping scheme.
- __init__(map: FdmLinearOpComposite, bcSet: collections.abc.Sequence[FdmBoundaryCondition] = [], relTol: SupportsFloat | SupportsIndex = 1e-08, solverType: ImplicitEulerSolverType = <ImplicitEulerSolverType.BiCGstab: 0>) None¶
Constructs from operator, boundary conditions, and solver settings.
- setStep(dt: SupportsFloat | SupportsIndex) None¶
Sets the time step size.
- step(a: Array, t: SupportsFloat | SupportsIndex) Array¶
Applies one time step and returns the modified array.
Backward Euler (implicit) time stepping with iterative solver.
scheme = ql.ImplicitEulerScheme(op, relTol=1e-8)
scheme.numberOfIterations() # solver iterations from last step
ImplicitEulerSolverType¶
- class pyquantlib.ImplicitEulerSolverType¶
Bases:
pybind11_objectIterative solver type for implicit schemes.
Members:
BiCGstab
GMRES
- __init__(value: SupportsInt | SupportsIndex) None¶
- BiCGstab = <ImplicitEulerSolverType.BiCGstab: 0>¶
- GMRES = <ImplicitEulerSolverType.GMRES: 1>¶
- ImplicitEulerSolverType.name -> str
- property value¶
Iterative solver for implicit schemes: BiCGstab, GMRES.
CrankNicolsonScheme¶
- class pyquantlib.CrankNicolsonScheme¶
Bases:
pybind11_objectCrank-Nicolson time-stepping scheme.
- __init__(theta: SupportsFloat | SupportsIndex, map: FdmLinearOpComposite, bcSet: collections.abc.Sequence[FdmBoundaryCondition] = [], relTol: SupportsFloat | SupportsIndex = 1e-08, solverType: ImplicitEulerSolverType = <ImplicitEulerSolverType.BiCGstab: 0>) None¶
Constructs from theta, operator, and solver settings.
- setStep(dt: SupportsFloat | SupportsIndex) None¶
Sets the time step size.
- step(a: Array, t: SupportsFloat | SupportsIndex) Array¶
Applies one time step and returns the modified array.
Crank-Nicolson (theta = 0.5) time stepping.
scheme = ql.CrankNicolsonScheme(0.5, op)
scheme.numberOfIterations()
DouglasScheme¶
- class pyquantlib.DouglasScheme¶
Bases:
pybind11_objectDouglas ADI time-stepping scheme.
- __init__(theta: SupportsFloat | SupportsIndex, map: FdmLinearOpComposite, bcSet: collections.abc.Sequence[FdmBoundaryCondition] = []) None¶
Constructs from theta, operator, and boundary conditions.
- setStep(dt: SupportsFloat | SupportsIndex) None¶
Sets the time step size.
- step(a: Array, t: SupportsFloat | SupportsIndex) Array¶
Applies one time step and returns the modified array.
Douglas ADI time-stepping scheme.
CraigSneydScheme¶
- class pyquantlib.CraigSneydScheme¶
Bases:
pybind11_objectCraig-Sneyd ADI time-stepping scheme.
- __init__(theta: SupportsFloat | SupportsIndex, mu: SupportsFloat | SupportsIndex, map: FdmLinearOpComposite, bcSet: collections.abc.Sequence[FdmBoundaryCondition] = []) None¶
Constructs from theta, mu, operator, and boundary conditions.
- setStep(dt: SupportsFloat | SupportsIndex) None¶
Sets the time step size.
- step(a: Array, t: SupportsFloat | SupportsIndex) Array¶
Applies one time step and returns the modified array.
Craig-Sneyd ADI time-stepping scheme.
HundsdorferScheme¶
- class pyquantlib.HundsdorferScheme¶
Bases:
pybind11_objectHundsdorfer ADI time-stepping scheme.
- __init__(theta: SupportsFloat | SupportsIndex, mu: SupportsFloat | SupportsIndex, map: FdmLinearOpComposite, bcSet: collections.abc.Sequence[FdmBoundaryCondition] = []) None¶
Constructs from theta, mu, operator, and boundary conditions.
- setStep(dt: SupportsFloat | SupportsIndex) None¶
Sets the time step size.
- step(a: Array, t: SupportsFloat | SupportsIndex) Array¶
Applies one time step and returns the modified array.
Hundsdorfer ADI time-stepping scheme.
ModifiedCraigSneydScheme¶
- class pyquantlib.ModifiedCraigSneydScheme¶
Bases:
pybind11_objectModified Craig-Sneyd ADI time-stepping scheme.
- __init__(theta: SupportsFloat | SupportsIndex, mu: SupportsFloat | SupportsIndex, map: FdmLinearOpComposite, bcSet: collections.abc.Sequence[FdmBoundaryCondition] = []) None¶
Constructs from theta, mu, operator, and boundary conditions.
- setStep(dt: SupportsFloat | SupportsIndex) None¶
Sets the time step size.
- step(a: Array, t: SupportsFloat | SupportsIndex) Array¶
Applies one time step and returns the modified array.
Modified Craig-Sneyd ADI time-stepping scheme.
MethodOfLinesScheme¶
- class pyquantlib.MethodOfLinesScheme¶
Bases:
pybind11_objectMethod of lines time-stepping scheme (Runge-Kutta).
- __init__(eps: SupportsFloat | SupportsIndex, relInitStepSize: SupportsFloat | SupportsIndex, map: FdmLinearOpComposite, bcSet: collections.abc.Sequence[FdmBoundaryCondition] = []) None¶
Constructs from tolerance, initial step size, operator, and BCs.
- setStep(dt: SupportsFloat | SupportsIndex) None¶
Sets the time step size.
- step(a: Array, t: SupportsFloat | SupportsIndex) Array¶
Applies one time step and returns the modified array.
Method of lines (Runge-Kutta) time-stepping scheme.
FDM Inner Value Calculators¶
Inner value calculators evaluate the payoff at grid points, used by step conditions and solvers.
FdmCellAveragingInnerValue¶
- class pyquantlib.FdmCellAveragingInnerValue¶
Bases:
FdmInnerValueCalculatorCell-averaging inner value calculator for FDM grids.
- __init__(payoff: base.Payoff, mesher: FdmMesher, direction: SupportsInt | SupportsIndex, gridMapping: object = None) None¶
Constructs with payoff, mesher, direction, and optional grid mapping.
Cell-averaging inner value calculator. Evaluates payoff with optional grid mapping.
payoff = ql.PlainVanillaPayoff(ql.OptionType.Call, 100.0)
calculator = ql.FdmCellAveragingInnerValue(payoff, mesher, 0)
# With custom grid mapping (e.g., exp for log-space)
import math
calculator = ql.FdmCellAveragingInnerValue(payoff, mesher, 0, gridMapping=math.exp)
FdmLogInnerValue¶
- class pyquantlib.FdmLogInnerValue¶
Bases:
FdmCellAveragingInnerValueLog-space inner value calculator for equity options.
- __init__(payoff: base.Payoff, mesher: FdmMesher, direction: SupportsInt | SupportsIndex) None¶
Constructs with payoff, mesher, and direction.
Log-space inner value calculator for equity options. Applies exp() mapping automatically.
calculator = ql.FdmLogInnerValue(payoff, mesher, 0)
FdmLogBasketInnerValue¶
- class pyquantlib.FdmLogBasketInnerValue¶
Bases:
FdmInnerValueCalculatorLog-space inner value calculator for basket options.
Log-space inner value calculator for basket options.
FdmZeroInnerValue¶
- class pyquantlib.FdmZeroInnerValue¶
Bases:
FdmInnerValueCalculatorZero inner value calculator (always returns 0).
Always returns zero. Used when no exercise value is needed.
FDM Step Conditions¶
Step conditions apply constraints or modifications at each time step during the backward PDE solve.
FdmSnapshotCondition¶
- class pyquantlib.FdmSnapshotCondition¶
Bases:
FdmStepConditionCaptures array values at a specific time (for theta calculation).
- __init__(t: SupportsFloat | SupportsIndex) None¶
Constructs with snapshot time.
Captures the solution array at a specified time.
snapshot = ql.FdmSnapshotCondition(0.5) # capture at t=0.5
snapshot.getTime() # 0.5
snapshot.getValues() # Array (available after solve)
FdmAmericanStepCondition¶
- class pyquantlib.FdmAmericanStepCondition¶
Bases:
FdmStepConditionAmerican-style early exercise step condition.
Applies early exercise at every time step (American-style).
condition = ql.FdmAmericanStepCondition(mesher, calculator)
FdmBermudanStepCondition¶
- class pyquantlib.FdmBermudanStepCondition¶
Bases:
FdmStepConditionBermudan-style early exercise step condition.
- __init__(exerciseDates: collections.abc.Sequence[Date], referenceDate: Date, dayCounter: DayCounter, mesher: FdmMesher, calculator: base.FdmInnerValueCalculator) None¶
Constructs with exercise dates, reference date, day counter, mesher, and calculator.
Applies early exercise at discrete dates (Bermudan-style).
condition = ql.FdmBermudanStepCondition(
exerciseDates, referenceDate, dayCounter, mesher, calculator
)
condition.exerciseTimes() # list of exercise times
FdmDividendHandler¶
- class pyquantlib.FdmDividendHandler¶
Bases:
FdmStepConditionApplies discrete dividends as a step condition.
- __init__(schedule: collections.abc.Sequence[base.Dividend], mesher: FdmMesher, referenceDate: Date, dayCounter: DayCounter, equityDirection: SupportsInt | SupportsIndex) None¶
Constructs with dividend schedule, mesher, reference date, day counter, and equity direction.
Adjusts grid values for discrete dividends during backward solve.
handler = ql.FdmDividendHandler(dividends, mesher, refDate, dc, equityDirection=0)
handler.dividendTimes() # list of dividend times
handler.dividendDates() # list of dividend dates
handler.dividends() # list of Dividend objects
FdmStepConditionComposite¶
- class pyquantlib.FdmStepConditionComposite¶
Bases:
FdmStepConditionComposite of FDM step conditions.
- static joinConditions(snapshotCondition: FdmSnapshotCondition, composite: FdmStepConditionComposite) FdmStepConditionComposite¶
Joins a snapshot condition with an existing composite.
- static vanillaComposite(dividendSchedule: collections.abc.Sequence[base.Dividend], exercise: Exercise, mesher: FdmMesher, calculator: base.FdmInnerValueCalculator, referenceDate: Date, dayCounter: DayCounter) FdmStepConditionComposite¶
Creates a standard composite for vanilla option FDM pricing.
- __init__(stoppingTimes: collections.abc.Sequence[collections.abc.Sequence[SupportsFloat | SupportsIndex]], conditions: collections.abc.Sequence[base.FdmStepCondition]) None¶
Constructs from stopping times and conditions.
Combines multiple step conditions into one. Provides factory methods for common setups.
# Vanilla option composite (handles dividends + exercise)
composite = ql.FdmStepConditionComposite.vanillaComposite(
dividends, exercise, mesher, calculator, refDate, dc
)
composite.stoppingTimes() # combined stopping times
composite.conditions() # list of step conditions
# Join snapshot with composite
joined = ql.FdmStepConditionComposite.joinConditions(snapshot, composite)
FDM Solvers¶
FdmSolverDesc¶
- class pyquantlib.FdmSolverDesc¶
Bases:
pybind11_objectDescriptor for FDM solver configuration.
- __init__(mesher: FdmMesher, bcSet: collections.abc.Sequence[FdmBoundaryCondition], condition: FdmStepConditionComposite, calculator: base.FdmInnerValueCalculator, maturity: SupportsFloat | SupportsIndex, timeSteps: SupportsInt | SupportsIndex, dampingSteps: SupportsInt | SupportsIndex = 0) None¶
Constructs solver descriptor.
- property bcSet¶
- property calculator¶
- property condition¶
- property dampingSteps¶
- property maturity¶
- property mesher¶
- property timeSteps¶
Descriptor aggregating all inputs for an FDM solver.
desc = ql.FdmSolverDesc(
mesher=mesher,
bcSet=[], # boundary conditions
condition=composite, # step condition composite
calculator=calculator, # inner value calculator
maturity=1.0,
timeSteps=100,
dampingSteps=0
)
FdmBackwardSolver¶
- class pyquantlib.FdmBackwardSolver¶
Bases:
pybind11_objectCore FDM backward solver performing PDE rollback.
- __init__(map: QuantLib::FdmLinearOpComposite, bcSet: collections.abc.Sequence[QuantLib::BoundaryCondition<QuantLib::FdmLinearOp>] = [], condition: object = None, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7f2534371630>) None¶
Constructs with operator, boundary conditions, step conditions, and scheme.
- rollback(a: Array, from_: SupportsFloat | SupportsIndex, to: SupportsFloat | SupportsIndex, steps: SupportsInt | SupportsIndex, dampingSteps: SupportsInt | SupportsIndex) Array¶
Rolls back array from time ‘from’ to time ‘to’ (returns modified copy).
Core backward PDE solver performing time rollback with a specified scheme.
solver = ql.FdmBackwardSolver(op, bcSet=[], schemeDesc=ql.FdmSchemeDesc.Douglas())
result = solver.rollback(array, from_=1.0, to=0.0, steps=100, dampingSteps=0)
Fdm1DimSolver¶
- class pyquantlib.Fdm1DimSolver¶
Bases:
LazyObject1D FDM solver with cubic interpolation.
- __init__(solverDesc: FdmSolverDesc, schemeDesc: FdmSchemeDesc, op: FdmLinearOpComposite) None¶
Constructs with solver descriptor, scheme descriptor, and operator.
- derivativeX(x: SupportsFloat | SupportsIndex) float¶
Returns first derivative at coordinate x.
- derivativeXX(x: SupportsFloat | SupportsIndex) float¶
Returns second derivative at coordinate x.
- interpolateAt(x: SupportsFloat | SupportsIndex) float¶
Interpolates solution at coordinate x.
- thetaAt(x: SupportsFloat | SupportsIndex) float¶
Returns theta at coordinate x.
One-dimensional FDM solver with interpolation.
solver = ql.Fdm1DimSolver(desc, ql.FdmSchemeDesc.Douglas(), op)
solver.interpolateAt(x) # solution value at x
solver.thetaAt(x) # theta at x
solver.derivativeX(x) # first derivative
solver.derivativeXX(x) # second derivative
Fdm2DimSolver¶
- class pyquantlib.Fdm2DimSolver¶
Bases:
LazyObject2D FDM solver with bicubic spline interpolation.
- __init__(solverDesc: FdmSolverDesc, schemeDesc: FdmSchemeDesc, op: FdmLinearOpComposite) None¶
Constructs with solver descriptor, scheme descriptor, and operator.
- derivativeX(x: SupportsFloat | SupportsIndex, y: SupportsFloat | SupportsIndex) float¶
Returns first derivative w.r.t. x.
- derivativeXX(x: SupportsFloat | SupportsIndex, y: SupportsFloat | SupportsIndex) float¶
Returns second derivative w.r.t. x.
- derivativeXY(x: SupportsFloat | SupportsIndex, y: SupportsFloat | SupportsIndex) float¶
Returns cross derivative w.r.t. x and y.
- derivativeY(x: SupportsFloat | SupportsIndex, y: SupportsFloat | SupportsIndex) float¶
Returns first derivative w.r.t. y.
- derivativeYY(x: SupportsFloat | SupportsIndex, y: SupportsFloat | SupportsIndex) float¶
Returns second derivative w.r.t. y.
- interpolateAt(x: SupportsFloat | SupportsIndex, y: SupportsFloat | SupportsIndex) float¶
Interpolates solution at coordinates (x, y).
- thetaAt(x: SupportsFloat | SupportsIndex, y: SupportsFloat | SupportsIndex) float¶
Returns theta at coordinates (x, y).
Two-dimensional FDM solver with bilinear interpolation.
solver = ql.Fdm2DimSolver(desc, ql.FdmSchemeDesc.Hundsdorfer(), op)
solver.interpolateAt(x, y)
solver.thetaAt(x, y)
solver.derivativeX(x, y)
solver.derivativeY(x, y)
solver.derivativeXX(x, y)
solver.derivativeYY(x, y)
solver.derivativeXY(x, y)
Fdm3DimSolver¶
- class pyquantlib.Fdm3DimSolver¶
Bases:
LazyObject3D FDM solver with bicubic spline interpolation.
- __init__(solverDesc: FdmSolverDesc, schemeDesc: FdmSchemeDesc, op: FdmLinearOpComposite) None¶
Constructs with solver descriptor, scheme descriptor, and operator.
- interpolateAt(x: SupportsFloat | SupportsIndex, y: SupportsFloat | SupportsIndex, z: SupportsFloat | SupportsIndex) float¶
Interpolates solution at coordinates (x, y, z).
- thetaAt(x: SupportsFloat | SupportsIndex, y: SupportsFloat | SupportsIndex, z: SupportsFloat | SupportsIndex) float¶
Returns theta at coordinates (x, y, z).
Three-dimensional FDM solver.
solver = ql.Fdm3DimSolver(desc, ql.FdmSchemeDesc.Douglas(), op)
solver.interpolateAt(x, y, z)
solver.thetaAt(x, y, z)
FdmBlackScholesSolver¶
- class pyquantlib.FdmBlackScholesSolver¶
Bases:
LazyObjectSpecialized 1D FDM solver for Black-Scholes processes.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(process: GeneralizedBlackScholesProcessHandle, strike: SupportsFloat | SupportsIndex, solverDesc: FdmSolverDesc, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7f25341b29b0>, localVol: bool = False, illegalLocalVolOverwrite: object = None, quantoHelper: object = None) -> None
Constructs from process handle.
__init__(process: GeneralizedBlackScholesProcess, strike: SupportsFloat | SupportsIndex, solverDesc: FdmSolverDesc, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7f252f3eedb0>, localVol: bool = False, illegalLocalVolOverwrite: object = None, quantoHelper: object = None) -> None
Constructs from process (handle created internally).
- deltaAt(s: SupportsFloat | SupportsIndex) float¶
Returns delta at spot price s.
- gammaAt(s: SupportsFloat | SupportsIndex) float¶
Returns gamma at spot price s.
- thetaAt(s: SupportsFloat | SupportsIndex) float¶
Returns theta at spot price s.
- valueAt(s: SupportsFloat | SupportsIndex) float¶
Returns option value at spot price s.
Specialized 1D solver for Black-Scholes processes. Accepts the process directly (no need to build operators manually).
solver = ql.FdmBlackScholesSolver(process, strike, desc)
solver.valueAt(spot) # option value
solver.deltaAt(spot) # delta
solver.gammaAt(spot) # gamma
solver.thetaAt(spot) # theta
FdmHestonSolver¶
- class pyquantlib.FdmHestonSolver¶
Bases:
LazyObjectSpecialized 2D FDM solver for Heston stochastic volatility.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(process: HestonProcessHandle, solverDesc: FdmSolverDesc, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7f2534349430>, quantoHelper: object = None, leverageFct: object = None, mixingFactor: SupportsFloat | SupportsIndex = 1.0) -> None
Constructs from Heston process handle.
__init__(process: HestonProcess, solverDesc: FdmSolverDesc, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7f25341d2fb0>, quantoHelper: object = None, leverageFct: object = None, mixingFactor: SupportsFloat | SupportsIndex = 1.0) -> None
Constructs from Heston process (handle created internally).
- deltaAt(s: SupportsFloat | SupportsIndex, v: SupportsFloat | SupportsIndex) float¶
Returns delta at spot s and variance v.
- gammaAt(s: SupportsFloat | SupportsIndex, v: SupportsFloat | SupportsIndex) float¶
Returns gamma at spot s and variance v.
- meanVarianceDeltaAt(s: SupportsFloat | SupportsIndex, v: SupportsFloat | SupportsIndex) float¶
Returns mean-variance adjusted delta.
- meanVarianceGammaAt(s: SupportsFloat | SupportsIndex, v: SupportsFloat | SupportsIndex) float¶
Returns mean-variance adjusted gamma.
- thetaAt(s: SupportsFloat | SupportsIndex, v: SupportsFloat | SupportsIndex) float¶
Returns theta at spot s and variance v.
- valueAt(s: SupportsFloat | SupportsIndex, v: SupportsFloat | SupportsIndex) float¶
Returns option value at spot s and variance v.
FdmBatesSolver¶
- class pyquantlib.FdmBatesSolver¶
Bases:
LazyObjectSpecialized 2D FDM solver for Bates jump-diffusion model.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(process: BatesProcessHandle, solverDesc: FdmSolverDesc, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7f25341a1ab0>, integroIntegrationOrder: SupportsInt | SupportsIndex = 12, quantoHelper: object = None) -> None
Constructs from Bates process handle.
__init__(process: BatesProcess, solverDesc: FdmSolverDesc, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7f252f3afc70>, integroIntegrationOrder: SupportsInt | SupportsIndex = 12, quantoHelper: object = None) -> None
Constructs from Bates process (handle created internally).
- deltaAt(s: SupportsFloat | SupportsIndex, v: SupportsFloat | SupportsIndex) float¶
Returns delta at spot s and variance v.
- gammaAt(s: SupportsFloat | SupportsIndex, v: SupportsFloat | SupportsIndex) float¶
Returns gamma at spot s and variance v.
- thetaAt(s: SupportsFloat | SupportsIndex, v: SupportsFloat | SupportsIndex) float¶
Returns theta at spot s and variance v.
- valueAt(s: SupportsFloat | SupportsIndex, v: SupportsFloat | SupportsIndex) float¶
Returns option value at spot s and variance v.
FdmHullWhiteSolver¶
- class pyquantlib.FdmHullWhiteSolver¶
Bases:
LazyObjectSpecialized 1D FDM solver for Hull-White interest rate model.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(model: QuantLib::Handle<QuantLib::HullWhite>, solverDesc: FdmSolverDesc, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7f25341c0730>) -> None
Constructs from Hull-White model handle.
__init__(model: QuantLib::HullWhite, solverDesc: FdmSolverDesc, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7f253438ed70>) -> None
Constructs from Hull-White model (handle created internally).
- valueAt(r: SupportsFloat | SupportsIndex) float¶
Returns option value at interest rate r.
FdmG2Solver¶
- class pyquantlib.FdmG2Solver¶
Bases:
LazyObjectSpecialized 2D FDM solver for G2++ two-factor interest rate model.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(model: QuantLib::Handle<QuantLib::G2>, solverDesc: FdmSolverDesc, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7f253418ebb0>) -> None
Constructs from G2 model handle.
__init__(model: QuantLib::G2, solverDesc: FdmSolverDesc, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7f25341a2ff0>) -> None
Constructs from G2 model (handle created internally).
- valueAt(x: SupportsFloat | SupportsIndex, y: SupportsFloat | SupportsIndex) float¶
Returns option value at state variables x and y.
Fdm2dBlackScholesSolver¶
- class pyquantlib.Fdm2dBlackScholesSolver¶
Bases:
LazyObjectSpecialized 2D FDM solver for two-asset Black-Scholes.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(p1: GeneralizedBlackScholesProcessHandle, p2: GeneralizedBlackScholesProcessHandle, correlation: SupportsFloat | SupportsIndex, solverDesc: FdmSolverDesc, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7f252f3d7630>, localVol: bool = False, illegalLocalVolOverwrite: object = None) -> None
Constructs from two BS process handles and correlation.
__init__(p1: GeneralizedBlackScholesProcess, p2: GeneralizedBlackScholesProcess, correlation: SupportsFloat | SupportsIndex, solverDesc: FdmSolverDesc, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7f25341feff0>, localVol: bool = False, illegalLocalVolOverwrite: object = None) -> None
Constructs from two BS processes (handles created internally).
- deltaXat(x: SupportsFloat | SupportsIndex, y: SupportsFloat | SupportsIndex) float¶
Returns delta with respect to first asset.
- deltaYat(x: SupportsFloat | SupportsIndex, y: SupportsFloat | SupportsIndex) float¶
Returns delta with respect to second asset.
- gammaXYat(x: SupportsFloat | SupportsIndex, y: SupportsFloat | SupportsIndex) float¶
Returns cross-gamma between assets.
- gammaXat(x: SupportsFloat | SupportsIndex, y: SupportsFloat | SupportsIndex) float¶
Returns gamma with respect to first asset.
- gammaYat(x: SupportsFloat | SupportsIndex, y: SupportsFloat | SupportsIndex) float¶
Returns gamma with respect to second asset.
- thetaAt(x: SupportsFloat | SupportsIndex, y: SupportsFloat | SupportsIndex) float¶
Returns theta.
- valueAt(x: SupportsFloat | SupportsIndex, y: SupportsFloat | SupportsIndex) float¶
Returns option value at spot prices x and y.
Boundary Conditions¶
FdmDirichletBoundary¶
- class pyquantlib.FdmDirichletBoundary¶
Bases:
FdmBoundaryConditionDirichlet boundary condition for FDM. Sets a fixed value on a boundary.
- __init__(mesher: FdmMesher, valueOnBoundary: SupportsFloat | SupportsIndex, direction: SupportsInt | SupportsIndex, side: BoundaryConditionSide) None¶
Constructs with mesher, boundary value, direction, and side.
FdmDiscountDirichletBoundary¶
- class pyquantlib.FdmDiscountDirichletBoundary¶
Bases:
FdmBoundaryConditionDiscounted Dirichlet boundary condition for FDM.
- __init__(mesher: FdmMesher, rTS: base.YieldTermStructure, maturityTime: SupportsFloat | SupportsIndex, valueOnBoundary: SupportsFloat | SupportsIndex, direction: SupportsInt | SupportsIndex, side: BoundaryConditionSide) None¶
Constructs with mesher, yield curve, maturity time, boundary value, direction, and side.
FdmTimeDepDirichletBoundary¶
- class pyquantlib.FdmTimeDepDirichletBoundary¶
Bases:
FdmBoundaryConditionTime-dependent Dirichlet boundary condition for FDM.
- __init__(mesher: FdmMesher, valueOnBoundary: collections.abc.Callable[[SupportsFloat | SupportsIndex], float], direction: SupportsInt | SupportsIndex, side: BoundaryConditionSide) None¶
Constructs with scalar time-dependent boundary value function.
Additional Meshers¶
ExponentialJump1dMesher¶
- class pyquantlib.ExponentialJump1dMesher¶
Bases:
Fdm1dMesher1D mesher for exponential jump-diffusion processes.
- __init__(steps: SupportsInt | SupportsIndex, beta: SupportsFloat | SupportsIndex, jumpIntensity: SupportsFloat | SupportsIndex, eta: SupportsFloat | SupportsIndex, eps: SupportsFloat | SupportsIndex = 0.001) None¶
Constructs with step count and jump parameters.
- jumpSizeDensity(*args, **kwargs)¶
Overloaded function.
jumpSizeDensity(x: SupportsFloat | SupportsIndex) -> float
Asymptotic jump size density (t -> infinity).
jumpSizeDensity(x: SupportsFloat | SupportsIndex, t: SupportsFloat | SupportsIndex) -> float
Time-dependent jump size density.
- jumpSizeDistribution(*args, **kwargs)¶
Overloaded function.
jumpSizeDistribution(x: SupportsFloat | SupportsIndex) -> float
Asymptotic jump size distribution.
jumpSizeDistribution(x: SupportsFloat | SupportsIndex, t: SupportsFloat | SupportsIndex) -> float
Time-dependent jump size distribution.
Glued1dMesher¶
- class pyquantlib.Glued1dMesher¶
Bases:
Fdm1dMesherCombines two 1D meshers into one by gluing at their boundary.
- __init__(leftMesher: Fdm1dMesher, rightMesher: Fdm1dMesher) None¶
Constructs by gluing left and right meshers.
Additional Step Conditions¶
FdmArithmeticAverageCondition¶
- class pyquantlib.FdmArithmeticAverageCondition¶
Bases:
FdmStepConditionArithmetic average step condition for Asian option FDM pricing.
- __init__(averageTimes: collections.abc.Sequence[SupportsFloat | SupportsIndex], runningAverage: SupportsFloat | SupportsIndex, pastFixings: SupportsInt | SupportsIndex, mesher: FdmMesher, equityDirection: SupportsInt | SupportsIndex) None¶
Constructs with averaging times, running average, past fixings, mesher, and equity direction index.
FdmSimpleSwingCondition¶
- class pyquantlib.FdmSimpleSwingCondition¶
Bases:
FdmStepConditionSimple swing option step condition for FDM pricing.
- __init__(exerciseTimes: collections.abc.Sequence[SupportsFloat | SupportsIndex], mesher: FdmMesher, calculator: base.FdmInnerValueCalculator, swingDirection: SupportsInt | SupportsIndex, minExercises: SupportsInt | SupportsIndex = 0) None¶
Constructs with exercise times, mesher, calculator, swing direction index, and minimum exercises.
Additional Operators¶
NthOrderDerivativeOp¶
- class pyquantlib.NthOrderDerivativeOp¶
Bases:
FdmLinearOpNth-order finite difference derivative operator.
- __init__(direction: SupportsInt | SupportsIndex, order: SupportsInt | SupportsIndex, nPoints: SupportsInt | SupportsIndex, mesher: FdmMesher) None¶
Constructs with direction, derivative order, stencil width, and mesher.
Risk-Neutral Density Calculators¶
Compute probability density, cumulative distribution, and inverse CDF under the risk-neutral measure.
BSMRNDCalculator¶
- class pyquantlib.BSMRNDCalculator¶
Bases:
RiskNeutralDensityCalculatorBlack-Scholes-Merton risk-neutral density calculator.
- __init__(process: GeneralizedBlackScholesProcess) None¶
Constructs with a Black-Scholes process.
Black-Scholes-Merton risk-neutral density calculator. Operates in log-space (x = ln(S)).
import math
calc = ql.BSMRNDCalculator(process)
calc.pdf(math.log(100.0), 1.0) # density at ln(S)=ln(100), t=1
calc.cdf(math.log(100.0), 1.0) # CDF at ln(S)=ln(100), t=1
calc.invcdf(0.5, 1.0) # inverse CDF (returns ln(S))
GBSMRNDCalculator¶
- class pyquantlib.GBSMRNDCalculator¶
Bases:
RiskNeutralDensityCalculatorGeneralized Black-Scholes-Merton risk-neutral density calculator.
- __init__(process: GeneralizedBlackScholesProcess) None¶
Constructs with a generalized Black-Scholes process.
Generalized BSM risk-neutral density calculator. Operates in spot-space (x = S).
calc = ql.GBSMRNDCalculator(process)
calc.pdf(100.0, 1.0) # density at S=100, t=1
calc.cdf(100.0, 1.0) # CDF at S=100, t=1
calc.invcdf(0.5, 1.0) # inverse CDF (returns S)
HestonRNDCalculator¶
- class pyquantlib.HestonRNDCalculator¶
Bases:
RiskNeutralDensityCalculatorHeston model risk-neutral density calculator.
- __init__(hestonProcess: HestonProcess, integrationEps: SupportsFloat | SupportsIndex = 1e-06, maxIntegrationIterations: SupportsInt | SupportsIndex = 10000) None¶
Constructs with Heston process and integration parameters.
Heston stochastic volatility risk-neutral density calculator. Operates in log-space (x = ln(S)).
calc = ql.HestonRNDCalculator(heston_process, integrationEps=1e-8, maxIntegrationIterations=100000)
calc.pdf(math.log(100.0), 1.0)
calc.cdf(math.log(100.0), 1.0)
CEVRNDCalculator¶
- class pyquantlib.CEVRNDCalculator¶
Bases:
RiskNeutralDensityCalculatorConstant Elasticity of Variance risk-neutral density calculator.
- __init__(f0: SupportsFloat | SupportsIndex, alpha: SupportsFloat | SupportsIndex, beta: SupportsFloat | SupportsIndex) None¶
Constructs with forward price, alpha, and beta.
- massAtZero(t: SupportsFloat | SupportsIndex) float¶
Returns probability mass at zero for time t.
Constant Elasticity of Variance risk-neutral density calculator.
calc = ql.CEVRNDCalculator(f0=100.0, alpha=0.3, beta=0.5)
calc.pdf(100.0, 1.0)
calc.cdf(100.0, 1.0)
calc.massAtZero(1.0) # probability mass at zero
SquareRootProcessRNDCalculator¶
- class pyquantlib.SquareRootProcessRNDCalculator¶
Bases:
RiskNeutralDensityCalculatorSquare-root process risk-neutral density calculator.
- __init__(v0: SupportsFloat | SupportsIndex, kappa: SupportsFloat | SupportsIndex, theta: SupportsFloat | SupportsIndex, sigma: SupportsFloat | SupportsIndex) None¶
Constructs with initial value, mean reversion, long-run mean, and volatility.
- stationary_cdf(v: SupportsFloat | SupportsIndex) float¶
Returns stationary cumulative distribution at v.
- stationary_invcdf(q: SupportsFloat | SupportsIndex) float¶
Returns stationary inverse CDF at quantile q.
- stationary_pdf(v: SupportsFloat | SupportsIndex) float¶
Returns stationary probability density at v.
Square-root (CIR) process risk-neutral density calculator. Includes stationary distribution methods.
calc = ql.SquareRootProcessRNDCalculator(v0=0.04, kappa=1.0, theta=0.04, sigma=0.2)
calc.pdf(0.04, 1.0)
calc.cdf(0.04, 1.0)
# Stationary distribution
calc.stationary_pdf(0.04)
calc.stationary_cdf(0.04)
calc.stationary_invcdf(0.5)
LocalVolRNDCalculator¶
- class pyquantlib.LocalVolRNDCalculator¶
Bases:
RiskNeutralDensityCalculatorRisk-neutral density calculator using local volatility and FDM.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(spot: base.Quote, rTS: base.YieldTermStructure, qTS: base.YieldTermStructure, localVol: base.LocalVolTermStructure, xGrid: SupportsInt | SupportsIndex = 101, tGrid: SupportsInt | SupportsIndex = 51, x0Density: SupportsFloat | SupportsIndex = 0.1, localVolProbEps: SupportsFloat | SupportsIndex = 1e-06, maxIter: SupportsInt | SupportsIndex = 10000, gaussianStepSize: object = None) -> None
Constructs from spot, yield curves, local vol surface, and grid parameters.
__init__(spot: base.Quote, rTS: base.YieldTermStructure, qTS: base.YieldTermStructure, localVol: base.LocalVolTermStructure, timeGrid: TimeGrid, xGrid: SupportsInt | SupportsIndex = 101, x0Density: SupportsFloat | SupportsIndex = 0.1, eps: SupportsFloat | SupportsIndex = 1e-06, maxIter: SupportsInt | SupportsIndex = 10000, gaussianStepSize: object = None) -> None
Constructs from spot, yield curves, local vol, and explicit time grid.
- cdf(x: SupportsFloat | SupportsIndex, t: SupportsFloat | SupportsIndex) float¶
Returns the cumulative distribution at x and time t.
- invcdf(p: SupportsFloat | SupportsIndex, t: SupportsFloat | SupportsIndex) float¶
Returns the inverse CDF at probability p and time t.
- mesher(t: SupportsFloat | SupportsIndex) Fdm1dMesher¶
Returns the 1D mesher at time t.
- pdf(x: SupportsFloat | SupportsIndex, t: SupportsFloat | SupportsIndex) float¶
Returns the probability density at x and time t.
Local volatility-based RND calculator using FDM. Operates in log-space (x = ln(S)).
Note
Abstract base classes FdmLinearOp, FdmLinearOpComposite, BrownianGenerator, BrownianGeneratorFactory, FdmMesher, FdmStepCondition, FdmInnerValueCalculator, and RiskNeutralDensityCalculator are available in pyquantlib.base for type checking.