Term Structures Module

Yield Term Structures

FlatForward

class pyquantlib.FlatForward

Bases: YieldTermStructure

Flat interest-rate curve.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(referenceDate: Date, forward: SupportsFloat | SupportsIndex, dayCounter: DayCounter, compounding: Compounding = <Compounding.Continuous: 2>, frequency: Frequency = <Frequency.Annual: 1>) -> None

Constructs from reference date and forward rate.

  1. __init__(referenceDate: Date, forward: QuoteHandle, dayCounter: DayCounter, compounding: Compounding = <Compounding.Continuous: 2>, frequency: Frequency = <Frequency.Annual: 1>) -> None

Constructs from reference date and quote handle.

  1. __init__(referenceDate: Date, forward: base.Quote, dayCounter: DayCounter, compounding: Compounding = <Compounding.Continuous: 2>, frequency: Frequency = <Frequency.Annual: 1>) -> None

Constructs from reference date and quote (handle created internally).

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, forward: SupportsFloat | SupportsIndex, dayCounter: DayCounter, compounding: Compounding = <Compounding.Continuous: 2>, frequency: Frequency = <Frequency.Annual: 1>) -> None

Constructs from settlement days and forward rate.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, forward: QuoteHandle, dayCounter: DayCounter, compounding: Compounding = <Compounding.Continuous: 2>, frequency: Frequency = <Frequency.Annual: 1>) -> None

Constructs from settlement days and quote handle.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, forward: base.Quote, dayCounter: DayCounter, compounding: Compounding = <Compounding.Continuous: 2>, frequency: Frequency = <Frequency.Annual: 1>) -> None

Constructs from settlement days and quote (handle created internally).

compounding() Compounding

Returns the compounding convention.

compoundingFrequency() Frequency

Returns the compounding frequency.

today = ql.Date(15, 6, 2025)
dc = ql.Actual365Fixed()

flat = ql.FlatForward(today, 0.05, dc)
print(flat.discount(1.0))

# Using a quote (hidden handle, for dynamic updates)
rate_quote = ql.SimpleQuote(0.05)
flat = ql.FlatForward(today, rate_quote, dc)
rate_quote.setValue(0.06)  # Curve updates automatically

YieldTermStructureHandle

class pyquantlib.YieldTermStructureHandle

Bases: pybind11_object

Handle to YieldTermStructure.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__() -> None

Creates an empty handle.

  1. __init__(ptr: object, registerAsObserver: bool = True) -> None

Creates a handle linked to the given object.

asObservable() Observable

Converts to Observable for observer registration.

Returns the shared_ptr to the current object link.

empty() bool

Returns true if the handle is empty.

get() base.YieldTermStructure

Returns the underlying shared_ptr. Raises error if empty.

RelinkableYieldTermStructureHandle

class pyquantlib.RelinkableYieldTermStructureHandle

Bases: YieldTermStructureHandle

Relinkable handle to YieldTermStructure.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__() -> None

Creates an empty relinkable handle.

  1. __init__(ptr: object, registerAsObserver: bool = True) -> None

Creates a relinkable handle linked to the given object.

linkTo(ptr: object = None, registerAsObserver: bool = True) None

Links the handle to a new object instance. Notifies observers.

Rate Helpers

Pillar

class pyquantlib.Pillar

Bases: pybind11_object

Pillar date calculation types for rate helpers.

class Choice

Bases: pybind11_object

Pillar choice for rate helper.

Members:

MaturityDate : Use the instrument maturity date.

LastRelevantDate : Use the last relevant date for pricing.

CustomDate : Use a custom pillar date.

__init__(value: SupportsInt | SupportsIndex) None
CustomDate = <Choice.CustomDate: 2>
LastRelevantDate = <Choice.LastRelevantDate: 1>
MaturityDate = <Choice.MaturityDate: 0>
Pillar.Choice.name -> str
property value
__init__(*args, **kwargs)

RateHelper

class pyquantlib.base.RateHelper

Bases: Observer, Observable

Rate helper for bootstrapping yield curves.

__init__(*args, **kwargs)
earliestDate() Date

Returns the earliest date.

impliedQuote() float

Returns the implied quote from the term structure.

latestDate() Date

Returns the latest date.

latestRelevantDate() Date

Returns the latest relevant date.

maturityDate() Date

Returns the maturity date.

pillarDate() Date

Returns the pillar date.

quote() QuoteHandle

Returns the market quote handle.

quoteError() float

Returns the difference between market and implied quotes.

RelativeDateRateHelper

class pyquantlib.base.RelativeDateRateHelper

Bases: RateHelper

Rate helper with date schedule relative to evaluation date.

__init__(*args, **kwargs)

Rate helper with date schedule that updates when the evaluation date changes. Base class for DepositRateHelper, FraRateHelper, SwapRateHelper, and OISRateHelper.

DepositRateHelper

class pyquantlib.DepositRateHelper

Bases: RelativeDateRateHelper

Rate helper for bootstrapping over deposit rates.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(rate: SupportsFloat | SupportsIndex, index: IborIndex) -> None

Constructs from rate and Ibor index.

  1. __init__(rate: QuoteHandle, index: IborIndex) -> None

Constructs from quote handle and Ibor index.

  1. __init__(rate: base.Quote, index: IborIndex) -> None

Constructs from quote and Ibor index (handle created internally).

  1. __init__(rate: SupportsFloat | SupportsIndex, tenor: Period, fixingDays: SupportsInt | SupportsIndex, calendar: Calendar, convention: BusinessDayConvention, endOfMonth: bool, dayCounter: DayCounter) -> None

Constructs from rate and explicit market conventions.

Rate helper for bootstrapping over deposit rates.

euribor6m = ql.Euribor6M(curve_handle)
helper = ql.DepositRateHelper(0.032, euribor6m)

FraRateHelper

class pyquantlib.FraRateHelper

Bases: RelativeDateRateHelper

Rate helper for bootstrapping over FRA rates.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(rate: SupportsFloat | SupportsIndex, monthsToStart: SupportsInt | SupportsIndex, index: IborIndex, pillar: Pillar.Choice = <Choice.LastRelevantDate: 1>, customPillarDate: Date = <Date: null date>, useIndexedCoupon: bool = True) -> None

Constructs from rate, months to start, and Ibor index.

  1. __init__(rate: QuoteHandle, monthsToStart: SupportsInt | SupportsIndex, index: IborIndex, pillar: Pillar.Choice = <Choice.LastRelevantDate: 1>, customPillarDate: Date = <Date: null date>, useIndexedCoupon: bool = True) -> None

Constructs from quote handle, months to start, and Ibor index.

  1. __init__(rate: base.Quote, monthsToStart: SupportsInt | SupportsIndex, index: IborIndex, pillar: Pillar.Choice = <Choice.LastRelevantDate: 1>, customPillarDate: Date = <Date: null date>, useIndexedCoupon: bool = True) -> None

Constructs from quote, months to start, and Ibor index (handle created internally).

  1. __init__(rate: SupportsFloat | SupportsIndex, periodToStart: Period, index: IborIndex, pillar: Pillar.Choice = <Choice.LastRelevantDate: 1>, customPillarDate: Date = <Date: null date>, useIndexedCoupon: bool = True) -> None

Constructs from rate, period to start, and Ibor index.

Rate helper for bootstrapping over FRA rates.

helper = ql.FraRateHelper(0.035, 3, euribor6m)  # 3x9 FRA

SwapRateHelper

class pyquantlib.SwapRateHelper

Bases: RelativeDateRateHelper

Rate helper for bootstrapping over swap rates.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(rate: SupportsFloat | SupportsIndex, tenor: Period, calendar: Calendar, fixedFrequency: Frequency, fixedConvention: BusinessDayConvention, fixedDayCount: DayCounter, iborIndex: IborIndex, spread: QuoteHandle = <QuoteHandle object at 0x7f25341b2b70>, fwdStart: Period = <Period: 0D>, discountingCurve: YieldTermStructureHandle = <YieldTermStructureHandle object at 0x7f25341b2af0>, settlementDays: object = None, pillar: Pillar.Choice = <Choice.LastRelevantDate: 1>, customPillarDate: Date = <Date: null date>, endOfMonth: bool = False) -> None

Constructs from rate, tenor, and market conventions.

  1. __init__(rate: QuoteHandle, tenor: Period, calendar: Calendar, fixedFrequency: Frequency, fixedConvention: BusinessDayConvention, fixedDayCount: DayCounter, iborIndex: IborIndex, spread: QuoteHandle = <QuoteHandle object at 0x7f25341b2e30>, fwdStart: Period = <Period: 0D>, discountingCurve: YieldTermStructureHandle = <YieldTermStructureHandle object at 0x7f25341b2db0>, settlementDays: object = None, pillar: Pillar.Choice = <Choice.LastRelevantDate: 1>, customPillarDate: Date = <Date: null date>, endOfMonth: bool = False) -> None

Constructs from quote handle, tenor, and market conventions.

  1. __init__(rate: base.Quote, tenor: Period, calendar: Calendar, fixedFrequency: Frequency, fixedConvention: BusinessDayConvention, fixedDayCount: DayCounter, iborIndex: IborIndex, spread: QuoteHandle = <QuoteHandle object at 0x7f25341b3130>, fwdStart: Period = <Period: 0D>, discountingCurve: YieldTermStructureHandle = <YieldTermStructureHandle object at 0x7f25341b30b0>, settlementDays: object = None, pillar: Pillar.Choice = <Choice.LastRelevantDate: 1>, customPillarDate: Date = <Date: null date>, endOfMonth: bool = False) -> None

Constructs from quote, tenor, and market conventions (handle created internally).

forwardStart() Period

Returns the forward start period.

spread() float

Returns the spread.

swap() QuantLib::VanillaSwap

Returns the underlying swap.

Rate helper for bootstrapping over swap rates.

helper = ql.SwapRateHelper(
    0.04, ql.Period(5, ql.Years), ql.TARGET(),
    ql.Annual, ql.Unadjusted,
    ql.Thirty360(ql.Thirty360.BondBasis), euribor6m
)
swap = helper.swap()  # access underlying VanillaSwap

OISRateHelper

class pyquantlib.OISRateHelper

Bases: RelativeDateRateHelper

Rate helper for bootstrapping over OIS rates.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, tenor: Period, fixedRate: SupportsFloat | SupportsIndex, overnightIndex: OvernightIndex, discountingCurve: YieldTermStructureHandle = <YieldTermStructureHandle object at 0x7f25341b3570>, telescopicValueDates: bool = False, paymentLag: SupportsInt | SupportsIndex = 0, paymentConvention: BusinessDayConvention = <BusinessDayConvention.Following: 0>, paymentFrequency: Frequency = <Frequency.Annual: 1>, paymentCalendar: object = None, forwardStart: Period = <Period: 0D>, overnightSpread: SupportsFloat | SupportsIndex = 0.0, pillar: Pillar.Choice = <Choice.LastRelevantDate: 1>, customPillarDate: Date = <Date: null date>, averagingMethod: RateAveraging.Type = <Type.Compound: 1>, lookbackDays: object = None, lockoutDays: SupportsInt | SupportsIndex = 0, applyObservationShift: bool = False) -> None

Constructs from settlement days, tenor, and overnight index.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, tenor: Period, fixedRate: QuoteHandle, overnightIndex: OvernightIndex, discountingCurve: YieldTermStructureHandle = <YieldTermStructureHandle object at 0x7f25341b37b0>, telescopicValueDates: bool = False, paymentLag: SupportsInt | SupportsIndex = 0, paymentConvention: BusinessDayConvention = <BusinessDayConvention.Following: 0>, paymentFrequency: Frequency = <Frequency.Annual: 1>, paymentCalendar: object = None, forwardStart: Period = <Period: 0D>, overnightSpread: SupportsFloat | SupportsIndex = 0.0, pillar: Pillar.Choice = <Choice.LastRelevantDate: 1>, customPillarDate: Date = <Date: null date>, averagingMethod: RateAveraging.Type = <Type.Compound: 1>, lookbackDays: object = None, lockoutDays: SupportsInt | SupportsIndex = 0, applyObservationShift: bool = False) -> None

Constructs from settlement days, tenor, and quote handle.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, tenor: Period, fixedRate: base.Quote, overnightIndex: OvernightIndex, discountingCurve: YieldTermStructureHandle = <YieldTermStructureHandle object at 0x7f25341b3bb0>, telescopicValueDates: bool = False, paymentLag: SupportsInt | SupportsIndex = 0, paymentConvention: BusinessDayConvention = <BusinessDayConvention.Following: 0>, paymentFrequency: Frequency = <Frequency.Annual: 1>, paymentCalendar: object = None, forwardStart: Period = <Period: 0D>, overnightSpread: SupportsFloat | SupportsIndex = 0.0, pillar: Pillar.Choice = <Choice.LastRelevantDate: 1>, customPillarDate: Date = <Date: null date>, averagingMethod: RateAveraging.Type = <Type.Compound: 1>, lookbackDays: object = None, lockoutDays: SupportsInt | SupportsIndex = 0, applyObservationShift: bool = False) -> None

Constructs from settlement days, tenor, and quote (handle created internally).

  1. __init__(startDate: Date, endDate: Date, fixedRate: SupportsFloat | SupportsIndex, overnightIndex: OvernightIndex, discountingCurve: YieldTermStructureHandle = <YieldTermStructureHandle object at 0x7f25341b3ef0>, telescopicValueDates: bool = False, paymentLag: SupportsInt | SupportsIndex = 0, paymentConvention: BusinessDayConvention = <BusinessDayConvention.Following: 0>, paymentFrequency: Frequency = <Frequency.Annual: 1>, paymentCalendar: object = None, overnightSpread: SupportsFloat | SupportsIndex = 0.0, pillar: Pillar.Choice = <Choice.LastRelevantDate: 1>, customPillarDate: Date = <Date: null date>, averagingMethod: RateAveraging.Type = <Type.Compound: 1>, lookbackDays: object = None, lockoutDays: SupportsInt | SupportsIndex = 0, applyObservationShift: bool = False) -> None

Constructs from start date, end date, rate, and overnight index.

  1. __init__(startDate: Date, endDate: Date, fixedRate: QuoteHandle, overnightIndex: OvernightIndex, discountingCurve: YieldTermStructureHandle = <YieldTermStructureHandle object at 0x7f25341c01b0>, telescopicValueDates: bool = False, paymentLag: SupportsInt | SupportsIndex = 0, paymentConvention: BusinessDayConvention = <BusinessDayConvention.Following: 0>, paymentFrequency: Frequency = <Frequency.Annual: 1>, paymentCalendar: object = None, overnightSpread: SupportsFloat | SupportsIndex = 0.0, pillar: Pillar.Choice = <Choice.LastRelevantDate: 1>, customPillarDate: Date = <Date: null date>, averagingMethod: RateAveraging.Type = <Type.Compound: 1>, lookbackDays: object = None, lockoutDays: SupportsInt | SupportsIndex = 0, applyObservationShift: bool = False) -> None

