loans
Loan instrument classes for the core domain model.
Classes:
-
AmortizingFixedRateLoan–A class representing an amortizing fixed rate loan.
-
CommercialMortgage–Represents a commercial mortgage with a fixed interest rate.
-
CreditCard–A class to represent credit card instruments.
-
Mortgage–Base class for mortgages with a fixed interest rate.
-
PersonalLoan–A class to represent personal loan instruments.
-
ResidentialMortgage–Represents a residential mortgage with a fixed interest rate.
-
VariableRateLoan–Benchmark-indexed variable-rate loan backed by
ql.AmortizingFloatingRateBond.
AmortizingFixedRateLoan
AmortizingFixedRateLoan(
face_value: float,
interest_rate: float,
issue_date: Date,
maturity: Period,
frequency: Period = Semiannual,
settlement_days: int = 0,
calendar: Calendar = NullCalendar(),
day_count: DayCounter = Thirty360(BondBasis),
business_convention: int = Unadjusted,
book_type: BookType | None = None,
credit_rating: CreditRating | None = None,
issuer: Issuer | None = None,
parent: Instrument | None = None,
measurement_basis: MeasurementBasis | None = None,
)
Bases: Instrument
A class representing an amortizing fixed rate loan.
Parameters:
-
(face_valuefloat) –The face value of the instrument.
-
(interest_ratefloat) –The interest rate of the instrument.
-
(issue_dateDate) –The issue date of the instrument.
-
(maturityPeriod) –The maturity period of the instrument.
-
(frequencyPeriod, default:Semiannual) –The frequency of coupon payments. Defaults to ql.Semiannual.
-
(settlement_daysint, default:0) –The number of settlement days. Defaults to 0.
-
(calendarCalendar, default:NullCalendar()) –The calendar used for date calculations. Defaults to ql.NullCalendar().
-
(day_countDayCounter, default:Thirty360(BondBasis)) –The day count convention used for interest calculations. Defaults to ql.Thirty360(ql.Thirty360.BondBasis).
-
(business_conventionint, default:Unadjusted) –The business convention used for date adjustments. Defaults to ql.Unadjusted.
-
(book_typeBookType, default:None) –The book type of the instrument.
-
(credit_ratingCreditRating, default:None) –The credit rating of the instrument.
-
(issuerIssuer, default:None) –The issuer of the instrument.
-
(parentInstrument, default:None) –The parent instrument.
-
(measurement_basisMeasurementBasis, default:None) –The instrument class.
Methods:
-
accept–Accept a visitor.
-
is_composite–Check if the instrument is composite.
-
notional–Calculate the notional value of the loan on a given date.
-
payment_schedule–Calculate the payment schedule for the instrument.
-
repricing_date–Return the next repricing date for variable-rate instruments.
-
set_pricing_engine–Set the pricing engine.
Attributes:
-
book_type(BookType | None) –Get the book type of the instrument.
-
credit_rating(CreditRating) –Get the instrument's credit rating.
-
face_value(float) –Get the face value of the loan.
-
interest_rate(float) –Get the interest rate of the loan.
-
issue_date(date) –Get the issue date of the loan.
-
issuer(Issuer) –Get the instrument's issuer.
-
maturity_date(date) –Get the maturity date of the loan.
-
parent(Instrument | None) –Get the parent instrument.
face_value
property
face_value: float
Get the face value of the loan.
interest_rate
property
interest_rate: float
Get the interest rate of the loan.
issue_date
property
issue_date: date
Get the issue date of the loan.
maturity_date
property
maturity_date: date
Get the maturity date of the loan.
is_composite
is_composite() -> bool
Check if the instrument is composite.
notional
notional(date: date) -> float
Calculate the notional value of the loan on a given date.
Parameters:
-
(datedate) –The date for which to calculate the notional value.
Returns:
-
float(float) –The notional value of the loan on the given date.
payment_schedule
cached
payment_schedule() -> (
tuple[
list[tuple[date, float]],
list[tuple[date, float]],
list[tuple[date, float]],
]
)
Calculate the payment schedule for the instrument.
Returns:
-
Tuple(tuple[list[tuple[date, float]], list[tuple[date, float]], list[tuple[date, float]]]) –A tuple containing three lists: - interest_pmt: A list of tuples representing the date and amount of interest payments. - principal_pmt: A list of tuples representing the date and amount of principal payments. - outstanding: A list of tuples representing the date and outstanding balance after each payment.
repricing_date
repricing_date(as_of: date) -> date | None
Return the next repricing date for variable-rate instruments.
Returns None for fixed-rate instruments (repricing_frequency is None).
set_pricing_engine
set_pricing_engine(engine: PricingEngine) -> None
Set the pricing engine.
CommercialMortgage
CommercialMortgage(
*, frequency: int = Monthly, **kwargs: object
)
Bases: Mortgage
Represents a commercial mortgage with a fixed interest rate.
Methods:
-
accept–Accept a visitor.
-
is_composite–Check if the instrument is composite.
-
notional–Calculate the notional value of the loan on a given date.
-
payment_schedule–Calculate the payment schedule for the instrument.
-
repricing_date–Return the next repricing date for variable-rate instruments.
-
set_pricing_engine–Set the pricing engine.
Attributes:
-
book_type(BookType | None) –Get the book type of the instrument.
-
credit_rating(CreditRating) –Get the instrument's credit rating.
-
face_value(float) –Get the face value of the loan.
-
interest_rate(float) –Get the interest rate of the loan.
-
issue_date(date) –Get the issue date of the loan.
-
issuer(Issuer) –Get the instrument's issuer.
-
maturity_date(date) –Get the maturity date of the loan.
-
parent(Instrument | None) –Get the parent instrument.
face_value
property
face_value: float
Get the face value of the loan.
interest_rate
property
interest_rate: float
Get the interest rate of the loan.
issue_date
property
issue_date: date
Get the issue date of the loan.
maturity_date
property
maturity_date: date
Get the maturity date of the loan.
is_composite
is_composite() -> bool
Check if the instrument is composite.
notional
notional(date: date) -> float
Calculate the notional value of the loan on a given date.
Parameters:
-
(datedate) –The date for which to calculate the notional value.
Returns:
-
float(float) –The notional value of the loan on the given date.
payment_schedule
cached
payment_schedule() -> (
tuple[
list[tuple[date, float]],
list[tuple[date, float]],
list[tuple[date, float]],
]
)
Calculate the payment schedule for the instrument.
Returns:
-
Tuple(tuple[list[tuple[date, float]], list[tuple[date, float]], list[tuple[date, float]]]) –A tuple containing three lists: - interest_pmt: A list of tuples representing the date and amount of interest payments. - principal_pmt: A list of tuples representing the date and amount of principal payments. - outstanding: A list of tuples representing the date and outstanding balance after each payment.
repricing_date
repricing_date(as_of: date) -> date | None
Return the next repricing date for variable-rate instruments.
Returns None for fixed-rate instruments (repricing_frequency is None).
set_pricing_engine
set_pricing_engine(engine: PricingEngine) -> None
Set the pricing engine.
CreditCard
CreditCard(**kwargs: object)
Bases: Instrument
A class to represent credit card instruments.
Methods:
-
accept–Accept a visitor.
-
is_composite–Check if the instrument is composite.
-
repricing_date–Return the next repricing date for variable-rate instruments.
Attributes:
-
book_type(BookType | None) –Get the book type of the instrument.
-
credit_rating(CreditRating) –Get the instrument's credit rating.
-
issuer(Issuer) –Get the instrument's issuer.
-
parent(Instrument | None) –Get the parent instrument.
is_composite
is_composite() -> bool
Check if the instrument is composite.
repricing_date
repricing_date(as_of: date) -> date | None
Return the next repricing date for variable-rate instruments.
Returns None for fixed-rate instruments (repricing_frequency is None).
Mortgage
Mortgage(*, frequency: int = Monthly, **kwargs: object)
Bases: AmortizingFixedRateLoan
Base class for mortgages with a fixed interest rate.
Defaults to monthly payments (ql.Monthly), overriding the base
class semi-annual default.
Methods:
-
accept–Accept a visitor.
-
is_composite–Check if the instrument is composite.
-
notional–Calculate the notional value of the loan on a given date.
-
payment_schedule–Calculate the payment schedule for the instrument.
-
repricing_date–Return the next repricing date for variable-rate instruments.
-
set_pricing_engine–Set the pricing engine.
Attributes:
-
book_type(BookType | None) –Get the book type of the instrument.
-
credit_rating(CreditRating) –Get the instrument's credit rating.
-
face_value(float) –Get the face value of the loan.
-
interest_rate(float) –Get the interest rate of the loan.
-
issue_date(date) –Get the issue date of the loan.
-
issuer(Issuer) –Get the instrument's issuer.
-
maturity_date(date) –Get the maturity date of the loan.
-
parent(Instrument | None) –Get the parent instrument.
face_value
property
face_value: float
Get the face value of the loan.
interest_rate
property
interest_rate: float
Get the interest rate of the loan.
issue_date
property
issue_date: date
Get the issue date of the loan.
maturity_date
property
maturity_date: date
Get the maturity date of the loan.
is_composite
is_composite() -> bool
Check if the instrument is composite.
notional
notional(date: date) -> float
Calculate the notional value of the loan on a given date.
Parameters:
-
(datedate) –The date for which to calculate the notional value.
Returns:
-
float(float) –The notional value of the loan on the given date.
payment_schedule
cached
payment_schedule() -> (
tuple[
list[tuple[date, float]],
list[tuple[date, float]],
list[tuple[date, float]],
]
)
Calculate the payment schedule for the instrument.
Returns:
-
Tuple(tuple[list[tuple[date, float]], list[tuple[date, float]], list[tuple[date, float]]]) –A tuple containing three lists: - interest_pmt: A list of tuples representing the date and amount of interest payments. - principal_pmt: A list of tuples representing the date and amount of principal payments. - outstanding: A list of tuples representing the date and outstanding balance after each payment.
repricing_date
repricing_date(as_of: date) -> date | None
Return the next repricing date for variable-rate instruments.
Returns None for fixed-rate instruments (repricing_frequency is None).
set_pricing_engine
set_pricing_engine(engine: PricingEngine) -> None
Set the pricing engine.
PersonalLoan
PersonalLoan(**kwargs: object)
Bases: Instrument
A class to represent personal loan instruments.
Methods:
-
accept–Accept a visitor.
-
is_composite–Check if the instrument is composite.
-
repricing_date–Return the next repricing date for variable-rate instruments.
Attributes:
-
book_type(BookType | None) –Get the book type of the instrument.
-
credit_rating(CreditRating) –Get the instrument's credit rating.
-
issuer(Issuer) –Get the instrument's issuer.
-
parent(Instrument | None) –Get the parent instrument.
is_composite
is_composite() -> bool
Check if the instrument is composite.
repricing_date
repricing_date(as_of: date) -> date | None
Return the next repricing date for variable-rate instruments.
Returns None for fixed-rate instruments (repricing_frequency is None).
ResidentialMortgage
ResidentialMortgage(
*, frequency: int = Monthly, **kwargs: object
)
Bases: Mortgage
Represents a residential mortgage with a fixed interest rate.
Methods:
-
accept–Accept a visitor.
-
is_composite–Check if the instrument is composite.
-
notional–Calculate the notional value of the loan on a given date.
-
payment_schedule–Calculate the payment schedule for the instrument.
-
repricing_date–Return the next repricing date for variable-rate instruments.
-
set_pricing_engine–Set the pricing engine.
Attributes:
-
book_type(BookType | None) –Get the book type of the instrument.
-
credit_rating(CreditRating) –Get the instrument's credit rating.
-
face_value(float) –Get the face value of the loan.
-
interest_rate(float) –Get the interest rate of the loan.
-
issue_date(date) –Get the issue date of the loan.
-
issuer(Issuer) –Get the instrument's issuer.
-
maturity_date(date) –Get the maturity date of the loan.
-
parent(Instrument | None) –Get the parent instrument.
face_value
property
face_value: float
Get the face value of the loan.
interest_rate
property
interest_rate: float
Get the interest rate of the loan.
issue_date
property
issue_date: date
Get the issue date of the loan.
maturity_date
property
maturity_date: date
Get the maturity date of the loan.
is_composite
is_composite() -> bool
Check if the instrument is composite.
notional
notional(date: date) -> float
Calculate the notional value of the loan on a given date.
Parameters:
-
(datedate) –The date for which to calculate the notional value.
Returns:
-
float(float) –The notional value of the loan on the given date.
payment_schedule
cached
payment_schedule() -> (
tuple[
list[tuple[date, float]],
list[tuple[date, float]],
list[tuple[date, float]],
]
)
Calculate the payment schedule for the instrument.
Returns:
-
Tuple(tuple[list[tuple[date, float]], list[tuple[date, float]], list[tuple[date, float]]]) –A tuple containing three lists: - interest_pmt: A list of tuples representing the date and amount of interest payments. - principal_pmt: A list of tuples representing the date and amount of principal payments. - outstanding: A list of tuples representing the date and outstanding balance after each payment.
repricing_date
repricing_date(as_of: date) -> date | None
Return the next repricing date for variable-rate instruments.
Returns None for fixed-rate instruments (repricing_frequency is None).
set_pricing_engine
set_pricing_engine(engine: PricingEngine) -> None
Set the pricing engine.
VariableRateLoan
VariableRateLoan(
face_value: float,
spread: float,
issue_date: Date,
maturity: Period,
ibor_index: IborIndex,
repricing_frequency: Period | None = None,
payment_frequency: Period | None = None,
principal_repayment_mode: PrincipalRepaymentMode = BULLET,
floor_rate: float | None = None,
cap_rate: float | None = None,
benchmark_family: BenchmarkFamily = PRIME,
settlement_days: int = 0,
calendar: Calendar | None = None,
day_count: DayCounter | None = None,
business_convention: int = ModifiedFollowing,
book_type: BookType | None = None,
credit_rating: CreditRating | None = None,
issuer: Issuer | None = None,
parent: Instrument | None = None,
measurement_basis: MeasurementBasis
| None = AMORTIZED_COST,
)
Bases: Instrument
Benchmark-indexed variable-rate loan backed by ql.AmortizingFloatingRateBond.
Methods:
-
accept–Accept a visitor.
-
is_composite–Check if the instrument is composite.
-
notional–Outstanding notional as of date.
-
payment_schedule–Interest, principal, and outstanding schedules from QL cashflows.
-
repricing_date–Return the next repricing date for variable-rate instruments.
-
set_pricing_engine–Set the pricing engine for NPV calculations.
Attributes:
-
book_type(BookType | None) –Get the book type of the instrument.
-
credit_rating(CreditRating) –Get the instrument's credit rating.
-
face_value(float) –Original face value of the loan.
-
issue_date(date) –Issue date of the loan.
-
issuer(Issuer) –Get the instrument's issuer.
-
maturity_date(date) –Maturity date of the loan.
-
parent(Instrument | None) –Get the parent instrument.
face_value
property
face_value: float
Original face value of the loan.
issue_date
property
issue_date: date
Issue date of the loan.
maturity_date
property
maturity_date: date
Maturity date of the loan.
is_composite
is_composite() -> bool
Check if the instrument is composite.
notional
notional(date: date) -> float
Outstanding notional as of date.
payment_schedule
payment_schedule() -> (
tuple[
list[tuple[date, float]],
list[tuple[date, float]],
list[tuple[date, float]],
]
)
Interest, principal, and outstanding schedules from QL cashflows.
Interest amounts for future coupons may be unavailable if the index's forwarding curve is not yet linked; those coupons are skipped. Principal/redemption cashflows are always deterministic.
repricing_date
repricing_date(as_of: date) -> date | None
Return the next repricing date for variable-rate instruments.
Returns None for fixed-rate instruments (repricing_frequency is None).
set_pricing_engine
set_pricing_engine(engine: PricingEngine) -> None
Set the pricing engine for NPV calculations.