Core Module¶
Settings¶
Settings¶
Global repository for run-time library settings.
ql.Settings is exported as the singleton instance, allowing direct property access.
Properties¶
Property |
Type |
Description |
|---|---|---|
|
|
The evaluation date for pricing calculations |
|
|
Whether events on the reference date are included |
|
|
Whether to include today’s cash flows |
|
|
Whether to enforce historic fixings for today |
Methods¶
Method |
Description |
|---|---|
|
Returns the singleton instance |
|
Sets the evaluation date |
|
Prevents the evaluation date from advancing automatically |
|
Resets evaluation date to today and allows automatic advancement |
Example¶
import pyquantlib as ql
# Set evaluation date
ql.Settings.evaluationDate = ql.Date(15, 6, 2025)
# Anchor the date (prevents automatic advancement)
ql.Settings.anchorEvaluationDate()
# Configure cash flow settings
ql.Settings.includeReferenceDateEvents = True
ql.Settings.includeTodaysCashFlows = True
ql.Settings.enforcesTodaysHistoricFixings = False
# Reset to today with automatic advancement
ql.Settings.resetEvaluationDate()
Tip
Both ql.Settings.evaluationDate and ql.Settings.instance().evaluationDate work identically.
Interest Rate¶
InterestRate¶
- class pyquantlib.InterestRate¶
Bases:
pybind11_objectInterest rate with compounding algebra.
- static impliedRate(*args, **kwargs)¶
Overloaded function.
impliedRate(compound: SupportsFloat | SupportsIndex, dayCounter: DayCounter, compounding: Compounding, frequency: Frequency, time: SupportsFloat | SupportsIndex) -> InterestRate
Implied rate from a compound factor over a time period.
impliedRate(compound: SupportsFloat | SupportsIndex, dayCounter: DayCounter, compounding: Compounding, frequency: Frequency, startDate: Date, endDate: Date, refStart: Date = <Date: null date>, refEnd: Date = <Date: null date>) -> InterestRate
Implied rate from a compound factor between two dates.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__() -> None
Default constructor returning a null interest rate.
__init__(rate: SupportsFloat | SupportsIndex, dayCounter: DayCounter, compounding: Compounding, frequency: Frequency) -> None
Construct an interest rate with the given parameters.
- compoundFactor(*args, **kwargs)¶
Overloaded function.
compoundFactor(time: SupportsFloat | SupportsIndex) -> float
Compound factor for a given time period.
compoundFactor(startDate: Date, endDate: Date, refStart: Date = <Date: null date>, refEnd: Date = <Date: null date>) -> float
Compound factor between two dates.
- compounding() Compounding¶
Returns the compounding convention.
- dayCounter() DayCounter¶
Returns the day counter.
- discountFactor(*args, **kwargs)¶
Overloaded function.
discountFactor(time: SupportsFloat | SupportsIndex) -> float
Discount factor for a given time period.
discountFactor(startDate: Date, endDate: Date, refStart: Date = <Date: null date>, refEnd: Date = <Date: null date>) -> float
Discount factor between two dates.
- equivalentRate(*args, **kwargs)¶
Overloaded function.
equivalentRate(compounding: Compounding, frequency: Frequency, time: SupportsFloat | SupportsIndex) -> InterestRate
Equivalent rate with different compounding over a time period.
equivalentRate(dayCounter: DayCounter, compounding: Compounding, frequency: Frequency, startDate: Date, endDate: Date, refStart: Date = <Date: null date>, refEnd: Date = <Date: null date>) -> InterestRate
Equivalent rate with different compounding between two dates.
rate = ql.InterestRate(0.05, ql.Actual365Fixed(), ql.Compounded, ql.Annual)
df = rate.discountFactor(1.0)
equivalent = rate.equivalentRate(ql.Continuous, ql.NoFrequency, 1.0)
Rounding¶
Rounding¶
- class pyquantlib.Rounding¶
Bases:
pybind11_objectBasic rounding convention.
- class Type¶
Bases:
pybind11_objectRounding type enumeration.
Members:
None_ : No rounding.
Up : Round up.
Down : Round down.
Closest : Round to the closest.
Floor : Round to the largest integer not greater than x.
Ceiling : Round to the smallest integer not less than x.
- __init__(value: SupportsInt | SupportsIndex) None¶
- Ceiling = <Type.Ceiling: 5>¶
- Closest = <Type.Closest: 3>¶
- Down = <Type.Down: 2>¶
- Floor = <Type.Floor: 4>¶
- None_ = <Type.None_: 0>¶
- Up = <Type.Up: 1>¶
- Rounding.Type.name -> str
- property value¶
- __init__(precision: SupportsInt | SupportsIndex, type: Rounding.Type = <Type.Closest: 3>, digit: SupportsInt | SupportsIndex = 5) None¶
Creates a rounding convention.
- property precision¶
Returns the precision.
- property roundingDigit¶
Returns the rounding digit.
- property type¶
Returns the rounding type.
UpRounding¶
- class pyquantlib.UpRounding¶
Bases:
RoundingUp-rounding.
- __init__(precision: SupportsInt | SupportsIndex, digit: SupportsInt | SupportsIndex = 5) None¶
DownRounding¶
- class pyquantlib.DownRounding¶
Bases:
RoundingDown-rounding.
- __init__(precision: SupportsInt | SupportsIndex, digit: SupportsInt | SupportsIndex = 5) None¶
ClosestRounding¶
- class pyquantlib.ClosestRounding¶
Bases:
RoundingClosest-rounding.
- __init__(precision: SupportsInt | SupportsIndex, digit: SupportsInt | SupportsIndex = 5) None¶
CeilingTruncation¶
- class pyquantlib.CeilingTruncation¶
Bases:
RoundingCeiling truncation.
- __init__(precision: SupportsInt | SupportsIndex, digit: SupportsInt | SupportsIndex = 5) None¶
FloorTruncation¶
- class pyquantlib.FloorTruncation¶
Bases:
RoundingFloor truncation.
- __init__(precision: SupportsInt | SupportsIndex, digit: SupportsInt | SupportsIndex = 5) None¶
Enumerations¶
- class pyquantlib.Compounding¶
Bases:
pybind11_objectInterest rate compounding rule.
Members:
Simple : 1 + r*t
Compounded : (1 + r)^t
Continuous : e^(r*t)
SimpleThenCompounded : Simple up to the first period, then Compounded.
CompoundedThenSimple : Compounded up to the first period, then Simple.
- __init__(value: SupportsInt | SupportsIndex) None¶
- Compounded = <Compounding.Compounded: 1>¶
- CompoundedThenSimple = <Compounding.CompoundedThenSimple: 4>¶
- Continuous = <Compounding.Continuous: 2>¶
- Simple = <Compounding.Simple: 0>¶
- SimpleThenCompounded = <Compounding.SimpleThenCompounded: 3>¶
- Compounding.name -> str
- property value¶
Value |
Description |
|---|---|
|
\((1 + r \cdot t)\) |
|
\((1 + r/n)^{nt}\) |
|
\(e^{rt}\) |
|
Simple for \(t < 1/n\), then compounded |
|
Compounded for \(t \geq 1/n\), then simple |
PositionType¶
- class pyquantlib.PositionType¶
Bases:
pybind11_objectLong or short position.
Members:
Long
Short
- __init__(value: SupportsInt | SupportsIndex) None¶
- Long = <PositionType.Long: 0>¶
- Short = <PositionType.Short: 1>¶
- PositionType.name -> str
- property value¶
Value |
Description |
|---|---|
|
Long position |
|
Short position |
ProtectionSide¶
- class pyquantlib.ProtectionSide¶
Bases:
pybind11_objectProtection buyer or seller.
Members:
Buyer : Protection buyer.
Seller : Protection seller.
- __init__(value: SupportsInt | SupportsIndex) None¶
- Buyer = <ProtectionSide.Buyer: 0>¶
- Seller = <ProtectionSide.Seller: 1>¶
- ProtectionSide.name -> str
- property value¶
Value |
Description |
|---|---|
|
Protection buyer |
|
Protection seller |
CdsPricingModel¶
Value |
Description |
|---|---|
|
Mid-point engine |
|
ISDA standard engine |
Constants¶
Constant |
Description |
|---|---|
|
Machine epsilon for floating point |
|
Null value for Real (indicates “no value”) |
|
Null value for Size/Integer |
|
Maximum Real value |
|
Minimum Real value |
|
Minimum positive Real value |
|
Maximum Integer value |
|
Minimum Integer value |
if value == ql.NullReal:
print("Value not available")