Constructs from start date, end date, quote handle, and overnight index.

swap() QuantLib::OvernightIndexedSwap

Returns the underlying OIS swap.

Rate helper for bootstrapping over OIS rates.

overnight_index = ql.OvernightIndex("ESTR", 0, ql.EURCurrency(),
                                     ql.TARGET(), ql.Actual360(), curve)
helper = ql.OISRateHelper(2, ql.Period(1, ql.Years), 0.035, overnight_index)

# With explicit averaging method
helper = ql.OISRateHelper(
    2, ql.Period(1, ql.Years), 0.035, overnight_index,
    averagingMethod=ql.RateAveraging.Type.Simple,
)

BondHelper

class pyquantlib.BondHelper

Bases: RateHelper

Bond helper for bootstrapping yield curves.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(price: QuoteHandle, bond: QuantLib::Bond, priceType: object = None) -> None

Constructs from price handle and bond.

  1. __init__(price: base.Quote, bond: QuantLib::Bond, priceType: object = None) -> None

Constructs from quote and bond (handle created internally).

bond() QuantLib::Bond

Returns the underlying bond.

priceType() QuantLib::Bond::Price::Type

Returns the price type (Clean or Dirty).

Bond helper for bootstrapping yield curves from a pre-constructed bond.

bond = ql.FixedRateBond(3, 100.0, schedule, [0.04], dc)
helper = ql.BondHelper(ql.SimpleQuote(101.0), bond)

FixedRateBondHelper

class pyquantlib.FixedRateBondHelper

Bases: BondHelper

Fixed-coupon bond helper for bootstrapping yield curves.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(price: QuoteHandle, settlementDays: SupportsInt | SupportsIndex, faceAmount: SupportsFloat | SupportsIndex, schedule: Schedule, coupons: collections.abc.Sequence[SupportsFloat | SupportsIndex], dayCounter: DayCounter, paymentConvention: BusinessDayConvention = <BusinessDayConvention.Following: 0>, redemption: SupportsFloat | SupportsIndex = 100.0, issueDate: Date = <Date: null date>, paymentCalendar: object = None, exCouponPeriod: Period = <Period: 0D>, exCouponCalendar: object = None, exCouponConvention: BusinessDayConvention = <BusinessDayConvention.Unadjusted: 4>, exCouponEndOfMonth: bool = False, priceType: object = None) -> None

Constructs from price handle and bond parameters.

  1. __init__(price: base.Quote, settlementDays: SupportsInt | SupportsIndex, faceAmount: SupportsFloat | SupportsIndex, schedule: Schedule, coupons: collections.abc.Sequence[SupportsFloat | SupportsIndex], dayCounter: DayCounter, paymentConvention: BusinessDayConvention = <BusinessDayConvention.Following: 0>, redemption: SupportsFloat | SupportsIndex = 100.0, issueDate: Date = <Date: null date>, paymentCalendar: object = None, exCouponPeriod: Period = <Period: 0D>, exCouponCalendar: object = None, exCouponConvention: BusinessDayConvention = <BusinessDayConvention.Unadjusted: 4>, exCouponEndOfMonth: bool = False, priceType: object = None) -> None

Constructs from quote and bond parameters (handle created internally).

  1. __init__(price: SupportsFloat | SupportsIndex, settlementDays: SupportsInt | SupportsIndex, faceAmount: SupportsFloat | SupportsIndex, schedule: Schedule, coupons: collections.abc.Sequence[SupportsFloat | SupportsIndex], dayCounter: DayCounter, paymentConvention: BusinessDayConvention = <BusinessDayConvention.Following: 0>, redemption: SupportsFloat | SupportsIndex = 100.0, issueDate: Date = <Date: null date>, paymentCalendar: object = None, exCouponPeriod: Period = <Period: 0D>, exCouponCalendar: object = None, exCouponConvention: BusinessDayConvention = <BusinessDayConvention.Unadjusted: 4>, exCouponEndOfMonth: bool = False, priceType: object = None) -> None

Constructs from price value and bond parameters.

Convenience helper that constructs a fixed-rate bond internally.

helper = ql.FixedRateBondHelper(
    101.0,          # clean price
    3,              # settlement days
    100.0,          # face amount
    schedule,
    [0.04],         # coupon rates
    ql.Thirty360(ql.Thirty360.BondBasis),
)
bond = helper.bond()  # access the underlying FixedRateBond

Interpolated Yield Curves

ZeroCurve

class pyquantlib.ZeroCurve

Bases: YieldTermStructure

Yield curve based on zero rates with linear interpolation.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(dates: collections.abc.Sequence[Date], yields: collections.abc.Sequence[SupportsFloat | SupportsIndex], dayCounter: DayCounter, compounding: Compounding = <Compounding.Continuous: 2>, frequency: Frequency = <Frequency.Annual: 1>) -> None

Constructs from dates, yields, and day counter.

  1. __init__(dates: collections.abc.Sequence[Date], yields: collections.abc.Sequence[SupportsFloat | SupportsIndex], dayCounter: DayCounter, calendar: Calendar, compounding: Compounding = <Compounding.Continuous: 2>, frequency: Frequency = <Frequency.Annual: 1>) -> None

Constructs from dates, yields, day counter, and calendar.

data() list[float]

Returns the zero rates.

dates() list[Date]

Returns the curve dates.

nodes() list[tuple[Date, float]]

Returns the (date, rate) pairs.

times() list[float]

Returns the curve times.

zeroRates() list[float]

Returns the zero rates.

Zero rate curve with linear interpolation.

dates = [today, today + ql.Period(1, ql.Years), today + ql.Period(5, ql.Years)]
rates = [0.03, 0.035, 0.04]
curve = ql.ZeroCurve(dates, rates, ql.Actual365Fixed())
print(curve.zeroRate(target_date, dc, ql.Continuous).rate())
print(curve.nodes())

DiscountCurve

class pyquantlib.DiscountCurve

Bases: YieldTermStructure

Yield curve based on discount factors with log-linear interpolation.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(dates: collections.abc.Sequence[Date], discounts: collections.abc.Sequence[SupportsFloat | SupportsIndex], dayCounter: DayCounter) -> None

Constructs from dates, discount factors, and day counter.

  1. __init__(dates: collections.abc.Sequence[Date], discounts: collections.abc.Sequence[SupportsFloat | SupportsIndex], dayCounter: DayCounter, calendar: Calendar) -> None

Constructs from dates, discount factors, day counter, and calendar.

data() list[float]

Returns the discount factors.

dates() list[Date]

Returns the curve dates.

discounts() list[float]

Returns the discount factors.

nodes() list[tuple[Date, float]]

Returns the (date, discount factor) pairs.

times() list[float]

Returns the curve times.

Discount factor curve with log-linear interpolation.

dfs = [1.0, 0.965, 0.835]
curve = ql.DiscountCurve(dates, dfs, ql.Actual365Fixed())
print(curve.discount(target_date))

ForwardCurve

class pyquantlib.ForwardCurve

Bases: YieldTermStructure

Yield curve based on forward rates with backward-flat interpolation.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(dates: collections.abc.Sequence[Date], forwards: collections.abc.Sequence[SupportsFloat | SupportsIndex], dayCounter: DayCounter) -> None

Constructs from dates, forward rates, and day counter.

  1. __init__(dates: collections.abc.Sequence[Date], forwards: collections.abc.Sequence[SupportsFloat | SupportsIndex], dayCounter: DayCounter, calendar: Calendar) -> None

Constructs from dates, forward rates, day counter, and calendar.

data() list[float]

Returns the forward rates.

dates() list[Date]

Returns the curve dates.

forwards() list[float]

Returns the forward rates.

nodes() list[tuple[Date, float]]

Returns the (date, forward rate) pairs.

times() list[float]

Returns the curve times.

Forward rate curve with backward-flat interpolation.

forwards = [0.03, 0.035, 0.04]
curve = ql.ForwardCurve(dates, forwards, ql.Actual365Fixed())
print(curve.forwardRate(d1, d2, dc, ql.Continuous).rate())

ZeroSpreadedTermStructure

class pyquantlib.ZeroSpreadedTermStructure

Bases: YieldTermStructure

Yield curve with an additive spread on zero rates.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(curveHandle: YieldTermStructureHandle, spreadHandle: QuoteHandle, compounding: Compounding = <Compounding.Continuous: 2>, frequency: Frequency = <Frequency.NoFrequency: -1>) -> None

Constructs from yield curve and spread handles.

  1. __init__(curve: base.YieldTermStructure, spread: base.Quote, compounding: Compounding = <Compounding.Continuous: 2>, frequency: Frequency = <Frequency.NoFrequency: -1>) -> None

Constructs from yield curve and spread (handles created internally).

Yield term structure with an additive spread over a base curve.

base = ql.FlatForward(today, 0.03, dc)
spread = ql.SimpleQuote(0.005)
spreaded = ql.ZeroSpreadedTermStructure(base, spread)
spread.setValue(0.01)  # spread updates dynamically

ForwardSpreadedTermStructure

class pyquantlib.ForwardSpreadedTermStructure

Bases: YieldTermStructure

Yield curve with an additive spread on forward rates.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(curveHandle: YieldTermStructureHandle, spreadHandle: QuoteHandle) -> None

Constructs from yield curve and spread handles.

  1. __init__(curve: base.YieldTermStructure, spread: base.Quote) -> None

Constructs from yield curve and spread (handles created internally).

Yield curve with an additive spread over instantaneous forward rates.

base = ql.FlatForward(today, 0.03, dc)
spread = ql.SimpleQuote(0.005)
spreaded = ql.ForwardSpreadedTermStructure(base, spread)

ImpliedTermStructure

class pyquantlib.ImpliedTermStructure

Bases: YieldTermStructure

Implied yield term structure at a future reference date.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(curveHandle: YieldTermStructureHandle, referenceDate: Date) -> None

Constructs from yield curve handle and reference date.

  1. __init__(curve: base.YieldTermStructure, referenceDate: Date) -> None

Constructs from yield curve and reference date (handle created internally).

Implied yield curve from a base curve and a new reference date.

base = ql.FlatForward(today, 0.03, dc)
implied = ql.ImpliedTermStructure(base, today + ql.Period("6M"))

UltimateForwardTermStructure

class pyquantlib.UltimateForwardTermStructure

Bases: YieldTermStructure

UFR extrapolation (Smith-Wilson) for regulatory term structures.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(curveHandle: YieldTermStructureHandle, lastLiquidForwardRate: QuoteHandle, ultimateForwardRate: QuoteHandle, firstSmoothingPoint: Period, alpha: SupportsFloat | SupportsIndex) -> None

Constructs from handles.

  1. __init__(curve: base.YieldTermStructure, lastLiquidForwardRate: base.Quote, ultimateForwardRate: base.Quote, firstSmoothingPoint: Period, alpha: SupportsFloat | SupportsIndex) -> None

Constructs from shared_ptrs (handles created internally).

Ultimate forward rate (UFR) extrapolation beyond a last liquid point.

ufr = ql.UltimateForwardTermStructure(
    base_curve, llfr_quote, ufr_quote,
    ql.Period(20, ql.Years), alpha=0.1
)

CompositeZeroYieldStructure

class pyquantlib.CompositeZeroYieldStructure

Bases: YieldTermStructure

Composite zero-yield term structure from two curves and a binary function.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(curve1: YieldTermStructureHandle, curve2: YieldTermStructureHandle, composer: collections.abc.Callable[[SupportsFloat | SupportsIndex, SupportsFloat | SupportsIndex], float], compounding: Compounding = <Compounding.Continuous: 2>, frequency: Frequency = <Frequency.NoFrequency: -1>) -> None

Constructs from yield curve handles and a composer function.

  1. __init__(curve1: base.YieldTermStructure, curve2: base.YieldTermStructure, composer: collections.abc.Callable[[SupportsFloat | SupportsIndex, SupportsFloat | SupportsIndex], float], compounding: Compounding = <Compounding.Continuous: 2>, frequency: Frequency = <Frequency.NoFrequency: -1>) -> None

Constructs from yield curves and composer (handles created internally).

Composite yield curve combining two curves via a binary function.

import operator
composite = ql.CompositeZeroYieldStructure(curve1, curve2, operator.add)
print(composite.zeroRate(1.0, ql.Continuous).rate())

QuantoTermStructure

class pyquantlib.QuantoTermStructure

Bases: YieldTermStructure

Quanto-adjusted dividend yield term structure.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(underlyingDividendTS: YieldTermStructureHandle, riskFreeTS: YieldTermStructureHandle, foreignRiskFreeTS: YieldTermStructureHandle, underlyingBlackVolTS: BlackVolTermStructureHandle, strike: SupportsFloat | SupportsIndex, exchRateBlackVolTS: BlackVolTermStructureHandle, exchRateATMlevel: SupportsFloat | SupportsIndex, underlyingExchRateCorrelation: SupportsFloat | SupportsIndex) -> None

Constructs from handles.

  1. __init__(underlyingDividendTS: base.YieldTermStructure, riskFreeTS: base.YieldTermStructure, foreignRiskFreeTS: base.YieldTermStructure, underlyingBlackVolTS: base.BlackVolTermStructure, strike: SupportsFloat | SupportsIndex, exchRateBlackVolTS: base.BlackVolTermStructure, exchRateATMlevel: SupportsFloat | SupportsIndex, underlyingExchRateCorrelation: SupportsFloat | SupportsIndex) -> None

Constructs from shared_ptrs (handles created internally).

Quanto-adjusted dividend yield term structure.

Piecewise Yield Curves

PiecewiseLogLinearDiscount

class pyquantlib.PiecewiseLogLinearDiscount

Bases: YieldTermStructure

Piecewise yield curve using log-linear discount factor interpolation.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(referenceDate: Date, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter) -> None

Constructs from reference date, instruments, and day counter.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter) -> None

Constructs from settlement days, calendar, instruments, and day counter.

data() list[float]

Returns the interpolated data values.

dates() list[Date]

Returns the interpolation dates.

nodes() list[tuple[Date, float]]

Returns (date, value) pairs for all nodes.

times() list[float]

Returns the interpolation times.

PiecewiseLinearDiscount

class pyquantlib.PiecewiseLinearDiscount

Bases: YieldTermStructure

Piecewise yield curve using linear discount factor interpolation.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(referenceDate: Date, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter) -> None

Constructs from reference date, instruments, and day counter.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter) -> None

Constructs from settlement days, calendar, instruments, and day counter.

data() list[float]

Returns the interpolated data values.

dates() list[Date]

Returns the interpolation dates.

nodes() list[tuple[Date, float]]

Returns (date, value) pairs for all nodes.

times() list[float]

Returns the interpolation times.

PiecewiseCubicDiscount

class pyquantlib.PiecewiseCubicDiscount

Bases: YieldTermStructure

Piecewise yield curve using cubic discount factor interpolation.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(referenceDate: Date, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter) -> None

