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

evaluationDate

Date

The evaluation date for pricing calculations

includeReferenceDateEvents

bool

Whether events on the reference date are included

includeTodaysCashFlows

bool or None

Whether to include today’s cash flows

enforcesTodaysHistoricFixings

bool

Whether to enforce historic fixings for today

Methods

Method

Description

instance()

Returns the singleton instance

setEvaluationDate(date)

Sets the evaluation date

anchorEvaluationDate()

Prevents the evaluation date from advancing automatically

resetEvaluationDate()

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_object

Interest rate with compounding algebra.

static impliedRate(*args, **kwargs)

Overloaded function.

  1. impliedRate(compound: SupportsFloat | SupportsIndex, dayCounter: DayCounter, compounding: Compounding, frequency: Frequency, time: SupportsFloat | SupportsIndex) -> InterestRate

Implied rate from a compound factor over a time period.

  1. 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.

  1. __init__() -> None

Default constructor returning a null interest rate.

  1. __init__(rate: SupportsFloat | SupportsIndex, dayCounter: DayCounter, compounding: Compounding, frequency: Frequency) -> None

Construct an interest rate with the given parameters.

compoundFactor(*args, **kwargs)

Overloaded function.

  1. compoundFactor(time: SupportsFloat | SupportsIndex) -> float

Compound factor for a given time period.

  1. 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.

  1. discountFactor(time: SupportsFloat | SupportsIndex) -> float

Discount factor for a given time period.

  1. 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.

  1. equivalentRate(compounding: Compounding, frequency: Frequency, time: SupportsFloat | SupportsIndex) -> InterestRate

Equivalent rate with different compounding over a time period.

  1. 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.

frequency() Frequency

Returns the compounding frequency.

isNull() bool

Returns true if the rate is null (uninitialized).

rate() float

Returns the rate value.

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_object

Basic rounding convention.

class Type

Bases: pybind11_object

Rounding 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: Rounding

Up-rounding.

__init__(precision: SupportsInt | SupportsIndex, digit: SupportsInt | SupportsIndex = 5) None

DownRounding

class pyquantlib.DownRounding

Bases: Rounding

Down-rounding.

__init__(precision: SupportsInt | SupportsIndex, digit: SupportsInt | SupportsIndex = 5) None

ClosestRounding

class pyquantlib.ClosestRounding

Bases: Rounding

Closest-rounding.

__init__(precision: SupportsInt | SupportsIndex, digit: SupportsInt | SupportsIndex = 5) None

CeilingTruncation

class pyquantlib.CeilingTruncation

Bases: Rounding

Ceiling truncation.

__init__(precision: SupportsInt | SupportsIndex, digit: SupportsInt | SupportsIndex = 5) None

FloorTruncation

class pyquantlib.FloorTruncation

Bases: Rounding

Floor truncation.

__init__(precision: SupportsInt | SupportsIndex, digit: SupportsInt | SupportsIndex = 5) None

Enumerations

class pyquantlib.Compounding

Bases: pybind11_object

Interest 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

Simple

\((1 + r \cdot t)\)

Compounded

\((1 + r/n)^{nt}\)

Continuous

\(e^{rt}\)

SimpleThenCompounded

Simple for \(t < 1/n\), then compounded

CompoundedThenSimple

Compounded for \(t \geq 1/n\), then simple

PositionType

class pyquantlib.PositionType

Bases: pybind11_object

Long 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

Long position

Short

Short position

ProtectionSide

class pyquantlib.ProtectionSide

Bases: pybind11_object

Protection 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

Buyer

Protection buyer

Seller

Protection seller

CdsPricingModel

Value

Description

Midpoint

Mid-point engine

ISDA

ISDA standard engine

Constants

Constant

Description

ql.EPSILON

Machine epsilon for floating point

ql.NullReal

Null value for Real (indicates “no value”)

ql.NullSize

Null value for Size/Integer

ql.MAX_REAL

Maximum Real value

ql.MIN_REAL

Minimum Real value

ql.MIN_POSITIVE_REAL

Minimum positive Real value

ql.MAX_INTEGER

Maximum Integer value

ql.MIN_INTEGER

Minimum Integer value

if value == ql.NullReal:
    print("Value not available")