Specifying Fixed Income Contracts

Overview

A fixed income instrument is a contract with various terms and conditions (see Fixed Rate Contract Terms) In order to model a contract and forecast its cash flows, one needs a way to specify all the terms of the security in question.

The davinci quantlib wrapper libraries provide a pydantic object model to wrap quantlib objects.

Properties

The following are the variables that can be specified to model a given contract. Not all arguments are required, and many provide default values.

  • settlement_days = an integer that defaults to 2
  • face_value = a float that defaults to
  • coupons = a list of floats. If you provide a single float, it represents the single coupon rate that applies to all coupons. if you provide more than one coupon rate, the number of rates in your list must exactly match the number of payment periods in the bond's Schedule
  • day_count = an instance of the DayCount class
  • schedule = an instance of a schedule class. Date schedule detailing the effective date, maturity date, frequency, calendars, and convention rules.
  • issue_date = a string (iso format) that indicates the issue date of a bond. it is optional issue date is when the security is officially created, sold, and delivered to the investor in exchange for funds, while the effective date (often called the dated date) is the specific day from which interest officially begins to accrue.
  • payment_convention = a convention object The schedule convention controls how the accrual/period boundary dates are generated and adjusted, whereas the bond's explicit paymentConvention argument governs the final cash flow payment date adjustment. Defaults to None.
  • redemption = The redemption amount percentage at maturity. Defaults to 100.0.
  • payment_calendar = Calendar used for payment holidays if different from the schedule. Defaults to None
  • first_period_day_count = Optional distinct day count for the very first coupon period.
  • ex_coupon_period = The length of time (as a ql.Period, like ql.Period(2, ql.Days)) before the payment date that the bond goes ex-coupon.
  • ex_coupon_calendar = The ql.Calendar used to determine business days for the ex-coupon period calculation.
  • ex_coupon_convention = applied to the ex-coupon date if it falls on a weekend or holiday.
  • ex_coupon_end_of_month = A boolean flag (True or False) indicating whether to apply end-of-month rules to the calculation. defaults to false

FixedRateBond Class

The pydantic dataclass is given here:

@dataclass class FixedRateBond(Contract): settlement_days: int face_value: float coupons: list[float]|float day_count: DayCount schedule: Schedule issue_date: str|None=None payment_convention: Convention|None=None redemption: float=100.0 payment_calendar: cl.Calendar|None = None first_period_day_count: DayCount|None=None ex_coupon_period: cl.Period|None=None ex_coupon_calendar: cl.Calendar|None=None ex_coupon_convention: Convention|None = None ex_coupon_end_of_month:bool=False

Sample Code

The following code demonstrates constructing a fixed rate instrument.

schedule = ct.Schedule(start_date='2000-01-01', end_date='2030-01-01', frequency= ct.Frequency.Annual, calendar= cl.Calendar.USGovernmentBond, convention=ct.Convention.Following, dateroll=ct.DateRoll.Forward) bond = ct.FixedRateBond(settlement_days=2,face_value=10000, day_count=ct.DayCount.Actual360, coupons=0.05,schedule=schedule)