Constructs from reference date, instruments, and day counter.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter) -> None

Constructs from settlement days, calendar, instruments, and day counter.

data() list[float]

Returns the interpolated data values.

dates() list[Date]

Returns the interpolation dates.

nodes() list[tuple[Date, float]]

Returns (date, value) pairs for all nodes.

times() list[float]

Returns the interpolation times.

PiecewiseLinearZero

class pyquantlib.PiecewiseLinearZero

Bases: YieldTermStructure

Piecewise yield curve using linear zero-rate interpolation.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(referenceDate: Date, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter) -> None

Constructs from reference date, instruments, and day counter.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter) -> None

Constructs from settlement days, calendar, instruments, and day counter.

data() list[float]

Returns the interpolated data values.

dates() list[Date]

Returns the interpolation dates.

nodes() list[tuple[Date, float]]

Returns (date, value) pairs for all nodes.

times() list[float]

Returns the interpolation times.

PiecewiseCubicZero

class pyquantlib.PiecewiseCubicZero

Bases: YieldTermStructure

Piecewise yield curve using cubic zero-rate interpolation.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(referenceDate: Date, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter) -> None

Constructs from reference date, instruments, and day counter.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter) -> None

Constructs from settlement days, calendar, instruments, and day counter.

data() list[float]

Returns the interpolated data values.

dates() list[Date]

Returns the interpolation dates.

nodes() list[tuple[Date, float]]

Returns (date, value) pairs for all nodes.

times() list[float]

Returns the interpolation times.

PiecewiseLinearForward

class pyquantlib.PiecewiseLinearForward

Bases: YieldTermStructure

Piecewise yield curve using linear forward-rate interpolation.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(referenceDate: Date, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter) -> None

Constructs from reference date, instruments, and day counter.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter) -> None

Constructs from settlement days, calendar, instruments, and day counter.

data() list[float]

Returns the interpolated data values.

dates() list[Date]

Returns the interpolation dates.

nodes() list[tuple[Date, float]]

Returns (date, value) pairs for all nodes.

times() list[float]

Returns the interpolation times.

PiecewiseBackwardFlatForward

class pyquantlib.PiecewiseBackwardFlatForward

Bases: YieldTermStructure

Piecewise yield curve using backward-flat forward-rate interpolation.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(referenceDate: Date, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter) -> None

Constructs from reference date, instruments, and day counter.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter) -> None

Constructs from settlement days, calendar, instruments, and day counter.

data() list[float]

Returns the interpolated data values.

dates() list[Date]

Returns the interpolation dates.

nodes() list[tuple[Date, float]]

Returns (date, value) pairs for all nodes.

times() list[float]

Returns the interpolation times.

PiecewiseFlatForward is an alias for PiecewiseBackwardFlatForward.

Piecewise yield curves bootstrap a term structure from market instruments.

helpers = [
    ql.DepositRateHelper(0.032, euribor6m),
    ql.SwapRateHelper(0.04, ql.Period(5, ql.Years), ql.TARGET(),
                      ql.Annual, ql.Unadjusted,
                      ql.Thirty360(ql.Thirty360.BondBasis), euribor6m),
]

curve = ql.PiecewiseLogLinearDiscount(today, helpers, ql.Actual365Fixed())
print(curve.discount(1.0))
print(curve.nodes())

Global Bootstrap Piecewise Curves

Piecewise yield curves using GlobalBootstrap, which solves for all nodes simultaneously via global optimization instead of iterative bootstrapping. Useful when instruments depend on each other or when the standard bootstrap fails to converge.

PiecewiseLogLinearDiscountGlobal

class pyquantlib.PiecewiseLogLinearDiscountGlobal

Bases: YieldTermStructure

Piecewise yield curve using log-linear discount factor interpolation with global bootstrap.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(referenceDate: Date, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter, accuracy: SupportsFloat | SupportsIndex = Null<NullReal>(), instrumentWeights: collections.abc.Sequence[SupportsFloat | SupportsIndex] = []) -> None

Constructs with global bootstrap using default optimizer.

  1. __init__(referenceDate: Date, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter, optimizer: base.OptimizationMethod, endCriteria: EndCriteria = None, instrumentWeights: collections.abc.Sequence[SupportsFloat | SupportsIndex] = []) -> None

Constructs with global bootstrap using a custom optimizer.

  1. __init__(referenceDate: Date, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter, additionalHelpers: collections.abc.Sequence[base.RateHelper], additionalDates: collections.abc.Callable[[], list[Date]], additionalPenalties: collections.abc.Callable[[], Array], accuracy: SupportsFloat | SupportsIndex = Null<NullReal>(), instrumentWeights: collections.abc.Sequence[SupportsFloat | SupportsIndex] = []) -> None

Constructs with global bootstrap, additional helpers, and penalty functions.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter, accuracy: SupportsFloat | SupportsIndex = Null<NullReal>(), instrumentWeights: collections.abc.Sequence[SupportsFloat | SupportsIndex] = []) -> None

Constructs from settlement days with global bootstrap.

data() list[float]

Returns the interpolated data values.

dates() list[Date]

Returns the interpolation dates.

nodes() list[tuple[Date, float]]

Returns (date, value) pairs for all nodes.

times() list[float]

Returns the interpolation times.

PiecewiseLinearZeroGlobal

class pyquantlib.PiecewiseLinearZeroGlobal

Bases: YieldTermStructure

Piecewise yield curve using linear zero-rate interpolation with global bootstrap.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(referenceDate: Date, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter, accuracy: SupportsFloat | SupportsIndex = Null<NullReal>(), instrumentWeights: collections.abc.Sequence[SupportsFloat | SupportsIndex] = []) -> None

Constructs with global bootstrap using default optimizer.

  1. __init__(referenceDate: Date, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter, optimizer: base.OptimizationMethod, endCriteria: EndCriteria = None, instrumentWeights: collections.abc.Sequence[SupportsFloat | SupportsIndex] = []) -> None

Constructs with global bootstrap using a custom optimizer.

  1. __init__(referenceDate: Date, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter, additionalHelpers: collections.abc.Sequence[base.RateHelper], additionalDates: collections.abc.Callable[[], list[Date]], additionalPenalties: collections.abc.Callable[[], Array], accuracy: SupportsFloat | SupportsIndex = Null<NullReal>(), instrumentWeights: collections.abc.Sequence[SupportsFloat | SupportsIndex] = []) -> None

Constructs with global bootstrap, additional helpers, and penalty functions.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter, accuracy: SupportsFloat | SupportsIndex = Null<NullReal>(), instrumentWeights: collections.abc.Sequence[SupportsFloat | SupportsIndex] = []) -> None

Constructs from settlement days with global bootstrap.

data() list[float]

Returns the interpolated data values.

dates() list[Date]

Returns the interpolation dates.

nodes() list[tuple[Date, float]]

Returns (date, value) pairs for all nodes.

times() list[float]

Returns the interpolation times.

PiecewiseBackwardFlatForwardGlobal

class pyquantlib.PiecewiseBackwardFlatForwardGlobal

Bases: YieldTermStructure

Piecewise yield curve using backward-flat forward-rate interpolation with global bootstrap.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(referenceDate: Date, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter, accuracy: SupportsFloat | SupportsIndex = Null<NullReal>(), instrumentWeights: collections.abc.Sequence[SupportsFloat | SupportsIndex] = []) -> None

Constructs with global bootstrap using default optimizer.

  1. __init__(referenceDate: Date, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter, optimizer: base.OptimizationMethod, endCriteria: EndCriteria = None, instrumentWeights: collections.abc.Sequence[SupportsFloat | SupportsIndex] = []) -> None

Constructs with global bootstrap using a custom optimizer.

  1. __init__(referenceDate: Date, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter, additionalHelpers: collections.abc.Sequence[base.RateHelper], additionalDates: collections.abc.Callable[[], list[Date]], additionalPenalties: collections.abc.Callable[[], Array], accuracy: SupportsFloat | SupportsIndex = Null<NullReal>(), instrumentWeights: collections.abc.Sequence[SupportsFloat | SupportsIndex] = []) -> None

Constructs with global bootstrap, additional helpers, and penalty functions.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, instruments: collections.abc.Sequence[base.RateHelper], dayCounter: DayCounter, accuracy: SupportsFloat | SupportsIndex = Null<NullReal>(), instrumentWeights: collections.abc.Sequence[SupportsFloat | SupportsIndex] = []) -> None

Constructs from settlement days with global bootstrap.

data() list[float]

Returns the interpolated data values.

dates() list[Date]

Returns the interpolation dates.

nodes() list[tuple[Date, float]]

Returns (date, value) pairs for all nodes.

times() list[float]

Returns the interpolation times.

curve = ql.PiecewiseLogLinearDiscountGlobal(
    today, helpers, ql.Actual365Fixed(), accuracy=1e-12)

# With instrument weights
weights = [1.0] * len(helpers)
curve = ql.PiecewiseLogLinearDiscountGlobal(
    today, helpers, ql.Actual365Fixed(),
    accuracy=1e-12, instrumentWeights=weights)

# Settlement days constructor
curve = ql.PiecewiseLogLinearDiscountGlobal(
    2, ql.TARGET(), helpers, ql.Actual365Fixed(), accuracy=1e-12)

MultiCurve

class pyquantlib.MultiCurve

Bases: Observer

Manages a set of yield curves that form a dependency cycle.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(accuracy: SupportsFloat | SupportsIndex) -> None

Constructs with a target accuracy for the bootstrap.

  1. __init__(optimizer: base.OptimizationMethod = None, endCriteria: EndCriteria = None) -> None

Constructs with an optimization method and end criteria.

addBootstrappedCurve(internalHandle: RelinkableYieldTermStructureHandle, curve: base.YieldTermStructure) YieldTermStructureHandle

Adds a bootstrapped curve and returns an external handle.

addNonBootstrappedCurve(internalHandle: RelinkableYieldTermStructureHandle, curve: base.YieldTermStructure) YieldTermStructureHandle

Adds a non-bootstrapped curve and returns an external handle.

Manages a set of yield curves that form a dependency cycle, bootstrapping them simultaneously. Curves added with addBootstrappedCurve are solved together; curves added with addNonBootstrappedCurve are relinked but not bootstrapped (e.g. spreaded curves derived from bootstrapped ones).

accuracy = 1e-10

# Internal relinkable handles for the dependency cycle
int_3m = ql.RelinkableYieldTermStructureHandle()
int_6m = ql.RelinkableYieldTermStructureHandle()

euribor3m = ql.Euribor3M(int_3m)
euribor6m = ql.Euribor6M(int_6m)

# Build helpers referencing each other's curves
helpers_3m = [ql.FraRateHelper(q, i, euribor3m) for i in range(1, 10)]
helpers_6m = [ql.SwapRateHelper(q, ql.Period(i, ql.Years), ...)
              for i in range(2, 11)]

# Create GlobalBootstrap curves
curve_3m = ql.PiecewiseLogLinearDiscountGlobal(
    today, helpers_3m, ql.Actual360(), accuracy=accuracy)
curve_6m = ql.PiecewiseLogLinearDiscountGlobal(
    today, helpers_6m, ql.Actual360(), accuracy=accuracy)

# Solve the cycle
mc = ql.MultiCurve(accuracy)
ext_3m = mc.addBootstrappedCurve(int_3m, curve_3m)
ext_6m = mc.addBootstrappedCurve(int_6m, curve_6m)

# Use external handles for pricing
print(ext_3m.currentLink().discount(1.0))

Fitted Bond Discount Curves

FittedBondDiscountCurve

class pyquantlib.FittedBondDiscountCurve

Bases: YieldTermStructure, LazyObject

Discount curve fitted to a set of bonds.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, bonds: collections.abc.Sequence[BondHelper], dayCounter: DayCounter, fittingMethod: base.FittingMethod, accuracy: SupportsFloat | SupportsIndex = 1e-10, maxEvaluations: SupportsInt | SupportsIndex = 10000, guess: Array = Array([]), simplexLambda: SupportsFloat | SupportsIndex = 1.0, maxStationaryStateIterations: SupportsInt | SupportsIndex = 100) -> None

Constructs from settlement days with bond fitting.

  1. __init__(referenceDate: Date, bonds: collections.abc.Sequence[BondHelper], dayCounter: DayCounter, fittingMethod: base.FittingMethod, accuracy: SupportsFloat | SupportsIndex = 1e-10, maxEvaluations: SupportsInt | SupportsIndex = 10000, guess: Array = Array([]), simplexLambda: SupportsFloat | SupportsIndex = 1.0, maxStationaryStateIterations: SupportsInt | SupportsIndex = 100) -> None

Constructs from reference date with bond fitting.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, fittingMethod: base.FittingMethod, parameters: Array, maxDate: Date, dayCounter: DayCounter) -> None

Constructs from settlement days with precalculated parameters.

  1. __init__(referenceDate: Date, fittingMethod: base.FittingMethod, parameters: Array, maxDate: Date, dayCounter: DayCounter) -> None

Constructs from reference date with precalculated parameters.

fitResults() base.FittingMethod

Returns the fitting method with calibration results.

numberOfBonds() int

Returns the number of bonds used in the fit.

resetGuess(guess: Array) None

Resets the initial guess for refitting.

Discount curve fitted to a set of bond prices using a parametric fitting method.

curve = ql.FittedBondDiscountCurve(
    today, bond_helpers, dc,
    ql.NelsonSiegelFitting()
)
curve.discount(1.0)

Fitting Methods

NelsonSiegelFitting

class pyquantlib.NelsonSiegelFitting

Bases: FittingMethod

Nelson-Siegel fitting method.

__init__(weights: Array = Array([]), optimizationMethod: base.OptimizationMethod = None, l2: Array = Array([]), minCutoffTime: SupportsFloat | SupportsIndex = 0.0, maxCutoffTime: SupportsFloat | SupportsIndex = 1.7976931348623157e+308, constraint: base.Constraint = <NoConstraint object at 0x7f252f3dc3b0>) None

Constructs a Nelson-Siegel fitting method.

SvenssonFitting

class pyquantlib.SvenssonFitting

Bases: FittingMethod

Svensson fitting method.

__init__(weights: Array = Array([]), optimizationMethod: base.OptimizationMethod = None, l2: Array = Array([]), minCutoffTime: SupportsFloat | SupportsIndex = 0.0, maxCutoffTime: SupportsFloat | SupportsIndex = 1.7976931348623157e+308, constraint: base.Constraint = <NoConstraint object at 0x7f253433d830>) None

Constructs a Svensson fitting method.

ExponentialSplinesFitting

class pyquantlib.ExponentialSplinesFitting

Bases: FittingMethod

Exponential splines fitting method.

