Qunatlib InterestRate Object
Arguments
- rate (float): The interest rate in decimal form
- dayCount (ql.DayCounter): Day count convention (e.g., ql.Actual360(), ql.ActualActual()).
- compounding (ql.Compounding): Compounding type (e.g., ql.Simple, ql.Compounded, ql.Continuous).
- frequency (ql.Frequency): Compounding frequency (e.g., ql.Annual, ql.Semiannual, ql.Monthly).
Compounding
- .Compounded - Standard compounding based on the given frequency.
- Simple - Simple interest
- Continuous - Continuously compounded interest
- SimpleThenCompounded - Uses simple interest up to the first period, and compounded thereafter.
- CompoundedThenSimple - : Compounded interest up to the final period, and simple in the last period (commonly seen in US Treasury and Street Conventions).
Frequency
Frequency- ql.NoFrequency - No interest (or undefined frequency)
- ql.Once - Paid once at maturity (e.g., for zero-coupon bonds)
- ql.Annual - Once a year
- ql.Semiannual - Twice a year
- ql.EveryFourthMonth - Every 4 months (3 times a year)
- ql.Quarterly - Four times a year
- ql.Bimonthly - Every 2 months (6 times a year)
- ql.Monthly - Once a month
- ql.EveryFourthWeek - Every 4 weeks (13 times a year)
- ql.Biweekly - Every 2 weeks (26 times a year)
- ql.Weekly - Once a week (52 times a year)
- ql.Daily - Once a day
Sample Code
import QuantLib as ql
# Define 5% annual compounded rate using Actual/360 day counter
annual_rate = 0.05
day_count = ql.Actual360()
compounding = ql.Compounded
frequency = ql.Annual
# Instantiate InterestRate
interest_rate = ql.InterestRate(annual_rate, day_count, compounding, frequency)