interest_accrual
InterestIncomeAccrualRule: accrues interest income using QuantLib conventions.
For QL-backed bonds, uses bond.accruedAmount(date) which correctly handles
day count conventions (e.g., Thirty360), business day adjustments, and coupon
period boundaries. The accrual is the change in QL's accrued interest between
the previous simulation date and today.
Any difference between the sum of daily accruals and the coupon payment amount is handled as a "catch-up" at settlement by the CouponPaymentRule.
For non-QL instruments, falls back to face_value * rate / 365.
Classes:
-
InterestIncomeAccrualRule–Accrue interest income for LONG positions on coupon/interest-bearing instruments.
Functions:
-
scaled_accrued_amount–Return the absolute accrued interest at ql_date in currency.
InterestIncomeAccrualRule
Accrue interest income for LONG positions on coupon/interest-bearing instruments.
Produces INTEREST_ACCRUAL transactions with ("side", "income") metadata.
Accounting: Dr Accrued Interest Receivable / Cr Interest Income.
Methods:
-
applies_to–Return True for LONG positions (runs every day).
-
generate–Generate an accrual transaction based on the change in accrued interest.
applies_to
applies_to(
_instrument: Instrument,
position: Position,
_context: RuleContext,
) -> bool
Return True for LONG positions (runs every day).
generate
generate(
instrument: Instrument,
position: Position,
context: RuleContext,
) -> list[Transaction]
Generate an accrual transaction based on the change in accrued interest.
scaled_accrued_amount
scaled_accrued_amount(
ql_inst: Bond, ql_date: Date
) -> Decimal
Return the absolute accrued interest at ql_date in currency.
QL's accruedAmount(d) returns per-100 of the current notional at
d. For fixed-notional bonds the current notional equals face value; for
amortizing instruments it declines at each payment date. In both cases,
scaling by notional(d) / 100 gives the correct dollar amount.