__init__(constrainAtZero: bool = True, weights: Array = Array([]), optimizationMethod: base.OptimizationMethod = None, l2: Array = Array([]), minCutoffTime: SupportsFloat | SupportsIndex = 0.0, maxCutoffTime: SupportsFloat | SupportsIndex = 1.7976931348623157e+308, numCoeffs: SupportsInt | SupportsIndex = 9, fixedKappa: object = None, constraint: base.Constraint = <NoConstraint object at 0x7f25341a0270>) None

Constructs an exponential splines fitting method.

CubicBSplinesFitting

class pyquantlib.CubicBSplinesFitting

Bases: FittingMethod

Cubic B-splines fitting method.

__init__(knotVector: collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], constrainAtZero: bool = True, weights: Array = Array([]), optimizationMethod: base.OptimizationMethod = None, l2: Array = Array([]), minCutoffTime: typing.SupportsFloat | typing.SupportsIndex = 0.0, maxCutoffTime: typing.SupportsFloat | typing.SupportsIndex = 1.7976931348623157e+308, constraint: base.Constraint = <NoConstraint object at 0x7f252f3dbdb0>) None

Constructs a cubic B-splines fitting method.

basisFunction(i: SupportsInt | SupportsIndex, t: SupportsFloat | SupportsIndex) float

Returns the i-th basis function value at time t.

SimplePolynomialFitting

class pyquantlib.SimplePolynomialFitting

Bases: FittingMethod

Simple polynomial fitting method.

__init__(degree: SupportsInt | SupportsIndex, constrainAtZero: bool = True, weights: Array = Array([]), optimizationMethod: base.OptimizationMethod = None, l2: Array = Array([]), minCutoffTime: SupportsFloat | SupportsIndex = 0.0, maxCutoffTime: SupportsFloat | SupportsIndex = 1.7976931348623157e+308, constraint: base.Constraint = <NoConstraint object at 0x7f25341a05f0>) None

Constructs a simple polynomial fitting method.

SpreadFittingMethod

class pyquantlib.SpreadFittingMethod

Bases: FittingMethod

Spread fitting method over a reference curve.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(method: base.FittingMethod, discountCurve: YieldTermStructureHandle, minCutoffTime: SupportsFloat | SupportsIndex = 0.0, maxCutoffTime: SupportsFloat | SupportsIndex = 1.7976931348623157e+308) -> None

Constructs with a discount curve handle.

  1. __init__(method: base.FittingMethod, discountCurve: object, minCutoffTime: SupportsFloat | SupportsIndex = 0.0, maxCutoffTime: SupportsFloat | SupportsIndex = 1.7976931348623157e+308) -> None

Constructs with a discount curve (handle created internally).

# Fit with Nelson-Siegel
ns = ql.NelsonSiegelFitting()
curve = ql.FittedBondDiscountCurve(today, helpers, dc, ns)

# Fit with Svensson
sv = ql.SvenssonFitting()
curve = ql.FittedBondDiscountCurve(today, helpers, dc, sv)

# Spread fitting over a reference curve
spread = ql.SpreadFittingMethod(ql.NelsonSiegelFitting(), reference_curve)
curve = ql.FittedBondDiscountCurve(today, helpers, dc, spread)

Volatility Term Structures

BlackConstantVol

class pyquantlib.BlackConstantVol

Bases: BlackVolatilityTermStructure

Constant Black volatility term structure.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(referenceDate: Date, calendar: Calendar, volatility: SupportsFloat | SupportsIndex, dayCounter: DayCounter) -> None

Constructs from reference date and constant volatility.

  1. __init__(referenceDate: Date, calendar: Calendar, volatility: QuoteHandle, dayCounter: DayCounter) -> None

Constructs from reference date and quote handle.

  1. __init__(referenceDate: Date, calendar: Calendar, volatility: base.Quote, dayCounter: DayCounter) -> None

Constructs from reference date and quote (handle created internally).

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, volatility: SupportsFloat | SupportsIndex, dayCounter: DayCounter) -> None

Constructs from settlement days and constant volatility.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, volatility: QuoteHandle, dayCounter: DayCounter) -> None

Constructs from settlement days and quote handle.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, volatility: base.Quote, dayCounter: DayCounter) -> None

Constructs from settlement days and quote (handle created internally).

const_vol = ql.BlackConstantVol(today, ql.TARGET(), 0.20, dc)

# Using a quote (hidden handle)
vol = ql.SimpleQuote(0.20)
const_vol = ql.BlackConstantVol(today, ql.TARGET(), vol, dc)

BlackVarianceSurface

class pyquantlib.BlackVarianceSurface

Bases: BlackVarianceTermStructure

Black volatility surface modelled as a variance surface.

__init__(referenceDate: Date, calendar: Calendar, dates: collections.abc.Sequence[Date], strikes: collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], blackVolMatrix: Matrix, dayCounter: DayCounter, lowerExtrapolation: BlackVarianceSurfaceExtrapolation = <BlackVarianceSurfaceExtrapolation.InterpolatorDefaultExtrapolation: 1>, upperExtrapolation: BlackVarianceSurfaceExtrapolation = <BlackVarianceSurfaceExtrapolation.InterpolatorDefaultExtrapolation: 1>) None

Constructs from date/strike grid and volatility matrix.

dayCounter() DayCounter

Returns the day counter.

maxDate() Date

Returns the maximum date.

maxStrike() float

Returns the maximum strike.

minStrike() float

Returns the minimum strike.

setInterpolation(interpolator: str) None

Sets interpolation method. Supported: ‘bilinear’, ‘bicubic’.

BlackVolTermStructureHandle

class pyquantlib.BlackVolTermStructureHandle

Bases: pybind11_object

Handle to BlackVolTermStructure.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__() -> None

Creates an empty handle.

  1. __init__(ptr: object, registerAsObserver: bool = True) -> None

Creates a handle linked to the given object.

asObservable() Observable

Converts to Observable for observer registration.

Returns the shared_ptr to the current object link.

empty() bool

Returns true if the handle is empty.

get() base.BlackVolTermStructure

Returns the underlying shared_ptr. Raises error if empty.

RelinkableBlackVolTermStructureHandle

class pyquantlib.RelinkableBlackVolTermStructureHandle

Bases: BlackVolTermStructureHandle

Relinkable handle to BlackVolTermStructure.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__() -> None

Creates an empty relinkable handle.

  1. __init__(ptr: object, registerAsObserver: bool = True) -> None

Creates a relinkable handle linked to the given object.

linkTo(ptr: object = None, registerAsObserver: bool = True) None

Links the handle to a new object instance. Notifies observers.

FlatSmileSection

class pyquantlib.FlatSmileSection

Bases: SmileSection

Smile section with constant volatility.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(d: Date, vol: SupportsFloat | SupportsIndex, dc: DayCounter = <DayCounter: Actual/365 (Fixed)>, referenceDate: Date = <Date: null date>, atmLevel: object = None, type: VolatilityType = <VolatilityType.ShiftedLognormal: 0>, shift: SupportsFloat | SupportsIndex = 0.0) -> None

Constructs with exercise date.

  1. __init__(exerciseTime: SupportsFloat | SupportsIndex, vol: SupportsFloat | SupportsIndex, dc: DayCounter = <DayCounter: Actual/365 (Fixed)>, atmLevel: object = None, type: VolatilityType = <VolatilityType.ShiftedLognormal: 0>, shift: SupportsFloat | SupportsIndex = 0.0) -> None

Constructs with exercise time.

Flat (constant) smile section for volatility modeling.

# From exercise time
fs = ql.FlatSmileSection(1.0, 0.2)

# From exercise date
fs = ql.FlatSmileSection(ql.Date(15, 6, 2026), 0.2)

# Normal volatility
fs = ql.FlatSmileSection(1.0, 0.005, type=ql.VolatilityType.Normal)

HestonBlackVolSurface

class pyquantlib.HestonBlackVolSurface

Bases: BlackVolTermStructure

Black volatility surface implied by a Heston model.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(hestonModel: QuantLib::Handle<QuantLib::HestonModel>) -> None

Constructs from Heston model handle with default formula and integration.

  1. __init__(hestonModel: QuantLib::HestonModel) -> None

Constructs from Heston model (handle created internally).

Black volatility surface implied by a Heston model.

model = ql.HestonModel(heston_process)
vol_surface = ql.HestonBlackVolSurface(model)

Swaption Volatility Spread

SpreadedSwaptionVolatility

class pyquantlib.SpreadedSwaptionVolatility

Bases: SwaptionVolatilityStructure

Swaption volatility with an additive spread.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(baseVolHandle: SwaptionVolatilityStructureHandle, spreadHandle: QuoteHandle) -> None

Constructs from swaption vol and spread handles.

  1. __init__(baseVol: base.SwaptionVolatilityStructure, spread: base.Quote) -> None

Constructs from shared_ptrs (handles created internally).

Swaption volatility surface with an additive spread over a base surface.

spread = ql.SimpleQuote(0.005)
spreaded_vol = ql.SpreadedSwaptionVolatility(base_vol_handle, spread)

SABR Volatility

SabrSmileSection

class pyquantlib.SabrSmileSection

Bases: SmileSection

SABR parametric smile section.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(timeToExpiry: SupportsFloat | SupportsIndex, forward: SupportsFloat | SupportsIndex, sabrParameters: collections.abc.Sequence[SupportsFloat | SupportsIndex], shift: SupportsFloat | SupportsIndex = 0.0, volatilityType: VolatilityType = <VolatilityType.ShiftedLognormal: 0>) -> None

Constructs from time to expiry, forward, and SABR parameters [alpha, beta, nu, rho].

  1. __init__(expiryDate: Date, forward: SupportsFloat | SupportsIndex, sabrParameters: collections.abc.Sequence[SupportsFloat | SupportsIndex], referenceDate: Date = <Date: null date>, dayCounter: DayCounter = <DayCounter: Actual/365 (Fixed)>, shift: SupportsFloat | SupportsIndex = 0.0, volatilityType: VolatilityType = <VolatilityType.ShiftedLognormal: 0>) -> None

Constructs from expiry date, forward, and SABR parameters [alpha, beta, nu, rho].

alpha() float

Returns SABR alpha parameter.

beta() float

Returns SABR beta parameter.

nu() float

Returns SABR nu parameter.

rho() float

Returns SABR rho parameter.

Parametric SABR smile section defined by alpha, beta, nu, rho.

params = [0.05, 0.5, 0.4, -0.1]  # alpha, beta, nu, rho
forward = 0.03

# From exercise time
section = ql.SabrSmileSection(1.0, forward, params)
vol = section.volatility(0.03)

# From expiry date
section = ql.SabrSmileSection(ql.Date(15, 7, 2025), forward, params)

SabrInterpolatedSmileSection

class pyquantlib.SabrInterpolatedSmileSection

Bases: SmileSection, LazyObject

Smile section calibrated via SABR interpolation.

__init__(optionDate: Date, forward: typing.SupportsFloat | typing.SupportsIndex, strikes: collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], hasFloatingStrikes: bool, atmVolatility: typing.SupportsFloat | typing.SupportsIndex, vols: collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], alpha: typing.SupportsFloat | typing.SupportsIndex, beta: typing.SupportsFloat | typing.SupportsIndex, nu: typing.SupportsFloat | typing.SupportsIndex, rho: typing.SupportsFloat | typing.SupportsIndex, isAlphaFixed: bool = False, isBetaFixed: bool = False, isNuFixed: bool = False, isRhoFixed: bool = False, vegaWeighted: bool = True, endCriteria: EndCriteria = None, method: base.OptimizationMethod = None, dayCounter: DayCounter = <DayCounter: Actual/365 (Fixed)>, shift: typing.SupportsFloat | typing.SupportsIndex = 0.0) None

Constructs and calibrates SABR to market strikes and volatilities.

alpha() float

Returns calibrated SABR alpha.

beta() float

Returns calibrated SABR beta.

endCriteria() EndCriteria.Type

Returns end criteria type from calibration.

maxError() float

Returns maximum calibration error.

nu() float

Returns calibrated SABR nu.

rho() float

Returns calibrated SABR rho.

rmsError() float

Returns RMS calibration error.

Smile section that calibrates SABR parameters to market strikes and volatilities.

option_date = ql.Date(15, 7, 2025)
forward = 0.03
strikes = [0.01, 0.02, 0.025, 0.03, 0.035, 0.04, 0.05]
vols = [0.30, 0.22, 0.19, 0.18, 0.185, 0.20, 0.25]

section = ql.SabrInterpolatedSmileSection(
    option_date, forward, strikes,
    hasFloatingStrikes=False,
    atmVolatility=0.18,
    vols=vols,
    alpha=0.05, beta=0.5, nu=0.4, rho=-0.1,
    isBetaFixed=True,
)
section.recalculate()
print(section.alpha(), section.rmsError())

SABR Free Functions

pyquantlib.sabrVolatility(strike: SupportsFloat | SupportsIndex, forward: SupportsFloat | SupportsIndex, expiryTime: SupportsFloat | SupportsIndex, alpha: SupportsFloat | SupportsIndex, beta: SupportsFloat | SupportsIndex, nu: SupportsFloat | SupportsIndex, rho: SupportsFloat | SupportsIndex, volatilityType: VolatilityType = <VolatilityType.ShiftedLognormal: 0>) float

Computes SABR implied volatility (with parameter validation).

pyquantlib.shiftedSabrVolatility(strike: SupportsFloat | SupportsIndex, forward: SupportsFloat | SupportsIndex, expiryTime: SupportsFloat | SupportsIndex, alpha: SupportsFloat | SupportsIndex, beta: SupportsFloat | SupportsIndex, nu: SupportsFloat | SupportsIndex, rho: SupportsFloat | SupportsIndex, shift: SupportsFloat | SupportsIndex, volatilityType: VolatilityType = <VolatilityType.ShiftedLognormal: 0>) float

Computes shifted SABR implied volatility.

pyquantlib.validateSabrParameters(alpha: SupportsFloat | SupportsIndex, beta: SupportsFloat | SupportsIndex, nu: SupportsFloat | SupportsIndex, rho: SupportsFloat | SupportsIndex) None

Validates SABR parameters (raises on invalid).

vol = ql.sabrVolatility(strike, forward, T, alpha, beta, nu, rho)
vol_shifted = ql.shiftedSabrVolatility(strike, forward, T, alpha, beta, nu, rho, shift)
ql.validateSabrParameters(alpha, beta, nu, rho)

No-Arbitrage SABR

NoArbSabrModel

class pyquantlib.NoArbSabrModel

Bases: pybind11_object

No-arbitrage SABR model (Doust, 2012). Provides arbitrage-free option prices, digital prices, and density.

__init__(expiryTime: SupportsFloat | SupportsIndex, forward: SupportsFloat | SupportsIndex, alpha: SupportsFloat | SupportsIndex, beta: SupportsFloat | SupportsIndex, nu: SupportsFloat | SupportsIndex, rho: SupportsFloat | SupportsIndex) None

Constructs a no-arbitrage SABR model.

absorptionProbability() float

Returns the probability of absorption at zero.

alpha() float
beta() float
density(strike: SupportsFloat | SupportsIndex) float

