Skip to content

Commit

Permalink
add amortizing floating rate bond
Browse files Browse the repository at this point in the history
  • Loading branch information
thrasibule committed Jul 31, 2024
1 parent b94c43e commit b0308e3
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
36 changes: 36 additions & 0 deletions quantlib/instruments/bonds/_amortizingfloatingratebond.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from quantlib.types cimport Integer, Natural, Rate, Real, Spread
from libcpp cimport bool
from quantlib.handle cimport shared_ptr
from quantlib.indexes._ibor_index cimport IborIndex
from quantlib.time.businessdayconvention cimport BusinessDayConvention
from quantlib.time._calendar cimport Calendar
from quantlib.time._date cimport Date
from quantlib.time._period cimport Period
from quantlib.time._daycounter cimport DayCounter
from quantlib.time._schedule cimport Schedule
from libcpp.vector cimport vector
from .._bond cimport Bond

cdef extern from "ql/instruments/bonds/amortizingfloatingratebond.hpp" namespace "QuantLib" nogil:
cdef cppclass AmortizingFloatingRateBond(Bond):
AmortizingFloatingRateBond(
Natural settlementDays,
const vector[Real]& notional,
const Schedule& schedule,
const shared_ptr[IborIndex]& index,
const DayCounter& accrualDayCounter,
BusinessDayConvention paymentConvention,# = Following,
Natural fixingDays,# = Null<Natural>(),
const vector[Real]& gearings, # = { 1.0 },
const vector[Spread]& spreads, # = { 0.0 },
const vector[Rate]& caps, # = {},
const vector[Rate]& floors, # = {},
bool inArrears,# = false,
const Date& issueDate,# = Date(),
const Period& exCouponPeriod,# = Period(),
const Calendar& exCouponCalendar,# = Calendar(),
BusinessDayConvention exCouponConvention,# = Unadjusted,
bool exCouponEndOfMonth, # = false,
const vector[Real]& redemptions, #= { 100.0 },
Integer paymentLag # = 0
) except +
4 changes: 4 additions & 0 deletions quantlib/instruments/bonds/amortizingfloatingratebond.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from ..bond cimport Bond

cdef class AmortizingFloatingRateBond(Bond):
pass
38 changes: 38 additions & 0 deletions quantlib/instruments/bonds/amortizingfloatingratebond.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from cython.operator cimport dereference as deref
from libcpp cimport bool
from libcpp.vector cimport vector

from quantlib.handle cimport static_pointer_cast
cimport quantlib.indexes._ibor_index as _ii
from quantlib.indexes.ibor_index cimport IborIndex
from quantlib.types cimport Natural, Integer, Real, Rate, Spread
from quantlib.time.businessdayconvention cimport BusinessDayConvention, Following, Unadjusted
from quantlib.time.schedule cimport Schedule
from quantlib.time.daycounter cimport DayCounter
from quantlib.time.date cimport Date, Period
from quantlib.time.calendar cimport Calendar
from quantlib.utilities.null cimport Null
from . cimport _amortizingfloatingratebond as _afb

cdef class AmortizingFloatingRateBond(Bond):
def __init__(self, Natural settlement_days, vector[Real] notional, Schedule schedule, IborIndex index, DayCounter accrual_day_counter,
BusinessDayConvention payment_convention = Following, Natural fixing_days = Null[Natural](), vector[Real] gearings = [1.0],
vector[Spread] spreads = [0.0],
vector[Rate] caps=[], vector[Rate] floors=[], bool in_arrears = False, Date issue_date = Date(),
Period ex_coupon_period = Period(), Calendar ex_coupon_calendar=Calendar(),
BusinessDayConvention ex_coupon_convention=Unadjusted,
bool ex_coupon_end_of_month=False,
vector[Real] redemptions=[100.0],
Integer payment_lag = 0):
self._thisptr.reset(
new _afb.AmortizingFloatingRateBond(
settlement_days,
notional, schedule._thisptr, static_pointer_cast[_ii.IborIndex](index._thisptr),
deref(accrual_day_counter._thisptr), payment_convention, fixing_days, gearings,
spreads, caps, floors, in_arrears, deref(issue_date._thisptr),
deref(ex_coupon_period._thisptr), ex_coupon_calendar._thisptr,
ex_coupon_convention, ex_coupon_end_of_month,
redemptions,
payment_lag
)
)

0 comments on commit b0308e3

Please sign in to comment.