Pricing Engines Module¶
Vanilla Engines¶
AnalyticEuropeanEngine¶
- class pyquantlib.AnalyticEuropeanEngine¶
Bases:
engineAnalytic pricing engine for European vanilla options.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(process: GeneralizedBlackScholesProcess) -> None
Constructs engine with a Black-Scholes process.
__init__(process: GeneralizedBlackScholesProcess, discountCurve: YieldTermStructureHandle) -> None
Constructs engine with separate discount curve.
__init__(process: GeneralizedBlackScholesProcess, discountCurve: base.YieldTermStructure) -> None
Constructs engine with separate discount curve (handle created internally).
import pyquantlib as ql
engine = ql.AnalyticEuropeanEngine(process)
option.setPricingEngine(engine)
print(f"NPV: {option.NPV():.4f}")
print(f"Delta: {option.delta():.4f}")
print(f"Gamma: {option.gamma():.4f}")
print(f"Vega: {option.vega():.4f}")
IntegralEngine¶
- class pyquantlib.IntegralEngine¶
Bases:
PricingEnginePricing engine for European options using integral approach.
- __init__(process: GeneralizedBlackScholesProcess) None¶
Constructs with a Black-Scholes process.
AnalyticHestonEngine¶
- class pyquantlib.AnalyticHestonEngine¶
Bases:
GenericHestonModelEngineAnalytic pricing engine for Heston stochastic volatility model.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(model: HestonModel, relTolerance: SupportsFloat | SupportsIndex, maxEvaluations: SupportsInt | SupportsIndex) -> None
Constructs with adaptive Gauss-Lobatto integration.
__init__(model: HestonModel, integrationOrder: SupportsInt | SupportsIndex = 144) -> None
Constructs with Gauss-Laguerre integration.
__init__(model: HestonModel, cpxLog: ComplexLogFormula, integration: Integration, andersenPiterbargEpsilon: SupportsFloat | SupportsIndex = 1e-25, alpha: SupportsFloat | SupportsIndex = -0.5) -> None
Constructs with full control over integration method.
- priceVanillaPayoff(payoff: PlainVanillaPayoff, maturity: SupportsFloat | SupportsIndex) float¶
Prices vanilla payoff for given maturity.
heston_process = ql.HestonProcess(
ql.YieldTermStructureHandle(risk_free),
ql.YieldTermStructureHandle(dividend),
ql.QuoteHandle(spot),
v0=0.04, kappa=1.0, theta=0.04, sigma=0.5, rho=-0.7,
)
heston_model = ql.HestonModel(heston_process)
engine = ql.AnalyticHestonEngine(heston_model)
Note
AnalyticHestonEngine computes NPV only. Greeks under Heston require finite difference engines.
AnalyticBlackVasicekEngine¶
- class pyquantlib.AnalyticBlackVasicekEngine¶
Bases:
PricingEngineEuropean option engine with stochastic Vasicek interest rates.
- __init__(bsProcess: GeneralizedBlackScholesProcess, vasicekProcess: Vasicek, correlation: SupportsFloat | SupportsIndex) None¶
Constructs with BS process, Vasicek model, and correlation.
European option pricing with stochastic Vasicek interest rates.
vasicek = ql.Vasicek(r0=0.05, a=0.3, b=0.05, sigma=0.01)
engine = ql.AnalyticBlackVasicekEngine(process, vasicek, correlation=0.5)
BatesEngine¶
- class pyquantlib.BatesEngine¶
Bases:
AnalyticHestonEngineAnalytic pricing engine for the Bates model.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(model: BatesModel, integrationOrder: SupportsInt | SupportsIndex = 144) -> None
Constructs with Bates model and integration order.
__init__(model: BatesModel, relTolerance: SupportsFloat | SupportsIndex, maxEvaluations: SupportsInt | SupportsIndex) -> None
Constructs with Bates model, relative tolerance, and max evaluations.
bates_process = ql.BatesProcess(
risk_free, dividend, spot,
0.04, 1.0, 0.04, 0.5, -0.7, # Heston params
0.1, -0.05, 0.1, # Jump params
)
model = ql.BatesModel(bates_process)
engine = ql.BatesEngine(model)
COSHestonEngine¶
- class pyquantlib.COSHestonEngine¶
Bases:
PricingEngineHeston engine using Fourier-cosine series expansion.
- __init__(model: HestonModel, L: SupportsFloat | SupportsIndex = 16, N: SupportsInt | SupportsIndex = 200) None¶
Constructs COS Heston engine.
- c1(t: SupportsFloat | SupportsIndex) float¶
- c2(t: SupportsFloat | SupportsIndex) float¶
- c3(t: SupportsFloat | SupportsIndex) float¶
- c4(t: SupportsFloat | SupportsIndex) float¶
- chF(u: SupportsFloat | SupportsIndex, t: SupportsFloat | SupportsIndex) complex¶
Returns the normalized characteristic function.
- kurtosis(t: SupportsFloat | SupportsIndex) float¶
Returns the kurtosis.
- mu(t: SupportsFloat | SupportsIndex) float¶
Returns the mean.
- skew(t: SupportsFloat | SupportsIndex) float¶
Returns the skewness.
- var(t: SupportsFloat | SupportsIndex) float¶
Returns the variance.
Fourier-cosine series expansion for fast Heston pricing.
engine = ql.COSHestonEngine(heston_model, L=16, N=200)
ExponentialFittingHestonEngine¶
- class pyquantlib.ExponentialFittingHestonEngine¶
Bases:
PricingEngineHeston engine using exponentially-fitted Gauss-Laguerre quadrature.
- __init__(model: HestonModel, cv: ComplexLogFormula = <ComplexLogFormula.OptimalCV: 7>, scaling: object = None, alpha: SupportsFloat | SupportsIndex = -0.5) None¶
Constructs exponential fitting Heston engine.
Exponentially-fitted Gauss-Laguerre quadrature for Heston pricing.
AnalyticPTDHestonEngine¶
- class pyquantlib.AnalyticPTDHestonEngine¶
Bases:
PricingEngineAnalytic piecewise time-dependent Heston engine.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(model: PiecewiseTimeDependentHestonModel, relTolerance: SupportsFloat | SupportsIndex, maxEvaluations: SupportsInt | SupportsIndex) -> None
Constructs with adaptive Gauss-Lobatto integration.
__init__(model: PiecewiseTimeDependentHestonModel, integrationOrder: SupportsInt | SupportsIndex = 144) -> None
Constructs with Gauss-Laguerre integration.
__init__(model: PiecewiseTimeDependentHestonModel, cpxLog: QuantLib::AnalyticPTDHestonEngine::ComplexLogFormula, integration: Integration, andersenPiterbargEpsilon: SupportsFloat | SupportsIndex = 1e-08) -> None
Constructs with full control over integration method.
Analytic engine for piecewise time-dependent Heston models.
AnalyticPDFHestonEngine¶
- class pyquantlib.AnalyticPDFHestonEngine¶
Bases:
PricingEnginePDF-based Heston engine for arbitrary European payoffs.
- Pv(x_t: SupportsFloat | SupportsIndex, t: SupportsFloat | SupportsIndex) float¶
Returns probability density in log-space.
- __init__(model: HestonModel, gaussLobattoEps: SupportsFloat | SupportsIndex = 1e-06, gaussLobattoIntegrationOrder: SupportsInt | SupportsIndex = 10000) None¶
Constructs PDF Heston engine.
- cdf(X: SupportsFloat | SupportsIndex, t: SupportsFloat | SupportsIndex) float¶
Returns cumulative distribution function Pr(x < X).
PDF-based Heston engine for arbitrary European payoffs.
HestonExpansionEngine¶
- class pyquantlib.HestonExpansionEngine¶
Bases:
PricingEngineHeston engine based on analytic expansions (LPP2, LPP3, Forde).
- __init__(model: HestonModel, formula: HestonExpansionFormula) None¶
Constructs Heston expansion engine.
Heston engine based on analytic expansions (LPP2, LPP3, Forde).
engine = ql.HestonExpansionEngine(model, ql.HestonExpansionFormula.LPP3)
AnalyticHestonHullWhiteEngine¶
- class pyquantlib.AnalyticHestonHullWhiteEngine¶
Bases:
AnalyticHestonEngineHeston engine with Hull-White stochastic interest rates.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(hestonModel: HestonModel, hullWhiteModel: HullWhite, integrationOrder: SupportsInt | SupportsIndex = 144) -> None
Constructs with Gauss-Laguerre integration.
__init__(hestonModel: HestonModel, hullWhiteModel: HullWhite, relTolerance: SupportsFloat | SupportsIndex, maxEvaluations: SupportsInt | SupportsIndex) -> None
Constructs with adaptive Gauss-Lobatto integration.
Heston model with Hull-White stochastic interest rates.
engine = ql.AnalyticHestonHullWhiteEngine(heston_model, hull_white_model)
AnalyticH1HWEngine¶
- class pyquantlib.AnalyticH1HWEngine¶
Bases:
AnalyticHestonHullWhiteEngineH1-HW approximation with equity-rate correlation.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(model: HestonModel, hullWhiteModel: HullWhite, rhoSr: SupportsFloat | SupportsIndex, integrationOrder: SupportsInt | SupportsIndex = 144) -> None
Constructs with Gauss-Laguerre integration.
__init__(model: HestonModel, hullWhiteModel: HullWhite, rhoSr: SupportsFloat | SupportsIndex, relTolerance: SupportsFloat | SupportsIndex, maxEvaluations: SupportsInt | SupportsIndex) -> None
Constructs with adaptive Gauss-Lobatto integration.
H1-HW approximation including equity-rate correlation.
engine = ql.AnalyticH1HWEngine(heston_model, hull_white_model, rhoSr=0.3)
BaroneAdesiWhaleyApproximationEngine¶
- class pyquantlib.BaroneAdesiWhaleyApproximationEngine¶
Bases:
PricingEngineBarone-Adesi and Whaley approximation engine for American options (1987).
- static criticalPrice(payoff: base.StrikedTypePayoff, riskFreeDiscount: SupportsFloat | SupportsIndex, dividendDiscount: SupportsFloat | SupportsIndex, variance: SupportsFloat | SupportsIndex, tolerance: SupportsFloat | SupportsIndex = 1e-06) float¶
Computes the critical price for early exercise.
- __init__(process: GeneralizedBlackScholesProcess) None¶
Constructs from a Black-Scholes process.
BjerksundStenslandApproximationEngine¶
- class pyquantlib.BjerksundStenslandApproximationEngine¶
Bases:
PricingEngineBjerksund and Stensland approximation engine for American options (1993).
- __init__(process: GeneralizedBlackScholesProcess) None¶
Constructs from a Black-Scholes process.
BinomialVanillaEngine¶
- class pyquantlib.BinomialVanillaEngine(process: GeneralizedBlackScholesProcess, treeType: str, timeSteps: SupportsInt | SupportsIndex) base.PricingEngine¶
Bases:
Binomial tree pricing engine for vanilla options.
- Parameters:
process – Black-Scholes process
treeType – Tree type - one of: ‘jr’ or ‘jarrowrudd’: Jarrow-Rudd ‘crr’ or ‘coxrossrubinstein’: Cox-Ross-Rubinstein ‘eqp’ or ‘additiveeqp’: Additive equal probabilities ‘trigeorgis’: Trigeorgis ‘tian’: Tian ‘lr’ or ‘leisenreimer’: Leisen-Reimer ‘joshi’ or ‘joshi4’: Joshi
timeSteps – Number of time steps (minimum 2)
engine = ql.BinomialVanillaEngine(process, "crr", 801)
Tree types: jr, crr, eqp, trigeorgis, tian, lr, joshi
FdBlackScholesVanillaEngine¶
- class pyquantlib.FdBlackScholesVanillaEngine¶
Bases:
PricingEngineFinite-differences Black-Scholes vanilla option engine.
- __init__(process: GeneralizedBlackScholesProcess, tGrid: SupportsInt | SupportsIndex = 100, xGrid: SupportsInt | SupportsIndex = 100, dampingSteps: SupportsInt | SupportsIndex = 0, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7e30eed4ff30>, localVol: bool = False, illegalLocalVolOverwrite: SupportsFloat | SupportsIndex = -3.4028234663852886e+38, cashDividendModel: CashDividendModel = <CashDividendModel.Spot: 0>) None¶
Constructs a finite-difference Black-Scholes engine.
- Parameters:
process – Black-Scholes process
tGrid – Number of time steps
xGrid – Number of spatial grid points
dampingSteps – Damping steps near maturity
schemeDesc – FD scheme (Douglas, CrankNicolson, etc.)
localVol – Use local volatility
illegalLocalVolOverwrite – Override for illegal local vol values
cashDividendModel – Spot or Escrowed
engine = ql.FdBlackScholesVanillaEngine(
process,
tGrid=100,
xGrid=100,
schemeDesc=ql.FdmSchemeDesc.Douglas(),
)
FdHestonVanillaEngine¶
- class pyquantlib.FdHestonVanillaEngine¶
Bases:
PricingEngineFinite-differences Heston vanilla option engine.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(model: HestonModel, tGrid: SupportsInt | SupportsIndex = 100, xGrid: SupportsInt | SupportsIndex = 100, vGrid: SupportsInt | SupportsIndex = 50, dampingSteps: SupportsInt | SupportsIndex = 0, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7e30ee4e1e30>, leverageFct: base.LocalVolTermStructure = None, mixingFactor: SupportsFloat | SupportsIndex = 1.0) -> None
Constructs FD Heston engine.
__init__(model: HestonModel, dividends: collections.abc.Sequence[base.Dividend], tGrid: SupportsInt | SupportsIndex = 100, xGrid: SupportsInt | SupportsIndex = 100, vGrid: SupportsInt | SupportsIndex = 50, dampingSteps: SupportsInt | SupportsIndex = 0, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7e30eed70b70>, leverageFct: base.LocalVolTermStructure = None, mixingFactor: SupportsFloat | SupportsIndex = 1.0) -> None
Constructs FD Heston engine with dividends.
- enableMultipleStrikesCaching(strikes: collections.abc.Sequence[SupportsFloat | SupportsIndex]) None¶
Enables caching for multiple strikes.
Finite-differences Heston vanilla option engine. Supports European and American exercise.
engine = ql.FdHestonVanillaEngine(heston_model, tGrid=100, xGrid=100, vGrid=50)
option.setPricingEngine(engine)
# Multiple-strike caching for efficiency
engine.enableMultipleStrikesCaching([90.0, 100.0, 110.0])
The MakeFdHestonVanillaEngine builder provides a keyword-argument interface:
engine = ql.MakeFdHestonVanillaEngine(heston_model, tGrid=100, xGrid=100, vGrid=50)
FdBatesVanillaEngine¶
- class pyquantlib.FdBatesVanillaEngine¶
Bases:
PricingEnginePartial integro finite-differences Bates vanilla option engine.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(model: BatesModel, tGrid: SupportsInt | SupportsIndex = 100, xGrid: SupportsInt | SupportsIndex = 100, vGrid: SupportsInt | SupportsIndex = 50, dampingSteps: SupportsInt | SupportsIndex = 0, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7e30ee4f66f0>) -> None
Constructs FD Bates engine.
__init__(model: BatesModel, dividends: std::vector<std::shared_ptr<QuantLib::Dividend>, std::allocator<std::shared_ptr<QuantLib::Dividend> > >, tGrid: SupportsInt | SupportsIndex = 100, xGrid: SupportsInt | SupportsIndex = 100, vGrid: SupportsInt | SupportsIndex = 50, dampingSteps: SupportsInt | SupportsIndex = 0, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7e30eed72ab0>) -> None
Constructs FD Bates engine with dividends.
Partial integro finite-differences engine for the Bates model (Heston + jumps).
engine = ql.FdBatesVanillaEngine(bates_model, tGrid=100, xGrid=100, vGrid=50)
FdSabrVanillaEngine¶
- class pyquantlib.FdSabrVanillaEngine¶
Bases:
PricingEngineFinite-differences SABR vanilla option engine.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(f0: SupportsFloat | SupportsIndex, alpha: SupportsFloat | SupportsIndex, beta: SupportsFloat | SupportsIndex, nu: SupportsFloat | SupportsIndex, rho: SupportsFloat | SupportsIndex, rTS: YieldTermStructureHandle, tGrid: SupportsInt | SupportsIndex = 50, fGrid: SupportsInt | SupportsIndex = 400, xGrid: SupportsInt | SupportsIndex = 50, dampingSteps: SupportsInt | SupportsIndex = 0, scalingFactor: SupportsFloat | SupportsIndex = 1.0, eps: SupportsFloat | SupportsIndex = 0.0001, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7e30ee5776b0>) -> None
Constructs FD SABR engine with handle.
__init__(f0: SupportsFloat | SupportsIndex, alpha: SupportsFloat | SupportsIndex, beta: SupportsFloat | SupportsIndex, nu: SupportsFloat | SupportsIndex, rho: SupportsFloat | SupportsIndex, rTS: base.YieldTermStructure, tGrid: SupportsInt | SupportsIndex = 50, fGrid: SupportsInt | SupportsIndex = 400, xGrid: SupportsInt | SupportsIndex = 50, dampingSteps: SupportsInt | SupportsIndex = 0, scalingFactor: SupportsFloat | SupportsIndex = 1.0, eps: SupportsFloat | SupportsIndex = 0.0001, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7e30ee54ccf0>) -> None
Constructs FD SABR engine (handle created internally).
Finite-differences SABR vanilla option engine. Takes model parameters directly.
engine = ql.FdSabrVanillaEngine(f0, alpha, beta, nu, rho, discount_curve)
FdCEVVanillaEngine¶
- class pyquantlib.FdCEVVanillaEngine¶
Bases:
PricingEngineFinite-differences CEV vanilla option engine.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(f0: SupportsFloat | SupportsIndex, alpha: SupportsFloat | SupportsIndex, beta: SupportsFloat | SupportsIndex, discountCurve: YieldTermStructureHandle, tGrid: SupportsInt | SupportsIndex = 50, xGrid: SupportsInt | SupportsIndex = 400, dampingSteps: SupportsInt | SupportsIndex = 0, scalingFactor: SupportsFloat | SupportsIndex = 1.0, eps: SupportsFloat | SupportsIndex = 0.0001, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7e30effe4bf0>) -> None
Constructs FD CEV engine with handle.
__init__(f0: SupportsFloat | SupportsIndex, alpha: SupportsFloat | SupportsIndex, beta: SupportsFloat | SupportsIndex, discountCurve: base.YieldTermStructure, tGrid: SupportsInt | SupportsIndex = 50, xGrid: SupportsInt | SupportsIndex = 400, dampingSteps: SupportsInt | SupportsIndex = 0, scalingFactor: SupportsFloat | SupportsIndex = 1.0, eps: SupportsFloat | SupportsIndex = 0.0001, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7e30effe53b0>) -> None
Constructs FD CEV engine (handle created internally).
Finite-differences CEV (constant elasticity of variance) vanilla option engine.
engine = ql.FdCEVVanillaEngine(f0, alpha, beta, discount_curve)
FdBlackScholesShoutEngine¶
- class pyquantlib.FdBlackScholesShoutEngine¶
Bases:
PricingEngineFinite-differences Black-Scholes shout option engine.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(process: GeneralizedBlackScholesProcess, tGrid: SupportsInt | SupportsIndex = 100, xGrid: SupportsInt | SupportsIndex = 100, dampingSteps: SupportsInt | SupportsIndex = 0, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7e30eed0ff30>) -> None
Constructs FD Black-Scholes shout engine.
__init__(process: GeneralizedBlackScholesProcess, dividends: std::vector<std::shared_ptr<QuantLib::Dividend>, std::allocator<std::shared_ptr<QuantLib::Dividend> > >, tGrid: SupportsInt | SupportsIndex = 100, xGrid: SupportsInt | SupportsIndex = 100, dampingSteps: SupportsInt | SupportsIndex = 0, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7e30eebc65f0>) -> None
Constructs FD Black-Scholes shout engine with dividends.
Finite-differences engine for shout options (holder can lock in current intrinsic value).
engine = ql.FdBlackScholesShoutEngine(process, tGrid=100, xGrid=100)
FdHestonHullWhiteVanillaEngine¶
- class pyquantlib.FdHestonHullWhiteVanillaEngine¶
Bases:
PricingEngineFinite-differences Heston + Hull-White vanilla option engine.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(model: HestonModel, hwProcess: HullWhiteProcess, corrEquityShortRate: SupportsFloat | SupportsIndex, tGrid: SupportsInt | SupportsIndex = 50, xGrid: SupportsInt | SupportsIndex = 100, vGrid: SupportsInt | SupportsIndex = 40, rGrid: SupportsInt | SupportsIndex = 20, dampingSteps: SupportsInt | SupportsIndex = 0, controlVariate: bool = True, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7e30ee57c2b0>) -> None
Constructs FD Heston-HW engine.
__init__(model: HestonModel, hwProcess: HullWhiteProcess, dividends: collections.abc.Sequence[base.Dividend], corrEquityShortRate: SupportsFloat | SupportsIndex, tGrid: SupportsInt | SupportsIndex = 50, xGrid: SupportsInt | SupportsIndex = 100, vGrid: SupportsInt | SupportsIndex = 40, rGrid: SupportsInt | SupportsIndex = 20, dampingSteps: SupportsInt | SupportsIndex = 0, controlVariate: bool = True, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7e30eebd9470>) -> None
Constructs FD Heston-HW engine with dividends.
Finite-differences Heston + Hull-White engine for vanilla options with stochastic rates.
engine = ql.FdHestonHullWhiteVanillaEngine(
heston_model, hw_process, corrEquityShortRate=0.3,
)
FdOrnsteinUhlenbeckVanillaEngine¶
- class pyquantlib.FdOrnsteinUhlenbeckVanillaEngine¶
Bases:
PricingEngineFinite-differences Ornstein-Uhlenbeck vanilla option engine.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(process: OrnsteinUhlenbeckProcess, riskFreeRate: base.YieldTermStructure, tGrid: SupportsInt | SupportsIndex = 100, xGrid: SupportsInt | SupportsIndex = 100, dampingSteps: SupportsInt | SupportsIndex = 0, epsilon: SupportsFloat | SupportsIndex = 0.0001, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7e30eecf7f70>) -> None
Constructs FD OU engine.
__init__(process: OrnsteinUhlenbeckProcess, riskFreeRate: base.YieldTermStructure, dividends: collections.abc.Sequence[base.Dividend], tGrid: SupportsInt | SupportsIndex = 100, xGrid: SupportsInt | SupportsIndex = 100, dampingSteps: SupportsInt | SupportsIndex = 0, epsilon: SupportsFloat | SupportsIndex = 0.0001, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7e30ee566f70>) -> None
Constructs FD OU engine with dividends.
Finite-differences Ornstein-Uhlenbeck vanilla option engine.
ou_process = ql.OrnsteinUhlenbeckProcess(speed=0.5, volatility=0.01)
engine = ql.FdOrnsteinUhlenbeckVanillaEngine(ou_process, discount_curve)
MCEuropeanEngine¶
- class pyquantlib.MCEuropeanEngine(process: GeneralizedBlackScholesProcess, rngType: str = 'pseudorandom', timeSteps: object = None, timeStepsPerYear: object = None, brownianBridge: bool = False, antitheticVariate: bool = False, requiredSamples: object = None, requiredTolerance: object = None, maxSamples: object = None, seed: SupportsInt | SupportsIndex = 0) base.PricingEngine¶
Bases:
Monte Carlo European option pricing engine.
- Parameters:
process – Black-Scholes process
rngType – ‘pseudorandom’ or ‘lowdiscrepancy’
timeSteps – Number of time steps
timeStepsPerYear – Time steps per year (alternative to timeSteps)
brownianBridge – Use Brownian bridge
antitheticVariate – Use antithetic variates
requiredSamples – Number of samples
requiredTolerance – Target tolerance (alternative to requiredSamples)
maxSamples – Maximum samples
seed – Random seed (0 for random)
engine = ql.MCEuropeanEngine(
process,
timeSteps=100,
requiredSamples=100000,
seed=42,
)
option.setPricingEngine(engine)
print(f"NPV: {option.NPV():.4f}")
print(f"Error: {option.errorEstimate():.6f}")
MCAmericanEngine¶
- class pyquantlib.MCAmericanEngine(process: GeneralizedBlackScholesProcess, rngType: str = 'pseudorandom', timeSteps: object = None, timeStepsPerYear: object = None, antitheticVariate: bool = False, controlVariate: bool = False, requiredSamples: object = None, requiredTolerance: object = None, maxSamples: object = None, seed: SupportsInt | SupportsIndex = 0, polynomialOrder: SupportsInt | SupportsIndex = 2, polynomialType: PolynomialType = <PolynomialType.Monomial: 0>, calibrationSamples: SupportsInt | SupportsIndex = 2048) base.PricingEngine¶
Bases:
Monte Carlo American option pricing engine (Longstaff-Schwartz).
- Parameters:
process – Black-Scholes process
rngType – ‘pseudorandom’ or ‘lowdiscrepancy’
timeSteps – Number of time steps
timeStepsPerYear – Time steps per year (alternative to timeSteps)
antitheticVariate – Use antithetic variates
controlVariate – Use control variate (European option)
requiredSamples – Number of samples
requiredTolerance – Target tolerance (alternative to requiredSamples)
maxSamples – Maximum samples
seed – Random seed (0 for random)
polynomialOrder – Order of regression polynomial
polynomialType – Polynomial basis type (Monomial, Laguerre, etc.)
calibrationSamples – Samples for regression calibration
engine = ql.MCAmericanEngine(
process,
timeSteps=100,
antitheticVariate=True,
calibrationSamples=4096,
requiredTolerance=0.02,
seed=42,
)
MCEuropeanHestonEngine¶
- pyquantlib.MCEuropeanHestonEngine(process: HestonProcess, rngType: str = 'pseudorandom', timeSteps: object = None, timeStepsPerYear: object = None, antitheticVariate: bool = False, requiredSamples: object = None, requiredTolerance: object = None, maxSamples: object = None, seed: SupportsInt | SupportsIndex = 0) base.PricingEngine¶
Monte Carlo European Heston option pricing engine.
- Parameters:
process – Heston process
rngType – ‘pseudorandom’ or ‘lowdiscrepancy’
timeSteps – Number of time steps
timeStepsPerYear – Time steps per year (alternative to timeSteps)
antitheticVariate – Use antithetic variates
requiredSamples – Number of samples
requiredTolerance – Target tolerance (alternative to requiredSamples)
maxSamples – Maximum samples
seed – Random seed (0 for random)
Monte Carlo European option engine under the Heston model.
engine = ql.MCEuropeanHestonEngine(
heston_process,
timeSteps=100,
requiredSamples=100000,
seed=42,
)
MCEuropeanGJRGARCHEngine¶
- pyquantlib.MCEuropeanGJRGARCHEngine(process: GJRGARCHProcess, rngType: str = 'pseudorandom', timeSteps: object = None, timeStepsPerYear: object = None, antitheticVariate: bool = False, requiredSamples: object = None, requiredTolerance: object = None, maxSamples: object = None, seed: SupportsInt | SupportsIndex = 0) base.PricingEngine¶
Monte Carlo GJR-GARCH European option pricing engine.
Monte Carlo European option engine under the GJR-GARCH(1,1) model.
engine = ql.MCEuropeanGJRGARCHEngine(
gjrgarch_process,
timeSteps=100,
requiredSamples=100000,
seed=42,
)
AnalyticCEVEngine¶
- class pyquantlib.AnalyticCEVEngine¶
Bases:
PricingEngineAnalytic Constant Elasticity of Variance pricing engine.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(f0: SupportsFloat | SupportsIndex, alpha: SupportsFloat | SupportsIndex, beta: SupportsFloat | SupportsIndex, discountCurve: YieldTermStructureHandle) -> None
Constructs AnalyticCEVEngine.
__init__(f0: SupportsFloat | SupportsIndex, alpha: SupportsFloat | SupportsIndex, beta: SupportsFloat | SupportsIndex, discountCurve: base.YieldTermStructure) -> None
Constructs from yield term structure (handle created internally).
Analytic engine for the constant elasticity of variance (CEV) model.
engine = ql.AnalyticCEVEngine(f0, alpha, beta, discount_curve)
CEVCalculator¶
- class pyquantlib.CEVCalculator¶
Bases:
pybind11_objectConstant Elasticity of Variance option value calculator.
- __init__(f0: SupportsFloat | SupportsIndex, alpha: SupportsFloat | SupportsIndex, beta: SupportsFloat | SupportsIndex) None¶
Constructs CEVCalculator.
- value(optionType: OptionType, strike: SupportsFloat | SupportsIndex, t: SupportsFloat | SupportsIndex) float¶
Returns CEV option value.
Standalone CEV option value calculator.
calc = ql.CEVCalculator(f0, alpha, beta)
print(calc.value(ql.Call, 100.0, 1.0))
QdFpAmericanEngine¶
- class pyquantlib.QdFpAmericanEngine¶
Bases:
PricingEngineHigh performance American option engine based on QD+ fixed-point iteration.
- static accurateScheme() QdFpIterationScheme¶
Returns the accurate iteration scheme (default).
- static fastScheme() QdFpIterationScheme¶
Returns the fast iteration scheme.
- static highPrecisionScheme() QdFpIterationScheme¶
Returns the high precision iteration scheme.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(process: GeneralizedBlackScholesProcess) -> None
Constructs with process using default accurate scheme.
__init__(process: GeneralizedBlackScholesProcess, iterationScheme: QdFpIterationScheme, fpEquation: QdFpFixedPointEquation = <QdFpFixedPointEquation.Auto: 2>) -> None
Constructs with process, iteration scheme, and fixed-point equation type.
High-performance American option engine based on QD+ fixed-point iteration.
engine = ql.QdFpAmericanEngine(process)
Warning
QdFpAmericanEngine.calculate() may crash on Windows. Use alternative American engines if needed.
JuQuadraticApproximationEngine¶
- class pyquantlib.JuQuadraticApproximationEngine¶
Bases:
PricingEngineJu quadratic approximation for American options.
- __init__(process: GeneralizedBlackScholesProcess) None¶
Constructs Ju quadratic approximation engine.
QdPlusAmericanEngine¶
- class pyquantlib.QdPlusAmericanEngine¶
Bases:
PricingEngineQD+ American option pricing engine.
- __init__(process: GeneralizedBlackScholesProcess, interpolationPoints: SupportsInt | SupportsIndex = 8, solverType: QdPlusAmericanEngineSolverType = <QdPlusAmericanEngineSolverType.Halley: 3>, eps: SupportsFloat | SupportsIndex = 1e-06, maxIter: object = None) None¶
Constructs QD+ American engine.
- class pyquantlib.QdPlusAmericanEngineSolverType¶
Bases:
pybind11_objectSolver type for QD+ American engine.
Members:
Brent
Newton
Ridder
Halley
SuperHalley
- __init__(value: SupportsInt | SupportsIndex) None¶
- Brent = <QdPlusAmericanEngineSolverType.Brent: 0>¶
- Halley = <QdPlusAmericanEngineSolverType.Halley: 3>¶
- Newton = <QdPlusAmericanEngineSolverType.Newton: 1>¶
- Ridder = <QdPlusAmericanEngineSolverType.Ridder: 2>¶
- SuperHalley = <QdPlusAmericanEngineSolverType.SuperHalley: 4>¶
- QdPlusAmericanEngineSolverType.name -> str
- property value¶
AnalyticDigitalAmericanEngine¶
- class pyquantlib.AnalyticDigitalAmericanEngine¶
Bases:
PricingEngineAnalytic pricing engine for digital American options (knock-in).
- __init__(process: GeneralizedBlackScholesProcess) None¶
Constructs analytic digital American engine.
AnalyticDigitalAmericanKOEngine¶
- class pyquantlib.AnalyticDigitalAmericanKOEngine¶
Bases:
AnalyticDigitalAmericanEngineAnalytic pricing engine for digital American options (knock-out).
- __init__(process: GeneralizedBlackScholesProcess) None¶
Constructs analytic digital American knock-out engine.
MCDigitalEngine¶
- pyquantlib.MCDigitalEngine(process: GeneralizedBlackScholesProcess, rngType: str = 'pseudorandom', timeSteps: object = None, timeStepsPerYear: object = None, brownianBridge: bool = False, antitheticVariate: bool = False, requiredSamples: object = None, requiredTolerance: object = None, maxSamples: object = None, seed: SupportsInt | SupportsIndex = 0) base.PricingEngine¶
Monte Carlo digital option pricing engine.
AnalyticDividendEuropeanEngine¶
- class pyquantlib.AnalyticDividendEuropeanEngine¶
Bases:
PricingEngineEuropean engine with discrete dividends.
- __init__(process: GeneralizedBlackScholesProcess, dividends: collections.abc.Sequence[base.Dividend]) None¶
Constructs analytic dividend European engine.
CashDividendEuropeanEngine¶
- class pyquantlib.CashDividendModel¶
Bases:
pybind11_objectCash dividend model for finite difference engines.
Members:
Spot : Spot adjustment model.
Escrowed : Escrowed dividend model.
- __init__(value: SupportsInt | SupportsIndex) None¶
- Escrowed = <CashDividendModel.Escrowed: 1>¶
- Spot = <CashDividendModel.Spot: 0>¶
- CashDividendModel.name -> str
- property value¶
Semi-analytic European engine with cash dividends (Healy, 2021). Supports Spot and Escrowed dividend models.
dividends = [ql.FixedDividend(2.0, ex_date)]
engine = ql.CashDividendEuropeanEngine(
process, dividends, ql.CashDividendModel.Spot)
AnalyticBSMHullWhiteEngine¶
- class pyquantlib.AnalyticBSMHullWhiteEngine¶
Bases:
PricingEngineBSM engine with Hull-White stochastic interest rates.
- __init__(equityShortRateCorrelation: SupportsFloat | SupportsIndex, process: GeneralizedBlackScholesProcess, hullWhiteModel: HullWhite) None¶
Constructs BSM Hull-White engine.
Basket Engines¶
MCEuropeanBasketEngine¶
- class pyquantlib.MCEuropeanBasketEngine¶
Bases:
PricingEngineMonte Carlo pricing engine for European basket options (pseudo-random).
- __init__(process: StochasticProcessArray, timeSteps: SupportsInt | SupportsIndex = Null<NullSize>(), timeStepsPerYear: SupportsInt | SupportsIndex = Null<NullSize>(), brownianBridge: bool = False, antitheticVariate: bool = False, requiredSamples: SupportsInt | SupportsIndex = Null<NullSize>(), requiredTolerance: SupportsFloat | SupportsIndex = Null<NullReal>(), maxSamples: SupportsInt | SupportsIndex = Null<NullSize>(), seed: SupportsInt | SupportsIndex = 0) None¶
Constructs MC European basket engine with pseudo-random numbers.
Fd2dBlackScholesVanillaEngine¶
- class pyquantlib.Fd2dBlackScholesVanillaEngine¶
Bases:
BasketOptionEngine2D finite-difference Black-Scholes engine for basket options.
- __init__(process1: GeneralizedBlackScholesProcess, process2: GeneralizedBlackScholesProcess, correlation: SupportsFloat | SupportsIndex, xGrid: SupportsInt | SupportsIndex = 100, yGrid: SupportsInt | SupportsIndex = 100, tGrid: SupportsInt | SupportsIndex = 50, dampingSteps: SupportsInt | SupportsIndex = 0, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7e30eeb69d70>, localVol: bool = False, illegalLocalVolOverwrite: SupportsFloat | SupportsIndex = -3.4028234663852886e+38) None¶
Constructs with two processes, correlation, and optional grid/scheme parameters.
KirkEngine¶
- class pyquantlib.KirkEngine¶
Bases:
SpreadBlackScholesVanillaEngineKirk engine for spread option pricing on two futures.
- __init__(process1: GeneralizedBlackScholesProcess, process2: GeneralizedBlackScholesProcess, correlation: SupportsFloat | SupportsIndex) None¶
Constructs with two Black-Scholes processes and correlation.
StulzEngine¶
- class pyquantlib.StulzEngine¶
Bases:
BasketOptionEngineStulz analytical engine for 2D min/max European basket options.
- __init__(process1: GeneralizedBlackScholesProcess, process2: GeneralizedBlackScholesProcess, correlation: SupportsFloat | SupportsIndex) None¶
Constructs with two Black-Scholes processes and correlation.
ChoiBasketEngine¶
Choi (2018) analytic engine for average and spread basket options.
SingleFactorBsmBasketEngine¶
Single-factor BSM approximation for average basket options.
MCAmericanBasketEngine¶
Monte Carlo American basket engine using Longstaff-Schwartz regression.
FdndimBlackScholesVanillaEngine¶
N-dimensional finite-difference Black-Scholes basket engine.
MCLDEuropeanBasketEngine¶
- class pyquantlib.MCLDEuropeanBasketEngine¶
Bases:
PricingEngineMonte Carlo pricing engine for European basket options (low-discrepancy/Sobol).
- __init__(process: StochasticProcessArray, timeSteps: SupportsInt | SupportsIndex = Null<NullSize>(), timeStepsPerYear: SupportsInt | SupportsIndex = Null<NullSize>(), brownianBridge: bool = False, antitheticVariate: bool = False, requiredSamples: SupportsInt | SupportsIndex = Null<NullSize>(), requiredTolerance: SupportsFloat | SupportsIndex = Null<NullReal>(), maxSamples: SupportsInt | SupportsIndex = Null<NullSize>(), seed: SupportsInt | SupportsIndex = 0) None¶
Constructs MC European basket engine with low-discrepancy sequences.
Swaption Engines¶
BlackSwaptionEngine¶
- class pyquantlib.BlackSwaptionEngine¶
Bases:
PricingEngineShifted lognormal Black-formula swaption engine.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(discountCurve: base.YieldTermStructure, vol: SupportsFloat | SupportsIndex, dayCounter: DayCounter = <DayCounter: Actual/365 (Fixed)>, displacement: SupportsFloat | SupportsIndex = 0.0) -> None
Constructs from constant volatility.
__init__(discountCurve: base.YieldTermStructure, vol: base.Quote, dayCounter: DayCounter = <DayCounter: Actual/365 (Fixed)>, displacement: SupportsFloat | SupportsIndex = 0.0) -> None
Constructs from quote volatility.
__init__(discountCurve: YieldTermStructureHandle, vol: SupportsFloat | SupportsIndex, dayCounter: DayCounter = <DayCounter: Actual/365 (Fixed)>, displacement: SupportsFloat | SupportsIndex = 0.0) -> None
Constructs from constant volatility (handle).
__init__(discountCurve: YieldTermStructureHandle, vol: QuoteHandle, dayCounter: DayCounter = <DayCounter: Actual/365 (Fixed)>, displacement: SupportsFloat | SupportsIndex = 0.0) -> None
Constructs from quote volatility (handle).
Black-formula (lognormal volatility) swaption engine.
engine = ql.BlackSwaptionEngine(curve, 0.20)
swaption.setPricingEngine(engine)
print(swaption.NPV())
BachelierSwaptionEngine¶
- class pyquantlib.BachelierSwaptionEngine¶
Bases:
PricingEngineNormal Bachelier-formula swaption engine.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(discountCurve: base.YieldTermStructure, vol: SupportsFloat | SupportsIndex, dayCounter: DayCounter = <DayCounter: Actual/365 (Fixed)>) -> None
Constructs from constant normal volatility.
__init__(discountCurve: base.YieldTermStructure, vol: base.Quote, dayCounter: DayCounter = <DayCounter: Actual/365 (Fixed)>) -> None
Constructs from quote normal volatility.
__init__(discountCurve: YieldTermStructureHandle, vol: SupportsFloat | SupportsIndex, dayCounter: DayCounter = <DayCounter: Actual/365 (Fixed)>) -> None
Constructs from constant normal volatility (handle).
__init__(discountCurve: YieldTermStructureHandle, vol: QuoteHandle, dayCounter: DayCounter = <DayCounter: Actual/365 (Fixed)>) -> None
Constructs from quote normal volatility (handle).
Bachelier (normal volatility) swaption engine.
engine = ql.BachelierSwaptionEngine(curve, 0.005)
swaption.setPricingEngine(engine)
print(swaption.NPV())
TreeSwaptionEngine¶
- class pyquantlib.TreeSwaptionEngine¶
Bases:
PricingEngineNumerical lattice engine for swaptions.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(model: base.ShortRateModel, timeSteps: SupportsInt | SupportsIndex, termStructure: YieldTermStructureHandle = <YieldTermStructureHandle object at 0x7e30eeb68270>) -> None
Constructs tree engine with model and time steps.
__init__(model: base.ShortRateModel, timeGrid: TimeGrid, termStructure: YieldTermStructureHandle = <YieldTermStructureHandle object at 0x7e30ee553c30>) -> None
Constructs tree engine with model and time grid.
__init__(model: ShortRateModelHandle, timeSteps: SupportsInt | SupportsIndex, termStructure: YieldTermStructureHandle = <YieldTermStructureHandle object at 0x7e30effe7970>) -> None
Constructs tree engine with model handle and time steps.
__init__(model: base.ShortRateModel, timeSteps: SupportsInt | SupportsIndex, termStructure: base.YieldTermStructure) -> None
Constructs tree engine with model, time steps, and term structure.
Numerical lattice engine for swaptions using short-rate models.
model = ql.HullWhite(curve, a=0.1, sigma=0.01)
engine = ql.TreeSwaptionEngine(model, timeSteps=100)
swaption.setPricingEngine(engine)
JamshidianSwaptionEngine¶
- class pyquantlib.JamshidianSwaptionEngine¶
Bases:
PricingEngineJamshidian swaption engine using bond option decomposition.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(model: base.OneFactorAffineModel, termStructure: YieldTermStructureHandle = <YieldTermStructureHandle object at 0x7e30f001c370>) -> None
Constructs Jamshidian engine with one-factor affine model.
__init__(model: base.OneFactorAffineModel, termStructure: base.YieldTermStructure) -> None
Constructs Jamshidian engine with model and term structure.
Analytic swaption engine using Jamshidian’s bond option decomposition.
model = ql.HullWhite(curve, a=0.1, sigma=0.01)
engine = ql.JamshidianSwaptionEngine(model)
swaption.setPricingEngine(engine)
G2SwaptionEngine¶
- class pyquantlib.G2SwaptionEngine¶
Bases:
PricingEngineSwaption engine for two-factor G2++ model.
- __init__(model: G2, range: SupportsFloat | SupportsIndex, intervals: SupportsInt | SupportsIndex) None¶
Constructs G2 swaption engine with integration parameters.
Swaption engine for the G2++ two-factor model.
model = ql.G2(curve, a=0.1, sigma=0.01, b=0.1, eta=0.01, rho=-0.75)
engine = ql.G2SwaptionEngine(model, range=6.0, intervals=200)
swaption.setPricingEngine(engine)
FdHullWhiteSwaptionEngine¶
- class pyquantlib.FdHullWhiteSwaptionEngine¶
Bases:
PricingEngineFinite-differences swaption engine for Hull-White model.
- __init__(model: HullWhite, tGrid: SupportsInt | SupportsIndex = 100, xGrid: SupportsInt | SupportsIndex = 100, dampingSteps: SupportsInt | SupportsIndex = 0, invEps: SupportsFloat | SupportsIndex = 1e-05, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7e30eeb68bb0>) None¶
Constructs FD Hull-White swaption engine.
Finite-differences swaption engine for the Hull-White model.
model = ql.HullWhite(curve, a=0.1, sigma=0.01)
engine = ql.FdHullWhiteSwaptionEngine(model, tGrid=100, xGrid=100)
swaption.setPricingEngine(engine)
FdG2SwaptionEngine¶
- class pyquantlib.FdG2SwaptionEngine¶
Bases:
PricingEngineFinite-differences swaption engine for G2++ two-factor model.
- __init__(model: G2, tGrid: SupportsInt | SupportsIndex = 100, xGrid: SupportsInt | SupportsIndex = 50, yGrid: SupportsInt | SupportsIndex = 50, dampingSteps: SupportsInt | SupportsIndex = 0, invEps: SupportsFloat | SupportsIndex = 1e-05, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7e30eeb6b270>) None¶
Constructs FD G2 swaption engine.
Finite-differences swaption engine for the G2++ two-factor model.
model = ql.G2(curve, a=0.1, sigma=0.01, b=0.1, eta=0.01, rho=-0.75)
engine = ql.FdG2SwaptionEngine(model, tGrid=100, xGrid=50, yGrid=50)
swaption.setPricingEngine(engine)
Gaussian1dSwaptionEngine¶
- class pyquantlib.Gaussian1dSwaptionEngine¶
Bases:
PricingEngineGaussian 1-D swaption engine for Bermudan/European swaptions.
- class Probabilities¶
Bases:
pybind11_objectProbability adjustment type.
Members:
- __init__(value: SupportsInt | SupportsIndex) None¶
- Digital = <Probabilities.Digital: 2>¶
- Naive = <Probabilities.Naive: 1>¶
- None_ = <Probabilities.None_: 0>¶
- Gaussian1dSwaptionEngine.Probabilities.name -> str
- property value¶
- __init__(model: base.Gaussian1dModel, integrationPoints: SupportsInt | SupportsIndex = 64, stddevs: SupportsFloat | SupportsIndex = 7.0, extrapolatePayoff: bool = True, flatPayoffExtrapolation: bool = False, discountCurve: YieldTermStructureHandle = <YieldTermStructureHandle object at 0x7e30eed19870>, probabilities: Gaussian1dSwaptionEngine.Probabilities = <Probabilities.None_: 0>) None¶
Constructs Gaussian 1-D swaption engine.
- Digital = <Probabilities.Digital: 2>¶
- Naive = <Probabilities.Naive: 1>¶
- None_ = <Probabilities.None_: 0>¶
Gaussian 1-D model swaption engine with numerical integration. Supports European and Bermudan exercise.
model = ql.Gsr(curve, [ql.Date(15, 1, 2025)], [0.01], 0.01)
engine = ql.Gaussian1dSwaptionEngine(model, integrationPoints=64)
swaption.setPricingEngine(engine)
print(swaption.NPV())
Gaussian1dJamshidianSwaptionEngine¶
- class pyquantlib.Gaussian1dJamshidianSwaptionEngine¶
Bases:
PricingEngineGaussian 1-D Jamshidian swaption engine (analytic decomposition).
Jamshidian decomposition swaption engine for Gaussian 1-D models. European exercise only.
engine = ql.Gaussian1dJamshidianSwaptionEngine(model)
swaption.setPricingEngine(engine)
Gaussian1dNonstandardSwaptionEngine¶
- class pyquantlib.Gaussian1dNonstandardSwaptionEngine¶
Bases:
PricingEngineGaussian 1-D engine for nonstandard swaptions.
- class Probabilities¶
Bases:
pybind11_objectProbability adjustment type.
Members:
- __init__(value: SupportsInt | SupportsIndex) None¶
- Digital = <Probabilities.Digital: 2>¶
- Naive = <Probabilities.Naive: 1>¶
- None_ = <Probabilities.None_: 0>¶
- Gaussian1dNonstandardSwaptionEngine.Probabilities.name -> str
- property value¶
- __init__(model: base.Gaussian1dModel, integrationPoints: SupportsInt | SupportsIndex = 64, stddevs: SupportsFloat | SupportsIndex = 7.0, extrapolatePayoff: bool = True, flatPayoffExtrapolation: bool = False, oas: QuoteHandle = <QuoteHandle object at 0x7e30f0038930>, discountCurve: YieldTermStructureHandle = <YieldTermStructureHandle object at 0x7e30f00383f0>, probabilities: Gaussian1dNonstandardSwaptionEngine.Probabilities = <Probabilities.None_: 0>) None¶
Constructs Gaussian 1-D nonstandard swaption engine.
- Digital = <Probabilities.Digital: 2>¶
- Naive = <Probabilities.Naive: 1>¶
- None_ = <Probabilities.None_: 0>¶
Gaussian 1-D model engine for nonstandard swaptions (period-varying notionals and strikes).
Gaussian1dFloatFloatSwaptionEngine¶
- class pyquantlib.Gaussian1dFloatFloatSwaptionEngine¶
Bases:
PricingEngineGaussian 1-D engine for float-float swaptions.
- class Probabilities¶
Bases:
pybind11_objectProbability adjustment type.
Members:
- __init__(value: SupportsInt | SupportsIndex) None¶
- Digital = <Probabilities.Digital: 2>¶
- Naive = <Probabilities.Naive: 1>¶
- None_ = <Probabilities.None_: 0>¶
- Gaussian1dFloatFloatSwaptionEngine.Probabilities.name -> str
- property value¶
- __init__(model: base.Gaussian1dModel, integrationPoints: SupportsInt | SupportsIndex = 64, stddevs: SupportsFloat | SupportsIndex = 7.0, extrapolatePayoff: bool = True, flatPayoffExtrapolation: bool = False, oas: QuoteHandle = <QuoteHandle object at 0x7e30ee5612f0>, discountCurve: YieldTermStructureHandle = <YieldTermStructureHandle object at 0x7e30ee5545f0>, includeTodaysExercise: bool = False, probabilities: Gaussian1dFloatFloatSwaptionEngine.Probabilities = <Probabilities.None_: 0>) None¶
Constructs Gaussian 1-D float-float swaption engine.
- Digital = <Probabilities.Digital: 2>¶
- Naive = <Probabilities.Naive: 1>¶
- None_ = <Probabilities.None_: 0>¶
Gaussian 1-D model engine for float-float swaptions.
Barrier Engines¶
AnalyticBarrierEngine¶
- class pyquantlib.AnalyticBarrierEngine¶
Bases:
PricingEngineAnalytic barrier option engine (Haug).
- __init__(process: GeneralizedBlackScholesProcess) None¶
Constructs AnalyticBarrierEngine.
Analytic pricing using Haug’s formulas.
engine = ql.AnalyticBarrierEngine(process)
AnalyticDoubleBarrierEngine¶
- class pyquantlib.AnalyticDoubleBarrierEngine¶
Bases:
PricingEngineAnalytic double barrier option engine (Ikeda-Kunitomo).
- __init__(process: GeneralizedBlackScholesProcess, series: SupportsInt | SupportsIndex = 5) None¶
Constructs AnalyticDoubleBarrierEngine.
Analytic double barrier engine using Ikeda-Kunitomo series.
engine = ql.AnalyticDoubleBarrierEngine(process, series=5)
FdBlackScholesBarrierEngine¶
- class pyquantlib.FdBlackScholesBarrierEngine¶
Bases:
PricingEngineFinite-differences Black-Scholes barrier option engine.
- __init__(process: GeneralizedBlackScholesProcess, tGrid: SupportsInt | SupportsIndex = 100, xGrid: SupportsInt | SupportsIndex = 100, dampingSteps: SupportsInt | SupportsIndex = 0, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7e30eed42b70>, localVol: bool = False, illegalLocalVolOverwrite: SupportsFloat | SupportsIndex = -3.4028234663852886e+38) None¶
Constructs FdBlackScholesBarrierEngine.
Finite-differences barrier option engine.
engine = ql.FdBlackScholesBarrierEngine(process, tGrid=100, xGrid=100)
FdBlackScholesRebateEngine¶
- class pyquantlib.FdBlackScholesRebateEngine¶
Bases:
PricingEngineFinite-differences Black-Scholes barrier option rebate engine.
- __init__(process: GeneralizedBlackScholesProcess, tGrid: SupportsInt | SupportsIndex = 100, xGrid: SupportsInt | SupportsIndex = 100, dampingSteps: SupportsInt | SupportsIndex = 0, schemeDesc: FdmSchemeDesc = <FdmSchemeDesc object at 0x7e30eeb7c1f0>, localVol: bool = False, illegalLocalVolOverwrite: SupportsFloat | SupportsIndex = -3.4028234663852886e+38) None¶
Constructs FdBlackScholesRebateEngine.
Finite-differences rebate engine for barrier options.
engine = ql.FdBlackScholesRebateEngine(process, tGrid=100, xGrid=100)
AnalyticDoubleBarrierBinaryEngine¶
- class pyquantlib.AnalyticDoubleBarrierBinaryEngine¶
Bases:
PricingEngineAnalytic double barrier binary (one-touch) option engine (Hui).
- __init__(process: GeneralizedBlackScholesProcess) None¶
Constructs AnalyticDoubleBarrierBinaryEngine.
Analytic double barrier binary (one-touch) option engine (Hui).
engine = ql.AnalyticDoubleBarrierBinaryEngine(process)
MCBarrierEngine¶
- pyquantlib.MCBarrierEngine(process: GeneralizedBlackScholesProcess, rngType: str = 'pseudorandom', timeSteps: object = None, timeStepsPerYear: object = None, brownianBridge: bool = False, antitheticVariate: bool = False, requiredSamples: object = None, requiredTolerance: object = None, maxSamples: object = None, isBiased: bool = False, seed: SupportsInt | SupportsIndex = 0) base.PricingEngine¶
Monte Carlo barrier option pricing engine.
Uses Brownian-bridge correction for the barrier by default. Set isBiased=True for the simpler (biased) path pricer.
Monte Carlo barrier option engine with optional Brownian bridge bias correction.
engine = ql.MCBarrierEngine(
process, timeSteps=50, requiredSamples=10000, seed=42,
)
MCDoubleBarrierEngine¶
- pyquantlib.MCDoubleBarrierEngine(process: GeneralizedBlackScholesProcess, rngType: str = 'pseudorandom', timeSteps: object = None, timeStepsPerYear: object = None, brownianBridge: bool = False, antitheticVariate: bool = False, requiredSamples: object = None, requiredTolerance: object = None, maxSamples: object = None, seed: SupportsInt | SupportsIndex = 0) base.PricingEngine¶
Monte Carlo double barrier option pricing engine.
Monte Carlo double barrier option engine.
engine = ql.MCDoubleBarrierEngine(
process, timeSteps=50, requiredSamples=10000, seed=42,
)
AnalyticBinaryBarrierEngine¶
Analytic binary (one-touch) barrier option engine.
BinomialBarrierEngine¶
Binomial tree barrier engine with configurable tree type and discretization.
engine = ql.BinomialBarrierEngine(process, "crr", 200)
engine = ql.BinomialBarrierEngine(process, "crr", 200, discretization="dermankani")
FdHestonBarrierEngine¶
Finite-difference Heston barrier option engine.
FdHestonDoubleBarrierEngine¶
Finite-difference Heston double barrier option engine.
FdHestonRebateEngine¶
Finite-difference Heston rebate engine for barrier options.
AnalyticPartialTimeBarrierOptionEngine¶
Analytic engine for partial-time barrier options (Heynen-Kat).
AnalyticSoftBarrierEngine¶
Analytic engine for soft barrier options.
AnalyticTwoAssetBarrierEngine¶
Analytic engine for two-asset barrier options.
Asian Engines¶
AnalyticContinuousGeometricAveragePriceAsianEngine¶
- class pyquantlib.AnalyticContinuousGeometricAveragePriceAsianEngine¶
Bases:
PricingEngineAnalytic continuous geometric average price Asian engine.
- __init__(process: GeneralizedBlackScholesProcess) None¶
Constructs engine.
AnalyticDiscreteGeometricAveragePriceAsianEngine¶
- class pyquantlib.AnalyticDiscreteGeometricAveragePriceAsianEngine¶
Bases:
PricingEngineAnalytic discrete geometric average price Asian engine.
- __init__(process: GeneralizedBlackScholesProcess) None¶
Constructs engine.
TurnbullWakemanAsianEngine¶
- class pyquantlib.TurnbullWakemanAsianEngine¶
Bases:
PricingEngineTurnbull-Wakeman moment-matching discrete arithmetic Asian engine.
- __init__(process: GeneralizedBlackScholesProcess) None¶
Constructs TurnbullWakemanAsianEngine.
Moment-matching approximation for discrete arithmetic average price Asian options.
engine = ql.TurnbullWakemanAsianEngine(process)
MCDiscreteArithmeticAPEngine¶
- class pyquantlib.MCDiscreteArithmeticAPEngine(process: GeneralizedBlackScholesProcess, rngType: str = 'pseudorandom', brownianBridge: bool = True, antitheticVariate: bool = False, controlVariate: bool = False, requiredSamples: object = None, requiredTolerance: object = None, maxSamples: object = None, seed: SupportsInt | SupportsIndex = 0) base.PricingEngine¶
Bases:
Monte Carlo discrete arithmetic average price Asian engine.
Monte Carlo engine for discrete arithmetic average price Asian options.
engine = ql.MCDiscreteArithmeticAPEngine(
process, requiredSamples=100000, seed=42, controlVariate=True,
)
ChoiAsianEngine¶
Choi (2018) analytic discrete arithmetic Asian engine.
AnalyticDiscreteGeometricAverageStrikeAsianEngine¶
ContinuousArithmeticAsianLevyEngine¶
Levy (1992) continuous arithmetic average price Asian engine.
FdBlackScholesAsianEngine¶
Finite-difference Black-Scholes engine for discrete Asian options.
MCDiscreteArithmeticASEngine¶
Monte Carlo discrete arithmetic average strike Asian engine.
MCDiscreteGeometricAPEngine¶
Monte Carlo discrete geometric average price Asian engine.
MCDiscreteArithmeticAPHestonEngine¶
Monte Carlo discrete arithmetic Asian engine under Heston dynamics.
MCDiscreteGeometricAPHestonEngine¶
Monte Carlo discrete geometric Asian engine under Heston dynamics.
Lookback Engines¶
AnalyticContinuousFloatingLookbackEngine¶
- class pyquantlib.AnalyticContinuousFloatingLookbackEngine¶
Bases:
PricingEngineAnalytic engine for continuous floating-strike lookback options.
- __init__(process: GeneralizedBlackScholesProcess) None¶
AnalyticContinuousFixedLookbackEngine¶
- class pyquantlib.AnalyticContinuousFixedLookbackEngine¶
Bases:
PricingEngineAnalytic engine for continuous fixed-strike lookback options.
- __init__(process: GeneralizedBlackScholesProcess) None¶
AnalyticContinuousPartialFloatingLookbackEngine¶
- class pyquantlib.AnalyticContinuousPartialFloatingLookbackEngine¶
Bases:
PricingEngineAnalytic engine for continuous partial floating-strike lookback options.
- __init__(process: GeneralizedBlackScholesProcess) None¶
AnalyticContinuousPartialFixedLookbackEngine¶
- class pyquantlib.AnalyticContinuousPartialFixedLookbackEngine¶
Bases:
PricingEngineAnalytic engine for continuous partial fixed-strike lookback options.
- __init__(process: GeneralizedBlackScholesProcess) None¶
payoff = ql.FloatingTypePayoff(ql.Call)
exercise = ql.EuropeanExercise(expiry)
option = ql.ContinuousFloatingLookbackOption(100.0, payoff, exercise)
option.setPricingEngine(ql.AnalyticContinuousFloatingLookbackEngine(process))
print(option.NPV())
Cliquet Engines¶
AnalyticCliquetEngine¶
- class pyquantlib.AnalyticCliquetEngine¶
Bases:
PricingEngineAnalytic engine for cliquet options.
- __init__(process: GeneralizedBlackScholesProcess) None¶
engine = ql.AnalyticCliquetEngine(process)
cliquet.setPricingEngine(engine)
print(cliquet.NPV())
Exotic Engines¶
AnalyticCompoundOptionEngine¶
- class pyquantlib.AnalyticCompoundOptionEngine¶
Bases:
PricingEngineAnalytic engine for compound options (option on an option).
- __init__(process: GeneralizedBlackScholesProcess) None¶
AnalyticSimpleChooserEngine¶
- class pyquantlib.AnalyticSimpleChooserEngine¶
Bases:
PricingEngineAnalytic engine for simple chooser options.
- __init__(process: GeneralizedBlackScholesProcess) None¶
AnalyticComplexChooserEngine¶
- class pyquantlib.AnalyticComplexChooserEngine¶
Bases:
PricingEngineAnalytic engine for complex chooser options.
- __init__(process: GeneralizedBlackScholesProcess) None¶
AnalyticEuropeanMargrabeEngine¶
- class pyquantlib.AnalyticEuropeanMargrabeEngine¶
Bases:
PricingEngineAnalytic engine for European exchange (Margrabe) options.
- __init__(process1: GeneralizedBlackScholesProcess, process2: GeneralizedBlackScholesProcess, correlation: SupportsFloat | SupportsIndex) None¶
Takes two Black-Scholes-Merton processes and a correlation parameter.
engine = ql.AnalyticEuropeanMargrabeEngine(process1, process2, 0.5)
option.setPricingEngine(engine)
AnalyticAmericanMargrabeEngine¶
- class pyquantlib.AnalyticAmericanMargrabeEngine¶
Bases:
PricingEngineAnalytic engine for American exchange (Margrabe) options.
- __init__(process1: GeneralizedBlackScholesProcess, process2: GeneralizedBlackScholesProcess, correlation: SupportsFloat | SupportsIndex) None¶
Forward-Start Engines¶
ForwardEuropeanEngine¶
- class pyquantlib.ForwardEuropeanEngine¶
Bases:
PricingEngineForward-start European option engine (Black-Scholes).
- __init__(process: GeneralizedBlackScholesProcess) None¶
ForwardPerformanceEuropeanEngine¶
- class pyquantlib.ForwardPerformanceEuropeanEngine¶
Bases:
PricingEngineForward-start performance European option engine.
- __init__(process: GeneralizedBlackScholesProcess) None¶
option = ql.ForwardVanillaOption(1.0, reset_date, payoff, exercise)
option.setPricingEngine(ql.ForwardEuropeanEngine(process))
print(option.NPV())
Quanto Engines¶
QuantoVanillaEngine¶
- class pyquantlib.QuantoVanillaEngine¶
Bases:
PricingEngineQuanto European option engine (currency-adjusted Black-Scholes).
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(process: GeneralizedBlackScholesProcess, foreignRiskFreeRate: YieldTermStructureHandle, exchangeRateVolatility: BlackVolTermStructureHandle, correlation: QuoteHandle) -> None
__init__(process: GeneralizedBlackScholesProcess, foreignRiskFreeRate: base.YieldTermStructure, exchangeRateVolatility: base.BlackVolTermStructure, correlation: base.Quote) -> None
Constructs from shared_ptr objects (handles created internally).
Quanto European option engine (currency-adjusted Black-Scholes). Accepts explicit Handle arguments or raw objects (hidden handles).
engine = ql.QuantoVanillaEngine(
process, foreign_rate, fx_vol, correlation,
)
option.setPricingEngine(engine)
print(option.NPV(), option.qvega(), option.qrho(), option.qlambda())
Cap/Floor Engines¶
BlackCapFloorEngine¶
- class pyquantlib.BlackCapFloorEngine¶
Bases:
PricingEngineBlack-formula cap/floor engine.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(discountCurve: YieldTermStructureHandle, vol: SupportsFloat | SupportsIndex, dayCounter: DayCounter = <DayCounter: Actual/365 (Fixed)>, displacement: SupportsFloat | SupportsIndex = 0.0) -> None
Constructs with flat volatility (handle).
__init__(discountCurve: base.YieldTermStructure, vol: SupportsFloat | SupportsIndex, dayCounter: DayCounter = <DayCounter: Actual/365 (Fixed)>, displacement: SupportsFloat | SupportsIndex = 0.0) -> None
Constructs with flat volatility.
__init__(discountCurve: YieldTermStructureHandle, vol: QuoteHandle, dayCounter: DayCounter = <DayCounter: Actual/365 (Fixed)>, displacement: SupportsFloat | SupportsIndex = 0.0) -> None
Constructs with quote volatility (handle).
__init__(discountCurve: base.YieldTermStructure, vol: base.Quote, dayCounter: DayCounter = <DayCounter: Actual/365 (Fixed)>, displacement: SupportsFloat | SupportsIndex = 0.0) -> None
Constructs with quote volatility.
Black-formula cap/floor engine (lognormal volatility).
engine = ql.BlackCapFloorEngine(curve, 0.20)
cap.setPricingEngine(engine)
print(cap.NPV())
BachelierCapFloorEngine¶
- class pyquantlib.BachelierCapFloorEngine¶
Bases:
PricingEngineBachelier (normal) cap/floor engine.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(discountCurve: YieldTermStructureHandle, vol: SupportsFloat | SupportsIndex, dayCounter: DayCounter = <DayCounter: Actual/365 (Fixed)>) -> None
Constructs with flat normal volatility (handle).
__init__(discountCurve: base.YieldTermStructure, vol: SupportsFloat | SupportsIndex, dayCounter: DayCounter = <DayCounter: Actual/365 (Fixed)>) -> None
Constructs with flat normal volatility.
__init__(discountCurve: YieldTermStructureHandle, vol: QuoteHandle, dayCounter: DayCounter = <DayCounter: Actual/365 (Fixed)>) -> None
Constructs with quote normal volatility (handle).
__init__(discountCurve: base.YieldTermStructure, vol: base.Quote, dayCounter: DayCounter = <DayCounter: Actual/365 (Fixed)>) -> None
Constructs with quote normal volatility.
Bachelier (normal volatility) cap/floor engine.
engine = ql.BachelierCapFloorEngine(curve, 0.005)
cap.setPricingEngine(engine)
print(cap.NPV())
AnalyticCapFloorEngine¶
- class pyquantlib.AnalyticCapFloorEngine¶
Bases:
PricingEngineAnalytic cap/floor engine for affine short-rate models.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(model: base.AffineModel, termStructure: YieldTermStructureHandle = <YieldTermStructureHandle object at 0x7e30f080c970>) -> None
Constructs analytic cap/floor engine.
__init__(model: base.AffineModel, termStructure: base.YieldTermStructure) -> None
Constructs analytic cap/floor engine (handle created internally).
Analytic cap/floor engine for affine short-rate models (Hull-White, CIR, G2++).
TreeCapFloorEngine¶
- class pyquantlib.TreeCapFloorEngine¶
Bases:
PricingEngineLattice cap/floor engine for short-rate models.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(model: base.ShortRateModel, timeSteps: SupportsInt | SupportsIndex, termStructure: YieldTermStructureHandle = <YieldTermStructureHandle object at 0x7e30eeb6a9f0>) -> None
Constructs tree cap/floor engine with time steps.
__init__(model: base.ShortRateModel, timeGrid: TimeGrid, termStructure: YieldTermStructureHandle = <YieldTermStructureHandle object at 0x7e30eeb69a30>) -> None
Constructs tree cap/floor engine with time grid.
__init__(model: base.ShortRateModel, timeSteps: SupportsInt | SupportsIndex, termStructure: base.YieldTermStructure) -> None
Constructs tree cap/floor engine (handle created internally).
Lattice-based cap/floor engine for short-rate models.
Gaussian1dCapFloorEngine¶
- class pyquantlib.Gaussian1dCapFloorEngine¶
Bases:
PricingEngineGaussian 1-D cap/floor pricing engine.
- __init__(model: base.Gaussian1dModel, integrationPoints: SupportsInt | SupportsIndex = 64, stddevs: SupportsFloat | SupportsIndex = 7.0, extrapolatePayoff: bool = True, flatPayoffExtrapolation: bool = False, discountCurve: YieldTermStructureHandle = <YieldTermStructureHandle object at 0x7e30f001cd70>) None¶
Constructs Gaussian 1-D cap/floor engine.
Gaussian 1-D model cap/floor engine with numerical integration.
model = ql.Gsr(curve, [ql.Date(15, 1, 2025)], [0.01], 0.01)
engine = ql.Gaussian1dCapFloorEngine(model, integrationPoints=64)
cap.setPricingEngine(engine)
print(cap.NPV())
YoY Inflation Cap/Floor Engines¶
YoYInflationBlackCapFloorEngine¶
- class pyquantlib.YoYInflationBlackCapFloorEngine¶
Bases:
PricingEngineBlack-formula engine for YoY inflation cap/floor.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(index: YoYInflationIndex, volatility: YoYOptionletVolatilitySurfaceHandle, nominalTermStructure: YieldTermStructureHandle) -> None
Constructs a Black YoY inflation cap/floor engine.
__init__(index: YoYInflationIndex, volatility: base.YoYOptionletVolatilitySurface, nominalTermStructure: YieldTermStructureHandle) -> None
Constructs with vol surface (handle created internally).
__init__(index: YoYInflationIndex, volatility: YoYOptionletVolatilitySurfaceHandle, nominalTermStructure: base.YieldTermStructure) -> None
Constructs with nominal curve (handle created internally).
__init__(index: YoYInflationIndex, volatility: base.YoYOptionletVolatilitySurface, nominalTermStructure: base.YieldTermStructure) -> None
Constructs with both handles created internally.
Black-formula engine for YoY inflation caps and floors (lognormal volatility).
engine = ql.YoYInflationBlackCapFloorEngine(yoy_index, yoy_vol_handle, curve_handle)
cap.setPricingEngine(engine)
print(cap.NPV())
YoYInflationUnitDisplacedBlackCapFloorEngine¶
- class pyquantlib.YoYInflationUnitDisplacedBlackCapFloorEngine¶
Bases:
PricingEngineUnit-displaced Black engine for YoY inflation cap/floor.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(index: YoYInflationIndex, volatility: YoYOptionletVolatilitySurfaceHandle, nominalTermStructure: YieldTermStructureHandle) -> None
Constructs a unit-displaced Black YoY inflation cap/floor engine.
__init__(index: YoYInflationIndex, volatility: base.YoYOptionletVolatilitySurface, nominalTermStructure: base.YieldTermStructure) -> None
Constructs with both handles created internally.
Unit-displaced Black-formula engine for YoY inflation caps and floors.
YoYInflationBachelierCapFloorEngine¶
- class pyquantlib.YoYInflationBachelierCapFloorEngine¶
Bases:
PricingEngineBachelier (normal) engine for YoY inflation cap/floor.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(index: YoYInflationIndex, volatility: YoYOptionletVolatilitySurfaceHandle, nominalTermStructure: YieldTermStructureHandle) -> None
Constructs a Bachelier YoY inflation cap/floor engine.
__init__(index: YoYInflationIndex, volatility: base.YoYOptionletVolatilitySurface, nominalTermStructure: base.YieldTermStructure) -> None
Constructs with both handles created internally.
Bachelier (normal volatility) engine for YoY inflation caps and floors.
Bond Engines¶
DiscountingBondEngine¶
- class pyquantlib.DiscountingBondEngine¶
Bases:
engineDiscounting engine for bonds.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(discountCurve: YieldTermStructureHandle = <YieldTermStructureHandle object at 0x7e30ee54e470>, includeSettlementDateFlows: bool | None = None) -> None
Constructs discounting bond engine.
__init__(discountCurve: base.YieldTermStructure, includeSettlementDateFlows: bool | None = None) -> None
Constructs discounting bond engine from term structure.
- discountCurve() YieldTermStructureHandle¶
Returns the discount curve handle.
engine = ql.DiscountingBondEngine(curve_handle)
bond.setPricingEngine(engine)
print(bond.cleanPrice())
Convertible Bond Engines¶
BinomialConvertibleEngine¶
- class pyquantlib.BinomialConvertibleEngine(*args, **kwargs)¶
Bases:
Overloaded function.
BinomialConvertibleEngine(process: GeneralizedBlackScholesProcess, treeType: str, timeSteps: SupportsInt | SupportsIndex, creditSpread: base.Quote, dividends: collections.abc.Sequence[base.Dividend] = []) -> base.PricingEngine
Binomial Tsiveriotis-Fernandes engine for convertible bonds.
- Parameters:
process – Black-Scholes process for the underlying equity
treeType – Tree type - one of: ‘jr’ or ‘jarrowrudd’: Jarrow-Rudd ‘crr’ or ‘coxrossrubinstein’: Cox-Ross-Rubinstein ‘eqp’ or ‘additiveeqp’: Additive equal probabilities ‘trigeorgis’: Trigeorgis ‘tian’: Tian ‘lr’ or ‘leisenreimer’: Leisen-Reimer ‘joshi’ or ‘joshi4’: Joshi
timeSteps – Number of time steps
creditSpread – Credit spread quote
dividends – Dividend schedule (optional)
BinomialConvertibleEngine(process: GeneralizedBlackScholesProcess, treeType: str, timeSteps: SupportsInt | SupportsIndex, creditSpread: QuoteHandle, dividends: collections.abc.Sequence[base.Dividend] = []) -> base.PricingEngine
Binomial Tsiveriotis-Fernandes engine for convertible bonds (Handle version).
Tsiveriotis-Fernandes binomial lattice engine for convertible bonds.
engine = ql.BinomialConvertibleEngine(process, "crr", 801)
bond.setPricingEngine(engine)
print(bond.NPV())
Tree types: jr, crr, eqp, trigeorgis, tian, lr, joshi
Also accepts an optional creditSpread parameter:
engine = ql.BinomialConvertibleEngine(process, "crr", 801, creditSpread=spread)
Credit Engines¶
MidPointCdsEngine¶
- class pyquantlib.MidPointCdsEngine¶
Bases:
PricingEngineMid-point engine for credit default swaps.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(probability: DefaultProbabilityTermStructureHandle, recoveryRate: SupportsFloat | SupportsIndex, discountCurve: YieldTermStructureHandle, includeSettlementDateFlows: bool | None = None) -> None
Constructs from handles.
__init__(probability: base.DefaultProbabilityTermStructure, recoveryRate: SupportsFloat | SupportsIndex, discountCurve: base.YieldTermStructure, includeSettlementDateFlows: bool | None = None) -> None
Constructs from term structures (handles created internally).
Mid-point CDS pricing engine.
engine = ql.MidPointCdsEngine(default_curve, 0.4, discount_curve)
cds.setPricingEngine(engine)
print(cds.NPV())
IsdaCdsEngine¶
- class pyquantlib.IsdaCdsEngine¶
Bases:
PricingEngineISDA-compliant CDS engine.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(probability: DefaultProbabilityTermStructureHandle, recoveryRate: SupportsFloat | SupportsIndex, discountCurve: YieldTermStructureHandle, includeSettlementDateFlows: bool | None = None, numericalFix: IsdaNumericalFix = <IsdaNumericalFix.Taylor: 1>, accrualBias: IsdaAccrualBias = <IsdaAccrualBias.HalfDayBias: 0>, forwardsInCouponPeriod: IsdaForwardsInCouponPeriod = <IsdaForwardsInCouponPeriod.Piecewise: 1>) -> None
Constructs from handles.
__init__(probability: base.DefaultProbabilityTermStructure, recoveryRate: SupportsFloat | SupportsIndex, discountCurve: base.YieldTermStructure, includeSettlementDateFlows: bool | None = None, numericalFix: IsdaNumericalFix = <IsdaNumericalFix.Taylor: 1>, accrualBias: IsdaAccrualBias = <IsdaAccrualBias.HalfDayBias: 0>, forwardsInCouponPeriod: IsdaForwardsInCouponPeriod = <IsdaForwardsInCouponPeriod.Piecewise: 1>) -> None
Constructs from term structures (handles created internally).
- isdaCreditCurve() DefaultProbabilityTermStructureHandle¶
ISDA credit curve.
- isdaRateCurve() YieldTermStructureHandle¶
ISDA rate curve.
ISDA-standard CDS pricing engine.
engine = ql.IsdaCdsEngine(default_curve, 0.4, discount_curve)
cds.setPricingEngine(engine)
print(cds.NPV())
Enum |
Values |
|---|---|
|
|
|
|
|
|
Swap Engines¶
DiscountingSwapEngine¶
- class pyquantlib.DiscountingSwapEngine¶
Bases:
engineDiscounting engine for swaps.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(discountCurve: YieldTermStructureHandle, includeSettlementDateFlows: bool | None = None, settlementDate: Date = <Date: null date>, npvDate: Date = <Date: null date>) -> None
Constructs discounting swap engine.
__init__(discountCurve: base.YieldTermStructure, includeSettlementDateFlows: bool | None = None, settlementDate: Date = <Date: null date>, npvDate: Date = <Date: null date>) -> None
Constructs discounting swap engine from term structure.
- discountCurve() YieldTermStructureHandle¶
Returns the discount curve handle.
Bond Functions¶
BondFunctions¶
- class pyquantlib.BondFunctions¶
Bases:
pybind11_objectStatic bond analytics functions.
- static accrualPeriod(bond: Bond, settlementDate: Date = <Date: null date>) float¶
Accrual period as a year fraction.
- static accrualStartDate(bond: Bond, settlementDate: Date = <Date: null date>) Date¶
Accrual start date.
- static accruedPeriod(bond: Bond, settlementDate: Date = <Date: null date>) float¶
Accrued period as a year fraction.
- static basisPointValue(bond: Bond, yield: SupportsFloat | SupportsIndex, dayCounter: DayCounter, compounding: Compounding, frequency: Frequency, settlementDate: Date = <Date: null date>) float¶
Basis point value (DV01).
- static bondYield(bond: Bond, price: BondPrice, dayCounter: DayCounter, compounding: Compounding, frequency: Frequency, settlementDate: Date = <Date: null date>, accuracy: SupportsFloat | SupportsIndex = 1e-10, maxIterations: SupportsInt | SupportsIndex = 100, guess: SupportsFloat | SupportsIndex = 0.05) float¶
Bond yield (IRR) from price.
- static bps(bond: Bond, discountCurve: base.YieldTermStructure, settlementDate: Date = <Date: null date>) float¶
Basis point sensitivity from discount curve.
- static cleanPrice(bond: Bond, discountCurve: base.YieldTermStructure, settlementDate: Date = <Date: null date>) float¶
Clean price from discount curve.
- static cleanPriceFromYield(bond: Bond, yield: SupportsFloat | SupportsIndex, dayCounter: DayCounter, compounding: Compounding, frequency: Frequency, settlementDate: Date = <Date: null date>) float¶
Clean price from yield.
- static convexity(bond: Bond, yield: SupportsFloat | SupportsIndex, dayCounter: DayCounter, compounding: Compounding, frequency: Frequency, settlementDate: Date = <Date: null date>) float¶
Bond convexity.
- static dirtyPrice(bond: Bond, discountCurve: base.YieldTermStructure, settlementDate: Date = <Date: null date>) float¶
Dirty price from discount curve.
- static dirtyPriceFromYield(bond: Bond, yield: SupportsFloat | SupportsIndex, dayCounter: DayCounter, compounding: Compounding, frequency: Frequency, settlementDate: Date = <Date: null date>) float¶
Dirty price from yield.
- static duration(bond: Bond, yield: SupportsFloat | SupportsIndex, dayCounter: DayCounter, compounding: Compounding, frequency: Frequency, type: DurationType = <DurationType.Modified: 2>, settlementDate: Date = <Date: null date>) float¶
Bond duration.
- static isTradable(bond: Bond, settlementDate: Date = <Date: null date>) bool¶
Whether the bond is tradable at the given date.
- static nextCashFlowAmount(bond: Bond, refDate: Date = <Date: null date>) float¶
Amount of the next cash flow.
- static nextCashFlowDate(bond: Bond, refDate: Date = <Date: null date>) Date¶
Date of the next cash flow.
- static nextCouponRate(bond: Bond, settlementDate: Date = <Date: null date>) float¶
Next coupon rate.
- static previousCashFlowAmount(bond: Bond, refDate: Date = <Date: null date>) float¶
Amount of the previous cash flow.
- static previousCashFlowDate(bond: Bond, refDate: Date = <Date: null date>) Date¶
Date of the previous cash flow.
- static previousCouponRate(bond: Bond, settlementDate: Date = <Date: null date>) float¶
Previous coupon rate.
- static yieldValueBasisPoint(bond: Bond, yield: SupportsFloat | SupportsIndex, dayCounter: DayCounter, compounding: Compounding, frequency: Frequency, settlementDate: Date = <Date: null date>) float¶
Yield value of a basis point.
- static zSpread(bond: Bond, price: BondPrice, discountCurve: base.YieldTermStructure, dayCounter: DayCounter, compounding: Compounding, frequency: Frequency, settlementDate: Date = <Date: null date>, accuracy: SupportsFloat | SupportsIndex = 1e-10, maxIterations: SupportsInt | SupportsIndex = 100, guess: SupportsFloat | SupportsIndex = 0.0) float¶
Z-spread over a discount curve.
- __init__(*args, **kwargs)¶
Static functions for bond analytics.
Function |
Description |
|---|---|
|
Clean price from yield |
|
Dirty price from yield |
|
Basis point sensitivity |
|
Yield from clean price |
|
Duration (Modified, Macaulay, or Simple) |
|
Convexity |
|
Basis point value |
|
Yield value of a basis point |
|
Z-spread |
rate = ql.InterestRate(0.05, ql.Actual365Fixed(), ql.Compounded, ql.Annual)
print(ql.BondFunctions.cleanPrice(bond, rate))
print(ql.BondFunctions.duration(bond, rate, ql.DurationType.Modified))
print(ql.BondFunctions.convexity(bond, rate))
Variance Swap Engines¶
ReplicatingVarianceSwapEngine¶
- class pyquantlib.ReplicatingVarianceSwapEngine¶
Bases:
PricingEngineVariance swap engine using replicating portfolio.
- __init__(process: GeneralizedBlackScholesProcess, dk: SupportsFloat | SupportsIndex = 5.0, callStrikes: collections.abc.Sequence[SupportsFloat | SupportsIndex] = [], putStrikes: collections.abc.Sequence[SupportsFloat | SupportsIndex] = []) None¶
Constructs the replicating variance swap engine.
Calculators¶
BlackCalculator¶
- class pyquantlib.BlackCalculator¶
Bases:
pybind11_objectBlack 1976 calculator for option pricing and Greeks.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(payoff: base.StrikedTypePayoff, forward: SupportsFloat | SupportsIndex, stdDev: SupportsFloat | SupportsIndex, discount: SupportsFloat | SupportsIndex = 1.0) -> None
Constructs from payoff, forward, stdDev, and discount.
__init__(optionType: OptionType, strike: SupportsFloat | SupportsIndex, forward: SupportsFloat | SupportsIndex, stdDev: SupportsFloat | SupportsIndex, discount: SupportsFloat | SupportsIndex = 1.0) -> None
Constructs from option type, strike, forward, stdDev, and discount.
- delta(spot: SupportsFloat | SupportsIndex) float¶
Sensitivity to change in the underlying spot price.
- dividendRho(maturity: SupportsFloat | SupportsIndex) float¶
Sensitivity to dividend/growth rate.
- elasticity(spot: SupportsFloat | SupportsIndex) float¶
Percent sensitivity to percent change in spot price.
- gamma(spot: SupportsFloat | SupportsIndex) float¶
Second order derivative w.r.t. spot price.
- rho(maturity: SupportsFloat | SupportsIndex) float¶
Sensitivity to discounting rate.
- theta(spot: SupportsFloat | SupportsIndex, maturity: SupportsFloat | SupportsIndex) float¶
Sensitivity to time to maturity.
- thetaPerDay(spot: SupportsFloat | SupportsIndex, maturity: SupportsFloat | SupportsIndex) float¶
Sensitivity to time to maturity per day (365-day basis).
- vega(maturity: SupportsFloat | SupportsIndex) float¶
Sensitivity to volatility.
Black 1976 pricing and Greeks calculator. Provides delta, gamma, theta, vega, rho, and more.
calc = ql.BlackCalculator(payoff, forward, stdDev, discount)
print(calc.value(), calc.delta(spot), calc.gamma(spot), calc.vega(T))
BachelierCalculator¶
- class pyquantlib.BachelierCalculator¶
Bases:
pybind11_objectBachelier (normal-volatility) calculator for option pricing and Greeks.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(payoff: base.StrikedTypePayoff, forward: SupportsFloat | SupportsIndex, stdDev: SupportsFloat | SupportsIndex, discount: SupportsFloat | SupportsIndex = 1.0) -> None
Constructs from payoff, forward, stdDev, and discount.
__init__(optionType: OptionType, strike: SupportsFloat | SupportsIndex, forward: SupportsFloat | SupportsIndex, stdDev: SupportsFloat | SupportsIndex, discount: SupportsFloat | SupportsIndex = 1.0) -> None
Constructs from option type, strike, forward, stdDev, and discount.
- delta(spot: SupportsFloat | SupportsIndex) float¶
Sensitivity to change in the underlying spot price.
- dividendRho(maturity: SupportsFloat | SupportsIndex) float¶
Sensitivity to dividend/growth rate.
- elasticity(spot: SupportsFloat | SupportsIndex) float¶
Percent sensitivity to percent change in spot price.
- gamma(spot: SupportsFloat | SupportsIndex) float¶
Second order derivative w.r.t. spot price.
- rho(maturity: SupportsFloat | SupportsIndex) float¶
Sensitivity to discounting rate.
- theta(spot: SupportsFloat | SupportsIndex, maturity: SupportsFloat | SupportsIndex) float¶
Sensitivity to time to maturity.
- thetaPerDay(spot: SupportsFloat | SupportsIndex, maturity: SupportsFloat | SupportsIndex) float¶
Sensitivity to time to maturity per day (365-day basis).
- vega(maturity: SupportsFloat | SupportsIndex) float¶
Sensitivity to volatility.
Bachelier (normal-volatility) pricing and Greeks calculator. Same API as BlackCalculator.
calc = ql.BachelierCalculator(payoff, forward, stdDev, discount)
print(calc.value(), calc.delta(spot), calc.gamma(spot), calc.vega(T))
Functions¶
Black-76 (Lognormal)¶
Function |
Description |
|---|---|
|
Option price |
|
Implied volatility × √T |
|
Fast implied vol approximation |
|
Vega / √T |
|
Vega |
|
Delta (forward) |
|
N(d2) |
|
N(d1) |
Bachelier (Normal)¶
Function |
Description |
|---|---|
|
Option price |
|
Implied vol |
|
Vega component |
import pyquantlib as ql
forward = 100.0
strike = 100.0
vol = 0.20
T = 1.0
stdDev = vol * (T ** 0.5)
price = ql.blackFormula(ql.OptionType.Call, strike, forward, stdDev)
impliedStdDev = ql.blackFormulaImpliedStdDev(ql.OptionType.Call, strike, forward, price)
Note
The abstract PricingEngine base class is available in pyquantlib.base for custom engine implementations.