Returns the probability density at the given strike.

digitalOptionPrice(strike: SupportsFloat | SupportsIndex) float

Returns the (undiscounted) digital call option price.

expiryTime() float
forward() float

Returns the external (input) forward rate.

nu() float
numericalForward() float

Returns the model-implied numerical forward.

optionPrice(strike: SupportsFloat | SupportsIndex) float

Returns the (undiscounted) call option price for the given strike.

rho() float

No-arbitrage SABR model (Doust, 2012). Provides arbitrage-free option prices, digital prices, and probability density.

model = ql.NoArbSabrModel(1.0, 0.05, 0.05, 0.5, 0.2, -0.3)
print(model.optionPrice(0.05))
print(model.density(0.05))
print(model.absorptionProbability())

NoArbSabrSmileSection

class pyquantlib.NoArbSabrSmileSection

Bases: SmileSection

No-arbitrage SABR smile section. Wraps NoArbSabrModel to provide a SmileSection interface.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(timeToExpiry: SupportsFloat | SupportsIndex, forward: SupportsFloat | SupportsIndex, sabrParameters: collections.abc.Sequence[SupportsFloat | SupportsIndex], shift: SupportsFloat | SupportsIndex = 0.0, volatilityType: VolatilityType = <VolatilityType.ShiftedLognormal: 0>) -> None

Constructs from time to expiry, forward, and SABR parameters [alpha, beta, nu, rho].

  1. __init__(expiryDate: Date, forward: SupportsFloat | SupportsIndex, sabrParameters: collections.abc.Sequence[SupportsFloat | SupportsIndex], dayCounter: DayCounter = <DayCounter: Actual/365 (Fixed)>, shift: SupportsFloat | SupportsIndex = 0.0, volatilityType: VolatilityType = <VolatilityType.ShiftedLognormal: 0>) -> None

Constructs from expiry date, forward, and SABR parameters [alpha, beta, nu, rho].

model() NoArbSabrModel

Returns the underlying NoArbSabrModel.

ss = ql.NoArbSabrSmileSection(1.0, 0.05, [0.05, 0.5, 0.2, -0.3])
vol = ss.volatility(0.05)
sabr_model = ss.model()

NoArbSabrInterpolatedSmileSection

class pyquantlib.NoArbSabrInterpolatedSmileSection

Bases: SmileSection

Smile section calibrated to market data using no-arbitrage SABR interpolation. Inherits from both SmileSection and LazyObject.

__init__(optionDate: Date, forward: typing.SupportsFloat | typing.SupportsIndex, strikes: collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], hasFloatingStrikes: bool, atmVolatility: typing.SupportsFloat | typing.SupportsIndex, vols: collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], alpha: typing.SupportsFloat | typing.SupportsIndex, beta: typing.SupportsFloat | typing.SupportsIndex, nu: typing.SupportsFloat | typing.SupportsIndex, rho: typing.SupportsFloat | typing.SupportsIndex, isAlphaFixed: bool = False, isBetaFixed: bool = False, isNuFixed: bool = False, isRhoFixed: bool = False, vegaWeighted: bool = True, endCriteria: EndCriteria = None, method: base.OptimizationMethod = None, dayCounter: DayCounter = <DayCounter: Actual/365 (Fixed)>) None

Constructs from market data (no quotes).

alpha() float
beta() float
endCriteria() EndCriteria.Type

Returns end criteria type after calibration.

maxError() float

Returns maximum calibration error.

nu() float
rho() float
rmsError() float

Returns RMS calibration error.

section = ql.NoArbSabrInterpolatedSmileSection(
    expiry_date, 0.05, strikes, False, 0.22, vols,
    0.05, 0.5, 0.2, -0.3)
print(section.alpha(), section.rmsError())

Kahale Arbitrage-Free Smile

KahaleSmileSection

class pyquantlib.KahaleSmileSection

Bases: SmileSection

Arbitrage-free smile section using Kahale’s C^1 inter- and extrapolation method.

__init__(source: object, atm: object = None, interpolate: bool = False, exponentialExtrapolation: bool = False, deleteArbitragePoints: bool = False, moneynessGrid: collections.abc.Sequence[SupportsFloat | SupportsIndex] = [], gap: SupportsFloat | SupportsIndex = 1e-05, forcedLeftIndex: SupportsInt | SupportsIndex = -1, forcedRightIndex: SupportsInt | SupportsIndex = 2147483647) None

Constructs from a source SmileSection, optionally specifying ATM level, interpolation, and extrapolation parameters.

coreIndices() tuple[int, int]

Returns (left, right) indices of the core region.

leftCoreStrike() float

Returns the leftmost core region strike.

rightCoreStrike() float

Returns the rightmost core region strike.

Arbitrage-free smile section using Kahale’s C^1 interpolation and extrapolation method.

source = ql.SabrSmileSection(1.0, 0.05, [0.3, 0.5, 0.4, -0.3])
kahale = ql.KahaleSmileSection(source)
kahale = ql.KahaleSmileSection(source, interpolate=True,
                                exponentialExtrapolation=True)
print(kahale.leftCoreStrike(), kahale.rightCoreStrike())

Andreasen-Huge Volatility

AndreasenHugeVolatilityInterpl

class pyquantlib.AndreasenHugeVolatilityInterpl

Bases: pybind11_object

Andreasen-Huge local volatility calibration and interpolation. Calibrates a local vol surface to a sparse grid of vanilla options.

__init__(calibrationSet: collections.abc.Sequence[tuple[QuantLib::VanillaOption, base.Quote]], spot: QuoteHandle, rTS: YieldTermStructureHandle, qTS: YieldTermStructureHandle, interpolationType: AndreasenHugeInterpolationType = <AndreasenHugeInterpolationType.CubicSpline: 2>, calibrationType: AndreasenHugeCalibrationType = <AndreasenHugeCalibrationType.Call: 1>, nGridPoints: typing.SupportsInt | typing.SupportsIndex = 500, minStrike: object = None, maxStrike: object = None, optimizationMethod: base.OptimizationMethod = None, endCriteria: EndCriteria = <EndCriteria object at 0x7f252f3cb6f0>) None

Constructs from a calibration set of (VanillaOption, Quote) pairs.

calibrationError() tuple[float, float, float]

Returns (min, max, avg) calibration error in volatility units.

fwd(t: SupportsFloat | SupportsIndex) float

Returns the forward price at time t.

localVol(t: SupportsFloat | SupportsIndex, strike: SupportsFloat | SupportsIndex) float

Returns the calibrated local volatility.

maxDate() Date
maxStrike() float
minStrike() float
optionPrice(t: SupportsFloat | SupportsIndex, strike: SupportsFloat | SupportsIndex, optionType: OptionType) float

Returns the calibrated option price.

riskFreeRate() YieldTermStructureHandle

Calibrates a local volatility surface to a sparse grid of vanilla options using the Andreasen-Huge method.

# calibration_set: list of (VanillaOption, SimpleQuote) pairs
ah = ql.AndreasenHugeVolatilityInterpl(
    calibration_set, spot, rTS, qTS,
    ql.AndreasenHugeInterpolationType.CubicSpline,
    ql.AndreasenHugeCalibrationType.Call)

min_err, max_err, avg_err = ah.calibrationError()
lv = ah.localVol(0.5, 100.0)

AndreasenHugeVolatilityAdapter

class pyquantlib.AndreasenHugeVolatilityAdapter

Bases: BlackVolTermStructure

BlackVolTermStructure adapter for Andreasen-Huge volatility interpolation. Provides implied Black volatility.

__init__(volInterpl: AndreasenHugeVolatilityInterpl, eps: SupportsFloat | SupportsIndex = 1e-06) None

Constructs from an AndreasenHugeVolatilityInterpl instance.

Black volatility term structure adapter for Andreasen-Huge interpolation.

adapter = ql.AndreasenHugeVolatilityAdapter(ah)
vol = adapter.blackVol(0.5, 100.0)

AndreasenHugeLocalVolAdapter

class pyquantlib.AndreasenHugeLocalVolAdapter

Bases: LocalVolTermStructure

LocalVolTermStructure adapter for Andreasen-Huge volatility interpolation.

__init__(localVol: AndreasenHugeVolatilityInterpl) None

Constructs from an AndreasenHugeVolatilityInterpl instance.

Local volatility term structure adapter for Andreasen-Huge interpolation.

adapter = ql.AndreasenHugeLocalVolAdapter(ah)
lv = adapter.localVol(0.5, 100.0)

Local Volatility

LocalConstantVol

class pyquantlib.LocalConstantVol

Bases: LocalVolTermStructure

Constant local volatility term structure.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(referenceDate: Date, volatility: SupportsFloat | SupportsIndex, dayCounter: DayCounter) -> None

Constructs from reference date and constant volatility.

  1. __init__(referenceDate: Date, volatility: QuoteHandle, dayCounter: DayCounter) -> None

Constructs from reference date and quote handle.

  1. __init__(referenceDate: Date, volatility: base.Quote, dayCounter: DayCounter) -> None

Constructs from reference date and quote (handle created internally).

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, volatility: SupportsFloat | SupportsIndex, dayCounter: DayCounter) -> None

Constructs from settlement days and constant volatility.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, volatility: QuoteHandle, dayCounter: DayCounter) -> None

Constructs from settlement days and quote handle.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, volatility: base.Quote, dayCounter: DayCounter) -> None

Constructs from settlement days and quote (handle created internally).

LocalVolSurface

class pyquantlib.LocalVolSurface

Bases: LocalVolTermStructure

Local volatility surface derived from a Black volatility surface.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(blackVolTS: BlackVolTermStructureHandle, riskFreeTS: YieldTermStructureHandle, dividendTS: YieldTermStructureHandle, underlying: QuoteHandle) -> None

Constructs from Black vol surface and quote handle for underlying.

  1. __init__(blackVolTS: BlackVolTermStructureHandle, riskFreeTS: YieldTermStructureHandle, dividendTS: YieldTermStructureHandle, underlying: SupportsFloat | SupportsIndex) -> None

Constructs from Black vol surface and fixed underlying value.

  1. __init__(blackVolTS: base.BlackVolTermStructure, riskFreeTS: base.YieldTermStructure, dividendTS: base.YieldTermStructure, underlying: base.Quote) -> None

Constructs from term structures and quote (handles created internally).

  1. __init__(blackVolTS: base.BlackVolTermStructure, riskFreeTS: base.YieldTermStructure, dividendTS: base.YieldTermStructure, underlying: SupportsFloat | SupportsIndex) -> None

Constructs from term structures and fixed value (handles created internally).

local_surface = ql.LocalVolSurface(black_vol, risk_free, dividend, 100.0)
print(local_surface.localVol(1.0, 100.0))

FixedLocalVolSurface

class pyquantlib.FixedLocalVolSurface

Bases: LocalVolTermStructure

Fixed local volatility surface with strike/time grid.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(referenceDate: Date, dates: collections.abc.Sequence[Date], strikes: collections.abc.Sequence[SupportsFloat | SupportsIndex], localVolMatrix: Matrix, dayCounter: DayCounter, lowerExtrapolation: FixedLocalVolExtrapolation = <FixedLocalVolExtrapolation.ConstantExtrapolation: 0>, upperExtrapolation: FixedLocalVolExtrapolation = <FixedLocalVolExtrapolation.ConstantExtrapolation: 0>) -> None

Constructs from dates and uniform strikes.

  1. __init__(referenceDate: Date, times: collections.abc.Sequence[SupportsFloat | SupportsIndex], strikes: collections.abc.Sequence[SupportsFloat | SupportsIndex], localVolMatrix: Matrix, dayCounter: DayCounter, lowerExtrapolation: FixedLocalVolExtrapolation = <FixedLocalVolExtrapolation.ConstantExtrapolation: 0>, upperExtrapolation: FixedLocalVolExtrapolation = <FixedLocalVolExtrapolation.ConstantExtrapolation: 0>) -> None

Constructs from times and uniform strikes.

  1. __init__(referenceDate: Date, times: collections.abc.Sequence[SupportsFloat | SupportsIndex], strikes: collections.abc.Sequence[collections.abc.Sequence[SupportsFloat | SupportsIndex]], localVolMatrix: Matrix, dayCounter: DayCounter, lowerExtrapolation: FixedLocalVolExtrapolation = <FixedLocalVolExtrapolation.ConstantExtrapolation: 0>, upperExtrapolation: FixedLocalVolExtrapolation = <FixedLocalVolExtrapolation.ConstantExtrapolation: 0>) -> None

Constructs from times and varying strikes per time point.

maxDate() Date

Returns the maximum date.

maxStrike() float

Returns the maximum strike.

maxTime() float

Returns the maximum time.

minStrike() float

Returns the minimum strike.

import numpy as np

dates = [ref_date + ql.Period(i, ql.Months) for i in [1, 3, 6]]
strikes = [90.0, 100.0, 110.0]
vol_matrix = ql.Matrix(np.array([[0.22, 0.21, 0.20], ...]))

surface = ql.FixedLocalVolSurface(ref_date, dates, strikes, vol_matrix, dc)

NoExceptLocalVolSurface

class pyquantlib.NoExceptLocalVolSurface

Bases: LocalVolSurface

Local volatility surface that returns a fallback value instead of throwing.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(blackTS: BlackVolTermStructureHandle, riskFreeTS: YieldTermStructureHandle, dividendTS: YieldTermStructureHandle, underlying: QuoteHandle, illegalLocalVolOverwrite: SupportsFloat | SupportsIndex) -> None

Constructs with quote handle for underlying.

  1. __init__(blackTS: BlackVolTermStructureHandle, riskFreeTS: YieldTermStructureHandle, dividendTS: YieldTermStructureHandle, underlying: SupportsFloat | SupportsIndex, illegalLocalVolOverwrite: SupportsFloat | SupportsIndex) -> None

Constructs with fixed underlying value.

  1. __init__(blackTS: base.BlackVolTermStructure, riskFreeTS: base.YieldTermStructure, dividendTS: base.YieldTermStructure, underlying: base.Quote, illegalLocalVolOverwrite: SupportsFloat | SupportsIndex) -> None

Constructs from term structures and quote (handles created internally).

  1. __init__(blackTS: base.BlackVolTermStructure, riskFreeTS: base.YieldTermStructure, dividendTS: base.YieldTermStructure, underlying: SupportsFloat | SupportsIndex, illegalLocalVolOverwrite: SupportsFloat | SupportsIndex) -> None

Constructs from term structures and fixed value (handles created internally).

LocalVolTermStructureHandle

class pyquantlib.LocalVolTermStructureHandle

Bases: pybind11_object

Handle to LocalVolTermStructure.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__() -> None

Creates an empty handle.

  1. __init__(ptr: object, registerAsObserver: bool = True) -> None

Creates a handle linked to the given object.

asObservable() Observable

Converts to Observable for observer registration.

Returns the shared_ptr to the current object link.

empty() bool

Returns true if the handle is empty.

get() base.LocalVolTermStructure

Returns the underlying shared_ptr. Raises error if empty.

RelinkableLocalVolTermStructureHandle

class pyquantlib.RelinkableLocalVolTermStructureHandle

Bases: LocalVolTermStructureHandle

Relinkable handle to LocalVolTermStructure.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__() -> None

Creates an empty relinkable handle.

  1. __init__(ptr: object, registerAsObserver: bool = True) -> None

Creates a relinkable handle linked to the given object.

linkTo(ptr: object = None, registerAsObserver: bool = True) None

Links the handle to a new object instance. Notifies observers.

Swaption Volatility Term Structures

ConstantSwaptionVolatility

class pyquantlib.ConstantSwaptionVolatility

Bases: SwaptionVolatilityStructure

Constant swaption volatility, no time-strike dependence.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, businessDayConvention: BusinessDayConvention, volatility: SupportsFloat | SupportsIndex, dayCounter: DayCounter, type: VolatilityType = <VolatilityType.ShiftedLognormal: 0>, shift: SupportsFloat | SupportsIndex = 0.0) -> None

Constructs from settlement days and constant volatility.

  1. __init__(referenceDate: Date, calendar: Calendar, businessDayConvention: BusinessDayConvention, volatility: SupportsFloat | SupportsIndex, dayCounter: DayCounter, type: VolatilityType = <VolatilityType.ShiftedLognormal: 0>, shift: SupportsFloat | SupportsIndex = 0.0) -> None

Constructs from reference date and constant volatility.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, businessDayConvention: BusinessDayConvention, volatility: QuoteHandle, dayCounter: DayCounter, type: VolatilityType = <VolatilityType.ShiftedLognormal: 0>, shift: SupportsFloat | SupportsIndex = 0.0) -> None

Constructs from settlement days and quote handle.

  1. __init__(referenceDate: Date, calendar: Calendar, businessDayConvention: BusinessDayConvention, volatility: QuoteHandle, dayCounter: DayCounter, type: VolatilityType = <VolatilityType.ShiftedLognormal: 0>, shift: SupportsFloat | SupportsIndex = 0.0) -> None

Constructs from reference date and quote handle.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, businessDayConvention: BusinessDayConvention, volatility: base.Quote, dayCounter: DayCounter, type: VolatilityType = <VolatilityType.ShiftedLognormal: 0>, shift: SupportsFloat | SupportsIndex = 0.0) -> None

Constructs from settlement days and quote (handle created internally).

  1. __init__(referenceDate: Date, calendar: Calendar, businessDayConvention: BusinessDayConvention, volatility: base.Quote, dayCounter: DayCounter, type: VolatilityType = <VolatilityType.ShiftedLognormal: 0>, shift: SupportsFloat | SupportsIndex = 0.0) -> None

Constructs from reference date and quote (handle created internally).

volatilityType() VolatilityType

Returns the volatility type.

const_vol = ql.ConstantSwaptionVolatility(
    0, ql.TARGET(), ql.Following, 0.20, ql.Actual365Fixed()
)

SwaptionVolatilityMatrix

class pyquantlib.SwaptionVolatilityMatrix

Bases: SwaptionVolatilityDiscrete

Discrete swaption volatility surface backed by a matrix.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(calendar: Calendar, businessDayConvention: BusinessDayConvention, optionTenors: collections.abc.Sequence[Period], swapTenors: collections.abc.Sequence[Period], volatilities: Matrix, dayCounter: DayCounter, flatExtrapolation: bool = False, type: VolatilityType = <VolatilityType.ShiftedLognormal: 0>, shifts: Matrix = Matrix(0, 0)) -> None

Constructs from calendar with fixed volatility matrix.

  1. __init__(referenceDate: Date, calendar: Calendar, businessDayConvention: BusinessDayConvention, optionTenors: collections.abc.Sequence[Period], swapTenors: collections.abc.Sequence[Period], volatilities: Matrix, dayCounter: DayCounter, flatExtrapolation: bool = False, type: VolatilityType = <VolatilityType.ShiftedLognormal: 0>, shifts: Matrix = Matrix(0, 0)) -> None

Constructs from reference date with fixed volatility matrix.

  1. __init__(calendar: Calendar, businessDayConvention: BusinessDayConvention, optionTenors: collections.abc.Sequence[Period], swapTenors: collections.abc.Sequence[Period], volatilities: collections.abc.Sequence[collections.abc.Sequence[QuoteHandle]], dayCounter: DayCounter, flatExtrapolation: bool = False, type: VolatilityType = <VolatilityType.ShiftedLognormal: 0>, shifts: collections.abc.Sequence[collections.abc.Sequence[SupportsFloat | SupportsIndex]] = []) -> None

Constructs from calendar with quote handle matrix.

  1. __init__(referenceDate: Date, calendar: Calendar, businessDayConvention: BusinessDayConvention, optionTenors: collections.abc.Sequence[Period], swapTenors: collections.abc.Sequence[Period], volatilities: collections.abc.Sequence[collections.abc.Sequence[QuoteHandle]], dayCounter: DayCounter, flatExtrapolation: bool = False, type: VolatilityType = <VolatilityType.ShiftedLognormal: 0>, shifts: collections.abc.Sequence[collections.abc.Sequence[SupportsFloat | SupportsIndex]] = []) -> None

Constructs from reference date with quote handle matrix.

  1. __init__(referenceDate: Date, calendar: Calendar, businessDayConvention: BusinessDayConvention, optionDates: collections.abc.Sequence[Date], swapTenors: collections.abc.Sequence[Period], volatilities: Matrix, dayCounter: DayCounter, flatExtrapolation: bool = False, type: VolatilityType = <VolatilityType.ShiftedLognormal: 0>, shifts: Matrix = Matrix(0, 0)) -> None

Constructs from reference date with option dates and matrix.

locate(*args, **kwargs)

Overloaded function.

  1. locate(optionDate: Date, swapTenor: Period) -> tuple[int, int]

Returns row/column index pair for given option date and swap tenor.

  1. locate(optionTime: SupportsFloat | SupportsIndex, swapLength: SupportsFloat | SupportsIndex) -> tuple[int, int]

Returns row/column index pair for given option time and swap length.

SwaptionVolatilityCube

class pyquantlib.SwaptionVolatilityCube

Bases: SwaptionVolatilityDiscrete

Abstract base for swaption volatility cubes with smile.

__init__(*args, **kwargs)
atmStrike(*args, **kwargs)

Overloaded function.

  1. atmStrike(optionDate: Date, swapTenor: Period) -> float

Returns ATM strike for option date and swap tenor.

  1. atmStrike(optionTenor: Period, swapTenor: Period) -> float

Returns ATM strike for option tenor and swap tenor.

atmVol() SwaptionVolatilityStructureHandle

Returns the ATM volatility structure handle.

shortSwapIndexBase() SwapIndex

Returns the short swap index base.

strikeSpreads() list[float]

Returns the strike spreads.

swapIndexBase() SwapIndex

Returns the swap index base.

vegaWeightedSmileFit() bool

Returns whether smile fit is vega-weighted.

volSpreads() list[list[QuoteHandle]]

Returns the volatility spread handles.

SabrSwaptionVolatilityCube

class pyquantlib.SabrSwaptionVolatilityCube

Bases: SwaptionVolatilityCube

SABR-parameterized swaption volatility cube.

__init__(atmVolStructure: SwaptionVolatilityStructureHandle, optionTenors: collections.abc.Sequence[Period], swapTenors: collections.abc.Sequence[Period], strikeSpreads: collections.abc.Sequence[SupportsFloat | SupportsIndex], volSpreads: collections.abc.Sequence[collections.abc.Sequence[QuoteHandle]], swapIndexBase: SwapIndex, shortSwapIndexBase: SwapIndex, vegaWeightedSmileFit: bool, parametersGuess: collections.abc.Sequence[collections.abc.Sequence[QuoteHandle]], isParameterFixed: collections.abc.Sequence[bool], isAtmCalibrated: bool, endCriteria: EndCriteria = None, maxErrorTolerance: object = None, optMethod: base.OptimizationMethod = None, errorAccept: object = None, useMaxError: bool = False, maxGuesses: SupportsInt | SupportsIndex = 50, backwardFlat: bool = False, cutoffStrike: SupportsFloat | SupportsIndex = 0.0001) None

Constructs SABR swaption volatility cube.

denseSabrParameters() Matrix

Returns dense SABR parameters matrix.

marketVolCube() Matrix

Returns the market volatility cube.

recalibration(*args, **kwargs)

Overloaded function.

  1. recalibration(beta: SupportsFloat | SupportsIndex, swapTenor: Period) -> None

Recalibrates with fixed beta for a given swap tenor.

  1. recalibration(beta: collections.abc.Sequence[SupportsFloat | SupportsIndex], swapTenor: Period) -> None

Recalibrates with beta vector for a given swap tenor.

sparseSabrParameters() Matrix

Returns sparse SABR parameters matrix.

updateAfterRecalibration() None

Updates internal state after recalibration.

volCubeAtmCalibrated() Matrix

Returns the ATM-calibrated volatility cube.

SwaptionVolatilityStructureHandle

class pyquantlib.SwaptionVolatilityStructureHandle

Bases: pybind11_object

Handle to SwaptionVolatilityStructure.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__() -> None

Creates an empty handle.

  1. __init__(ptr: object, registerAsObserver: bool = True) -> None

Creates a handle linked to the given object.

asObservable() Observable

Converts to Observable for observer registration.

Returns the shared_ptr to the current object link.

empty() bool

Returns true if the handle is empty.

get() base.SwaptionVolatilityStructure

Returns the underlying shared_ptr. Raises error if empty.

RelinkableSwaptionVolatilityStructureHandle

class pyquantlib.RelinkableSwaptionVolatilityStructureHandle

Bases: SwaptionVolatilityStructureHandle

Relinkable handle to SwaptionVolatilityStructure.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__() -> None

Creates an empty relinkable handle.

  1. __init__(ptr: object, registerAsObserver: bool = True) -> None

Creates a relinkable handle linked to the given object.

linkTo(ptr: object = None, registerAsObserver: bool = True) None

Links the handle to a new object instance. Notifies observers.

Optionlet Volatility Term Structures

ConstantOptionletVolatility

class pyquantlib.ConstantOptionletVolatility

Bases: OptionletVolatilityStructure

Constant optionlet volatility, no time-strike dependence.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, businessDayConvention: BusinessDayConvention, volatility: SupportsFloat | SupportsIndex, dayCounter: DayCounter, type: VolatilityType = <VolatilityType.ShiftedLognormal: 0>, displacement: SupportsFloat | SupportsIndex = 0.0) -> None

Constructs from settlement days and constant volatility.

  1. __init__(referenceDate: Date, calendar: Calendar, businessDayConvention: BusinessDayConvention, volatility: SupportsFloat | SupportsIndex, dayCounter: DayCounter, type: VolatilityType = <VolatilityType.ShiftedLognormal: 0>, displacement: SupportsFloat | SupportsIndex = 0.0) -> None

Constructs from reference date and constant volatility.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, businessDayConvention: BusinessDayConvention, volatility: QuoteHandle, dayCounter: DayCounter, type: VolatilityType = <VolatilityType.ShiftedLognormal: 0>, displacement: SupportsFloat | SupportsIndex = 0.0) -> None

Constructs from settlement days and quote handle.

  1. __init__(referenceDate: Date, calendar: Calendar, businessDayConvention: BusinessDayConvention, volatility: QuoteHandle, dayCounter: DayCounter, type: VolatilityType = <VolatilityType.ShiftedLognormal: 0>, displacement: SupportsFloat | SupportsIndex = 0.0) -> None

Constructs from reference date and quote handle.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, businessDayConvention: BusinessDayConvention, volatility: base.Quote, dayCounter: DayCounter, type: VolatilityType = <VolatilityType.ShiftedLognormal: 0>, displacement: SupportsFloat | SupportsIndex = 0.0) -> None

Constructs from settlement days and quote (handle created internally).

  1. __init__(referenceDate: Date, calendar: Calendar, businessDayConvention: BusinessDayConvention, volatility: base.Quote, dayCounter: DayCounter, type: VolatilityType = <VolatilityType.ShiftedLognormal: 0>, displacement: SupportsFloat | SupportsIndex = 0.0) -> None

Constructs from reference date and quote (handle created internally).

const_vol = ql.ConstantOptionletVolatility(
    0, ql.TARGET(), ql.Following, 0.20, ql.Actual365Fixed()
)

OptionletVolatilityStructureHandle

class pyquantlib.OptionletVolatilityStructureHandle

Bases: pybind11_object

Handle to OptionletVolatilityStructure.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__() -> None

Creates an empty handle.

  1. __init__(ptr: object, registerAsObserver: bool = True) -> None

Creates a handle linked to the given object.

asObservable() Observable

Converts to Observable for observer registration.

Returns the shared_ptr to the current object link.

empty() bool

Returns true if the handle is empty.

get() base.OptionletVolatilityStructure

Returns the underlying shared_ptr. Raises error if empty.

RelinkableOptionletVolatilityStructureHandle

class pyquantlib.RelinkableOptionletVolatilityStructureHandle

Bases: OptionletVolatilityStructureHandle

Relinkable handle to OptionletVolatilityStructure.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__() -> None

Creates an empty relinkable handle.

  1. __init__(ptr: object, registerAsObserver: bool = True) -> None

Creates a relinkable handle linked to the given object.

linkTo(ptr: object = None, registerAsObserver: bool = True) None

Links the handle to a new object instance. Notifies observers.

YoY Inflation Optionlet Volatility

YoYOptionletVolatilitySurface

class pyquantlib.base.YoYOptionletVolatilitySurface

Bases: VolatilityTermStructure

Abstract base class for YoY inflation optionlet volatility.

__init__(*args, **kwargs)
baseDate() Date

Returns the base date.

baseLevel() float

Returns the base level of volatility.

displacement() float

Returns the displacement for shifted lognormal.

frequency() Frequency

Returns the frequency.

indexIsInterpolated() bool

Returns whether the index is interpolated.

observationLag() Period

Returns the observation lag.

totalVariance(exerciseDate: Date, strike: SupportsFloat | SupportsIndex, obsLag: Period = <Period: -1D>, extrapolate: bool = False) float

Returns the total variance.

volatility(*args, **kwargs)

Overloaded function.

  1. volatility(maturityDate: Date, strike: SupportsFloat | SupportsIndex, obsLag: Period = <Period: -1D>, extrapolate: bool = False) -> float

Returns the volatility for a given maturity date and strike.

  1. volatility(optionTenor: Period, strike: SupportsFloat | SupportsIndex, obsLag: Period = <Period: -1D>, extrapolate: bool = False) -> float

Returns the volatility for a given option tenor and strike.

volatilityType() VolatilityType

Returns the volatility type.

Abstract base class for year-on-year inflation optionlet volatility surfaces.

ConstantYoYOptionletVolatility

class pyquantlib.ConstantYoYOptionletVolatility

Bases: YoYOptionletVolatilitySurface

Constant YoY inflation optionlet volatility.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(volatility: SupportsFloat | SupportsIndex, settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, bdc: BusinessDayConvention, dayCounter: DayCounter, observationLag: Period, frequency: Frequency, indexIsInterpolated: bool, minStrike: SupportsFloat | SupportsIndex = -1.0, maxStrike: SupportsFloat | SupportsIndex = 100.0, volatilityType: VolatilityType = <VolatilityType.ShiftedLognormal: 0>, displacement: SupportsFloat | SupportsIndex = 0.0) -> None

Constructs with a constant volatility value.

  1. __init__(volatility: QuoteHandle, settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, bdc: BusinessDayConvention, dayCounter: DayCounter, observationLag: Period, frequency: Frequency, indexIsInterpolated: bool, minStrike: SupportsFloat | SupportsIndex = -1.0, maxStrike: SupportsFloat | SupportsIndex = 100.0, volatilityType: VolatilityType = <VolatilityType.ShiftedLognormal: 0>, displacement: SupportsFloat | SupportsIndex = 0.0) -> None

Constructs with a volatility quote.

  1. __init__(volatility: base.Quote, settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, bdc: BusinessDayConvention, dayCounter: DayCounter, observationLag: Period, frequency: Frequency, indexIsInterpolated: bool, minStrike: SupportsFloat | SupportsIndex = -1.0, maxStrike: SupportsFloat | SupportsIndex = 100.0, volatilityType: VolatilityType = <VolatilityType.ShiftedLognormal: 0>, displacement: SupportsFloat | SupportsIndex = 0.0) -> None

Constructs with a volatility quote (handle created internally).

Constant year-on-year inflation optionlet volatility.

yoy_vol = ql.ConstantYoYOptionletVolatility(
    0.10, 0, ql.TARGET(), ql.ModifiedFollowing, ql.Actual365Fixed(),
    ql.Period(3, ql.Months), ql.Monthly,
)

YoYOptionletVolatilitySurfaceHandle

class pyquantlib.YoYOptionletVolatilitySurfaceHandle

Bases: pybind11_object

Handle to YoYOptionletVolatilitySurface.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__() -> None

Creates an empty handle.

  1. __init__(ptr: object, registerAsObserver: bool = True) -> None

Creates a handle linked to the given object.

asObservable() Observable

Converts to Observable for observer registration.

Returns the shared_ptr to the current object link.

empty() bool

Returns true if the handle is empty.

get() base.YoYOptionletVolatilitySurface

Returns the underlying shared_ptr. Raises error if empty.

RelinkableYoYOptionletVolatilitySurfaceHandle

class pyquantlib.RelinkableYoYOptionletVolatilitySurfaceHandle

Bases: YoYOptionletVolatilitySurfaceHandle

Relinkable handle to YoYOptionletVolatilitySurface.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__() -> None

Creates an empty relinkable handle.

  1. __init__(ptr: object, registerAsObserver: bool = True) -> None

Creates a relinkable handle linked to the given object.

linkTo(ptr: object = None, registerAsObserver: bool = True) None

Links the handle to a new object instance. Notifies observers.

Cap/Floor Term Volatility

CapFloorTermVolSurface

class pyquantlib.CapFloorTermVolSurface

Bases: LazyObject, CapFloorTermVolatilityStructure

Cap/floor smile volatility surface.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, businessDayConvention: BusinessDayConvention, optionTenors: collections.abc.Sequence[Period], strikes: collections.abc.Sequence[SupportsFloat | SupportsIndex], volatilities: Matrix, dayCounter: DayCounter = <DayCounter: Actual/365 (Fixed)>) -> None

Constructs from settlement days and volatility matrix.

  1. __init__(settlementDate: Date, calendar: Calendar, businessDayConvention: BusinessDayConvention, optionTenors: collections.abc.Sequence[Period], strikes: collections.abc.Sequence[SupportsFloat | SupportsIndex], volatilities: Matrix, dayCounter: DayCounter = <DayCounter: Actual/365 (Fixed)>) -> None

Constructs from settlement date and volatility matrix.

maxDate() Date

Returns the maximum date.

maxStrike() float

Returns the maximum strike.

minStrike() float

Returns the minimum strike.

optionDates() list[Date]

Returns the option dates.

optionTenors() list[Period]

Returns the option tenors.

optionTimes() list[float]

Returns the option times.

strikes() list[float]

Returns the strikes.

Cap/floor smile volatility surface interpolating market term volatilities.

option_tenors = [ql.Period("1Y"), ql.Period("2Y"), ql.Period("5Y")]
strikes = [0.01, 0.02, 0.03, 0.04, 0.05]
vols = ql.Matrix(3, 5)  # populate with market volatilities

surface = ql.CapFloorTermVolSurface(
    2, ql.TARGET(), ql.ModifiedFollowing,
    option_tenors, strikes, vols, ql.Actual365Fixed()
)
print(surface.volatility(ql.Period("1Y"), 0.03))

Optionlet Stripping

OptionletStripper1

class pyquantlib.OptionletStripper1

Bases: OptionletStripper

Strips optionlet volatilities from a cap/floor term volatility surface.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(termVolSurface: CapFloorTermVolSurface, index: IborIndex, switchStrike: object = None, accuracy: SupportsFloat | SupportsIndex = 1e-06, maxIter: SupportsInt | SupportsIndex = 100, discount: YieldTermStructureHandle = <YieldTermStructureHandle object at 0x7f252f3d85b0>, type: VolatilityType = <VolatilityType.ShiftedLognormal: 0>, displacement: SupportsFloat | SupportsIndex = 0.0, dontThrow: bool = False, optionletFrequency: object = None) -> None

Constructs an optionlet stripper.

  1. __init__(termVolSurface: CapFloorTermVolSurface, index: IborIndex, switchStrike: object = None, accuracy: SupportsFloat | SupportsIndex = 1e-06, maxIter: SupportsInt | SupportsIndex = 100, discount: base.YieldTermStructure, type: VolatilityType = <VolatilityType.ShiftedLognormal: 0>, displacement: SupportsFloat | SupportsIndex = 0.0, dontThrow: bool = False, optionletFrequency: object = None) -> None

Constructs an optionlet stripper (handle created internally).

capFloorPrices() Matrix

Returns the cap/floor prices matrix.

capFloorVolatilities() Matrix

Returns the cap/floor volatilities matrix.

capletVols() Matrix

Returns the caplet volatilities matrix.

optionletPrices() Matrix

Returns the optionlet prices matrix.

switchStrike() float

Returns the switch strike.

Strips optionlet (caplet/floorlet) volatilities from a cap/floor term volatility surface.

# Build cap/floor vol surface (see above)
index = ql.Euribor(ql.Period("6M"), ts_handle)
stripper = ql.OptionletStripper1(surface, index, discount=ts_handle)

# Access stripped optionlet data
n = stripper.optionletMaturities()
for i in range(n):
    print(stripper.optionletStrikes(i))
    print(stripper.optionletVolatilities(i))

StrippedOptionletAdapter

class pyquantlib.StrippedOptionletAdapter

Bases: OptionletVolatilityStructure, LazyObject

Adapts stripped optionlet data into an OptionletVolatilityStructure.

__init__(optionletStripper: base.StrippedOptionletBase) None

Constructs from a StrippedOptionletBase.

displacement() float

Returns the displacement for shifted lognormal volatilities.

maxDate() Date

Returns the maximum date.

maxStrike() float

Returns the maximum strike.

minStrike() float

Returns the minimum strike.

volatilityType() VolatilityType

Returns the volatility type.

Adapts stripped optionlet data into an OptionletVolatilityStructure for use with pricing engines.

adapter = ql.StrippedOptionletAdapter(stripper)
handle = ql.OptionletVolatilityStructureHandle(adapter)
vol = adapter.volatility(ql.Period("1Y"), 0.03)

Credit Term Structures

DefaultProbabilityTermStructureHandle

class pyquantlib.DefaultProbabilityTermStructureHandle

Bases: pybind11_object

Handle to DefaultProbabilityTermStructure.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__() -> None

Creates an empty handle.

  1. __init__(ptr: object, registerAsObserver: bool = True) -> None

Creates a handle linked to the given object.

asObservable() Observable

Converts to Observable for observer registration.

Returns the shared_ptr to the current object link.

empty() bool

Returns true if the handle is empty.

get() base.DefaultProbabilityTermStructure

Returns the underlying shared_ptr. Raises error if empty.

RelinkableDefaultProbabilityTermStructureHandle

class pyquantlib.RelinkableDefaultProbabilityTermStructureHandle

Bases: DefaultProbabilityTermStructureHandle

Relinkable handle to DefaultProbabilityTermStructure.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__() -> None

Creates an empty relinkable handle.

  1. __init__(ptr: object, registerAsObserver: bool = True) -> None

Creates a relinkable handle linked to the given object.

linkTo(ptr: object = None, registerAsObserver: bool = True) None

Links the handle to a new object instance. Notifies observers.

FlatHazardRate

class pyquantlib.FlatHazardRate

Bases: DefaultProbabilityTermStructure

Flat hazard rate term structure.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(referenceDate: Date, hazardRate: SupportsFloat | SupportsIndex, dayCounter: DayCounter) -> None

Constructs from date and hazard rate.

  1. __init__(referenceDate: Date, hazardRate: QuoteHandle, dayCounter: DayCounter) -> None

Constructs from date and hazard rate quote handle.

  1. __init__(referenceDate: Date, hazardRate: base.Quote, dayCounter: DayCounter) -> None

Constructs from date and hazard rate quote.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, hazardRate: SupportsFloat | SupportsIndex, dayCounter: DayCounter) -> None

Constructs from settlement days and hazard rate.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, hazardRate: QuoteHandle, dayCounter: DayCounter) -> None

Constructs from settlement days and hazard rate quote handle.

maxDate() Date

Maximum date.

Flat hazard rate default probability term structure.

today = ql.Date(15, 1, 2025)
dc = ql.Actual365Fixed()
default_curve = ql.FlatHazardRate(today, 0.01, dc)
print(default_curve.survivalProbability(1.0))  # ~0.99
print(default_curve.defaultProbability(1.0))   # ~0.01
print(default_curve.hazardRate(1.0))           # 0.01

Default Probability Helpers

SpreadCdsHelper

class pyquantlib.SpreadCdsHelper

Bases: DefaultProbabilityHelper

Spread-quoted CDS bootstrap helper.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(runningSpread: SupportsFloat | SupportsIndex, tenor: Period, settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, frequency: Frequency, paymentConvention: BusinessDayConvention, rule: DateGeneration.Rule, dayCounter: DayCounter, recoveryRate: SupportsFloat | SupportsIndex, discountCurve: YieldTermStructureHandle, settlesAccrual: bool = True, paysAtDefaultTime: bool = True, startDate: Date = <Date: null date>, lastPeriodDayCounter: object = None, rebatesAccrual: bool = True, model: CdsPricingModel = <CdsPricingModel.Midpoint: 0>) -> None

Constructs from running spread.

  1. __init__(runningSpread: QuoteHandle, tenor: Period, settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, frequency: Frequency, paymentConvention: BusinessDayConvention, rule: DateGeneration.Rule, dayCounter: DayCounter, recoveryRate: SupportsFloat | SupportsIndex, discountCurve: YieldTermStructureHandle, settlesAccrual: bool = True, paysAtDefaultTime: bool = True, startDate: Date = <Date: null date>, lastPeriodDayCounter: object = None, rebatesAccrual: bool = True, model: CdsPricingModel = <CdsPricingModel.Midpoint: 0>) -> None

Constructs from running spread quote.

Bootstrap helper for spread-quoted CDS.

helper = ql.SpreadCdsHelper(
    0.01, ql.Period(5, ql.Years), 1, ql.TARGET(),
    ql.Quarterly, ql.Following, ql.DateGeneration.TwentiethIMM,
    ql.Actual360(), 0.4, discount_curve,
)

UpfrontCdsHelper

class pyquantlib.UpfrontCdsHelper

Bases: DefaultProbabilityHelper

Upfront-quoted CDS bootstrap helper.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(upfront: SupportsFloat | SupportsIndex, runningSpread: SupportsFloat | SupportsIndex, tenor: Period, settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, frequency: Frequency, paymentConvention: BusinessDayConvention, rule: DateGeneration.Rule, dayCounter: DayCounter, recoveryRate: SupportsFloat | SupportsIndex, discountCurve: YieldTermStructureHandle, upfrontSettlementDays: SupportsInt | SupportsIndex = 3, settlesAccrual: bool = True, paysAtDefaultTime: bool = True, startDate: Date = <Date: null date>, lastPeriodDayCounter: object = None, rebatesAccrual: bool = True, model: CdsPricingModel = <CdsPricingModel.Midpoint: 0>) -> None

Constructs from upfront and running spread.

  1. __init__(upfront: QuoteHandle, runningSpread: SupportsFloat | SupportsIndex, tenor: Period, settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, frequency: Frequency, paymentConvention: BusinessDayConvention, rule: DateGeneration.Rule, dayCounter: DayCounter, recoveryRate: SupportsFloat | SupportsIndex, discountCurve: YieldTermStructureHandle, upfrontSettlementDays: SupportsInt | SupportsIndex = 3, settlesAccrual: bool = True, paysAtDefaultTime: bool = True, startDate: Date = <Date: null date>, lastPeriodDayCounter: object = None, rebatesAccrual: bool = True, model: CdsPricingModel = <CdsPricingModel.Midpoint: 0>) -> None

Constructs from upfront quote and running spread.

Bootstrap helper for upfront-quoted CDS.

helper = ql.UpfrontCdsHelper(
    0.02, 0.01, ql.Period(5, ql.Years), 1, ql.TARGET(),
    ql.Quarterly, ql.Following, ql.DateGeneration.TwentiethIMM,
    ql.Actual360(), 0.4, discount_curve,
)

Piecewise Default Curves

PiecewiseLogLinearSurvival

class pyquantlib.PiecewiseLogLinearSurvival

Bases: DefaultProbabilityTermStructure

Piecewise default curve using log-linear survival probability.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(referenceDate: Date, instruments: collections.abc.Sequence[base.DefaultProbabilityHelper], dayCounter: DayCounter) -> None

Constructs from reference date, instruments, and day counter.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, instruments: collections.abc.Sequence[base.DefaultProbabilityHelper], dayCounter: DayCounter) -> None

Constructs from settlement days, calendar, instruments, and day counter.

data() list[float]

Returns the interpolated data values.

dates() list[Date]

Returns the interpolation dates.

nodes() list[tuple[Date, float]]

Returns (date, value) pairs for all nodes.

times() list[float]

Returns the interpolation times.

PiecewiseFlatHazardRate

pyquantlib.PiecewiseFlatHazardRate

alias of PiecewiseBackwardFlatHazard

PiecewiseBackwardFlatHazard

class pyquantlib.PiecewiseBackwardFlatHazard

Bases: DefaultProbabilityTermStructure

Piecewise default curve using backward-flat hazard rate.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(referenceDate: Date, instruments: collections.abc.Sequence[base.DefaultProbabilityHelper], dayCounter: DayCounter) -> None

Constructs from reference date, instruments, and day counter.

  1. __init__(settlementDays: SupportsInt | SupportsIndex, calendar: Calendar, instruments: collections.abc.Sequence[base.DefaultProbabilityHelper], dayCounter: DayCounter) -> None

Constructs from settlement days, calendar, instruments, and day counter.

data() list[float]

Returns the interpolated data values.

dates() list[Date]

Returns the interpolation dates.

nodes() list[tuple[Date, float]]

Returns (date, value) pairs for all nodes.

times() list[float]

Returns the interpolation times.

Bootstrap a default probability curve from CDS helpers.

helpers = [
    ql.SpreadCdsHelper(spread, tenor, 1, ql.TARGET(),
                       ql.Quarterly, ql.Following,
                       ql.DateGeneration.TwentiethIMM,
                       ql.Actual360(), 0.4, discount_curve)
    for spread, tenor in zip(spreads, tenors)
]
curve = ql.PiecewiseLogLinearSurvival(today, helpers, ql.Actual365Fixed())
print(curve.survivalProbability(1.0))
print(curve.nodes())

Inflation Term Structures

InflationTermStructure

class pyquantlib.base.InflationTermStructure

Bases: TermStructure

Abstract base class for inflation term structures.

__init__(*args, **kwargs)
baseDate() Date

Returns the base date.

baseRate() float

Returns the base rate.

frequency() Frequency

Returns the frequency of the inflation index.

hasSeasonality() bool

Returns true if a seasonality correction is set.

seasonality() QuantLib::Seasonality

Returns the seasonality correction.

setSeasonality(seasonality: object = None) None

Sets the seasonality correction.

Base class for all inflation term structures. Provides frequency(), baseRate(), baseDate(), and hasSeasonality().

ZeroInflationTermStructure

class pyquantlib.base.ZeroInflationTermStructure

Bases: InflationTermStructure

Abstract base class for zero-coupon inflation term structures.

__init__(*args, **kwargs)
zeroRate(date: Date, extrapolate: bool = False) float

Returns the zero-coupon inflation rate for the given date.

Additional method: zeroRate(date, observationLag, forceLinearInterpolation=False, extrapolate=False).

YoYInflationTermStructure

class pyquantlib.base.YoYInflationTermStructure

Bases: InflationTermStructure

Abstract base class for year-on-year inflation term structures.

__init__(*args, **kwargs)
yoyRate(date: Date, extrapolate: bool = False) float

Returns the year-on-year inflation rate for the given date.

Additional method: yoyRate(date, observationLag, forceLinearInterpolation=False, extrapolate=False).

Inflation Handles

class pyquantlib.ZeroInflationTermStructureHandle

Bases: pybind11_object

Handle to ZeroInflationTermStructure.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__() -> None

Creates an empty handle.

  1. __init__(ptr: object, registerAsObserver: bool = True) -> None

Creates a handle linked to the given object.

asObservable() Observable

Converts to Observable for observer registration.

Returns the shared_ptr to the current object link.

empty() bool

Returns true if the handle is empty.

get() base.ZeroInflationTermStructure

Returns the underlying shared_ptr. Raises error if empty.

class pyquantlib.RelinkableZeroInflationTermStructureHandle

Bases: ZeroInflationTermStructureHandle

Relinkable handle to ZeroInflationTermStructure.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__() -> None

Creates an empty relinkable handle.

  1. __init__(ptr: object, registerAsObserver: bool = True) -> None

Creates a relinkable handle linked to the given object.

linkTo(ptr: object = None, registerAsObserver: bool = True) None

Links the handle to a new object instance. Notifies observers.

class pyquantlib.YoYInflationTermStructureHandle

Bases: pybind11_object

Handle to YoYInflationTermStructure.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__() -> None

Creates an empty handle.

  1. __init__(ptr: object, registerAsObserver: bool = True) -> None

Creates a handle linked to the given object.

asObservable() Observable

Converts to Observable for observer registration.

Returns the shared_ptr to the current object link.

empty() bool

Returns true if the handle is empty.

get() base.YoYInflationTermStructure

Returns the underlying shared_ptr. Raises error if empty.

class pyquantlib.RelinkableYoYInflationTermStructureHandle

Bases: YoYInflationTermStructureHandle

Relinkable handle to YoYInflationTermStructure.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__() -> None

Creates an empty relinkable handle.

  1. __init__(ptr: object, registerAsObserver: bool = True) -> None

Creates a relinkable handle linked to the given object.

linkTo(ptr: object = None, registerAsObserver: bool = True) None

Links the handle to a new object instance. Notifies observers.

inflationPeriod

pyquantlib.inflationPeriod(date: Date, frequency: Frequency) tuple[Date, Date]

Returns the start and end dates of the inflation period.

Returns the (start, end) date pair for the inflation period containing the given date.

start, end = ql.inflationPeriod(ql.Date(15, ql.March, 2024), ql.Monthly)
# start = Date(1, March, 2024), end = Date(31, March, 2024)

Seasonality

class pyquantlib.base.Seasonality

Bases: pybind11_object

Abstract base class for inflation seasonality corrections.

__init__() None
correctYoYRate(date: Date, rate: SupportsFloat | SupportsIndex, inflationTermStructure: base.InflationTermStructure) float

Returns the seasonality-corrected year-on-year rate.

correctZeroRate(date: Date, rate: SupportsFloat | SupportsIndex, inflationTermStructure: base.InflationTermStructure) float

Returns the seasonality-corrected zero rate.

isConsistent(inflationTermStructure: base.InflationTermStructure) bool

Returns true if the seasonality is consistent with the term structure.

class pyquantlib.MultiplicativePriceSeasonality

Bases: Seasonality

Multiplicative price seasonality correction.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__() -> None

Constructs a default (empty) seasonality.

  1. __init__(seasonalityBaseDate: Date, frequency: Frequency, seasonalityFactors: collections.abc.Sequence[SupportsFloat | SupportsIndex]) -> None

Constructs from base date, frequency, and factors.

frequency() Frequency

Returns the seasonality frequency.

seasonalityBaseDate() Date

Returns the seasonality base date.

seasonalityFactor(date: Date) float

Returns the seasonality factor for the given date.

seasonalityFactors() list[float]

Returns the seasonality factors.

set(seasonalityBaseDate: Date, frequency: Frequency, seasonalityFactors: collections.abc.Sequence[SupportsFloat | SupportsIndex]) None

Sets the seasonality parameters.

class pyquantlib.KerkhofSeasonality

Bases: MultiplicativePriceSeasonality

Kerkhof seasonality correction (monthly frequency).

__init__(seasonalityBaseDate: Date, seasonalityFactors: collections.abc.Sequence[SupportsFloat | SupportsIndex]) None

Constructs from base date and monthly factors.

factors = [1.0, 1.01, 1.02, 0.99, 0.98, 1.0, 1.01, 1.03, 0.97, 0.98, 1.0, 1.01]
seasonality = ql.MultiplicativePriceSeasonality(
    ql.Date(1, ql.January, 2024), ql.Monthly, factors
)
curve.setSeasonality(seasonality)

Inflation Bootstrap Helpers

class pyquantlib.base.ZeroInflationHelper

Bases: Observer, Observable

Bootstrap helper for zero-inflation term structures.

__init__(*args, **kwargs)
earliestDate() Date

Returns the earliest date.

impliedQuote() float

Returns the implied quote.

latestDate() Date

Returns the latest date.

latestRelevantDate() Date

Returns the latest relevant date.

maturityDate() Date

Returns the maturity date.

quote() QuoteHandle

Returns the market quote handle.

quoteError() float

Returns the difference between market and implied quotes.

class pyquantlib.base.YoYInflationHelper

Bases: Observer, Observable

Bootstrap helper for year-on-year inflation term structures.

__init__(*args, **kwargs)
earliestDate() Date

Returns the earliest date.

impliedQuote() float

Returns the implied quote.

latestDate() Date

Returns the latest date.

latestRelevantDate() Date

Returns the latest relevant date.

maturityDate() Date

Returns the maturity date.

quote() QuoteHandle

Returns the market quote handle.

quoteError() float

Returns the difference between market and implied quotes.

class pyquantlib.ZeroCouponInflationSwapHelper

Bases: RelativeDateZeroInflationHelper

Zero-coupon inflation swap bootstrap helper.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(quote: QuoteHandle, swapObsLag: Period, maturity: Date, calendar: Calendar, paymentConvention: BusinessDayConvention, dayCounter: DayCounter, zeroInflationIndex: ZeroInflationIndex, observationInterpolation: CPI.InterpolationType) -> None

Constructs from quote handle.

  1. __init__(quote: base.Quote, swapObsLag: Period, maturity: Date, calendar: Calendar, paymentConvention: BusinessDayConvention, dayCounter: DayCounter, zeroInflationIndex: ZeroInflationIndex, observationInterpolation: CPI.InterpolationType) -> None

Constructs from quote (handle created internally).

  1. __init__(rate: SupportsFloat | SupportsIndex, swapObsLag: Period, maturity: Date, calendar: Calendar, paymentConvention: BusinessDayConvention, dayCounter: DayCounter, zeroInflationIndex: ZeroInflationIndex, observationInterpolation: CPI.InterpolationType) -> None

Constructs from fixed rate.

swap() QuantLib::ZeroCouponInflationSwap

Returns the underlying zero-coupon inflation swap.

class pyquantlib.YearOnYearInflationSwapHelper

Bases: RelativeDateYoYInflationHelper

Year-on-year inflation swap bootstrap helper.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(quote: QuoteHandle, swapObsLag: Period, maturity: Date, calendar: Calendar, paymentConvention: BusinessDayConvention, dayCounter: DayCounter, yoyInflationIndex: YoYInflationIndex, interpolation: CPI.InterpolationType, nominalTermStructure: YieldTermStructureHandle) -> None

Constructs from quote handle.

  1. __init__(quote: base.Quote, swapObsLag: Period, maturity: Date, calendar: Calendar, paymentConvention: BusinessDayConvention, dayCounter: DayCounter, yoyInflationIndex: YoYInflationIndex, interpolation: CPI.InterpolationType, nominalTermStructure: YieldTermStructureHandle) -> None

Constructs from quote (handle created internally).

  1. __init__(rate: SupportsFloat | SupportsIndex, swapObsLag: Period, maturity: Date, calendar: Calendar, paymentConvention: BusinessDayConvention, dayCounter: DayCounter, yoyInflationIndex: YoYInflationIndex, interpolation: CPI.InterpolationType, nominalTermStructure: YieldTermStructureHandle) -> None

Constructs from fixed rate.

swap() QuantLib::YearOnYearInflationSwap

Returns the underlying year-on-year inflation swap.

helper = ql.ZeroCouponInflationSwapHelper(
    0.025,                          # quoted rate
    ql.Period(3, ql.Months),        # observation lag
    maturity_date, calendar, ql.ModifiedFollowing,
    day_counter, cpi_index, ql.CPI.Flat,
)

Interpolated Inflation Curves

class pyquantlib.ZeroInflationCurve

Bases: ZeroInflationTermStructure

Zero-inflation curve with linear interpolation.

__init__(referenceDate: Date, dates: collections.abc.Sequence[Date], rates: collections.abc.Sequence[SupportsFloat | SupportsIndex], frequency: Frequency, dayCounter: DayCounter, seasonality: object = None) None

Constructs from dates and zero rates.

data() list[float]

Returns the interpolated data values.

dates() list[Date]

Returns the interpolation dates.

nodes() list[tuple[Date, float]]

Returns (date, rate) pairs for all nodes.

rates() list[float]

Returns the zero inflation rates.

times() list[float]

Returns the interpolation times.

class pyquantlib.YoYInflationCurve

Bases: YoYInflationTermStructure

Year-on-year inflation curve with linear interpolation.

__init__(referenceDate: Date, dates: collections.abc.Sequence[Date], rates: collections.abc.Sequence[SupportsFloat | SupportsIndex], frequency: Frequency, dayCounter: DayCounter, seasonality: object = None) None

Constructs from dates and year-on-year rates.

data() list[float]

Returns the interpolated data values.

dates() list[Date]

Returns the interpolation dates.

nodes() list[tuple[Date, float]]

Returns (date, rate) pairs for all nodes.

rates() list[float]

Returns the year-on-year rates.

times() list[float]

Returns the interpolation times.

curve = ql.ZeroInflationCurve(
    reference_date, dates, rates, ql.Monthly, day_counter
)

Piecewise Inflation Curves

class pyquantlib.PiecewiseZeroInflationCurve

Bases: ZeroInflationTermStructure

Piecewise zero-inflation curve bootstrapped from helpers.

__init__(referenceDate: Date, baseDate: Date, frequency: Frequency, dayCounter: DayCounter, instruments: collections.abc.Sequence[base.ZeroInflationHelper], seasonality: object = None, accuracy: SupportsFloat | SupportsIndex = 1e-14) None

Constructs from reference date, base date, and helpers.

data() list[float]

Returns the interpolated data values.

dates() list[Date]

Returns the interpolation dates.

nodes() list[tuple[Date, float]]

Returns (date, value) pairs for all nodes.

times() list[float]

Returns the interpolation times.

class pyquantlib.PiecewiseYoYInflationCurve

Bases: YoYInflationTermStructure

Piecewise year-on-year inflation curve bootstrapped from helpers.

__init__(referenceDate: Date, baseDate: Date, baseYoYRate: SupportsFloat | SupportsIndex, frequency: Frequency, dayCounter: DayCounter, instruments: collections.abc.Sequence[base.YoYInflationHelper], seasonality: object = None, accuracy: SupportsFloat | SupportsIndex = 1e-12) None

Constructs from reference date, base date, base rate, and helpers.

data() list[float]

Returns the interpolated data values.

dates() list[Date]

Returns the interpolation dates.

nodes() list[tuple[Date, float]]

Returns (date, value) pairs for all nodes.

times() list[float]

Returns the interpolation times.

curve = ql.PiecewiseZeroInflationCurve(
    reference_date, base_date, ql.Monthly, day_counter, helpers
)

Note

Abstract base classes YieldTermStructure, BlackVolTermStructure, LocalVolTermStructure, SmileSection, DefaultProbabilityTermStructure, RateHelper, RelativeDateRateHelper, FittingMethod, SwaptionVolatilityStructure, SwaptionVolatilityDiscrete, OptionletVolatilityStructure, CapFloorTermVolatilityStructure, StrippedOptionletBase, OptionletStripper, InflationTermStructure, ZeroInflationTermStructure, YoYInflationTermStructure, Seasonality, ZeroInflationHelper, YoYInflationHelper, and YoYOptionletVolatilitySurface are available in pyquantlib.base.