Skip to content

Commit b0308e3

Browse files
committed
add amortizing floating rate bond
1 parent b94c43e commit b0308e3

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from quantlib.types cimport Integer, Natural, Rate, Real, Spread
2+
from libcpp cimport bool
3+
from quantlib.handle cimport shared_ptr
4+
from quantlib.indexes._ibor_index cimport IborIndex
5+
from quantlib.time.businessdayconvention cimport BusinessDayConvention
6+
from quantlib.time._calendar cimport Calendar
7+
from quantlib.time._date cimport Date
8+
from quantlib.time._period cimport Period
9+
from quantlib.time._daycounter cimport DayCounter
10+
from quantlib.time._schedule cimport Schedule
11+
from libcpp.vector cimport vector
12+
from .._bond cimport Bond
13+
14+
cdef extern from "ql/instruments/bonds/amortizingfloatingratebond.hpp" namespace "QuantLib" nogil:
15+
cdef cppclass AmortizingFloatingRateBond(Bond):
16+
AmortizingFloatingRateBond(
17+
Natural settlementDays,
18+
const vector[Real]& notional,
19+
const Schedule& schedule,
20+
const shared_ptr[IborIndex]& index,
21+
const DayCounter& accrualDayCounter,
22+
BusinessDayConvention paymentConvention,# = Following,
23+
Natural fixingDays,# = Null<Natural>(),
24+
const vector[Real]& gearings, # = { 1.0 },
25+
const vector[Spread]& spreads, # = { 0.0 },
26+
const vector[Rate]& caps, # = {},
27+
const vector[Rate]& floors, # = {},
28+
bool inArrears,# = false,
29+
const Date& issueDate,# = Date(),
30+
const Period& exCouponPeriod,# = Period(),
31+
const Calendar& exCouponCalendar,# = Calendar(),
32+
BusinessDayConvention exCouponConvention,# = Unadjusted,
33+
bool exCouponEndOfMonth, # = false,
34+
const vector[Real]& redemptions, #= { 100.0 },
35+
Integer paymentLag # = 0
36+
) except +
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from ..bond cimport Bond
2+
3+
cdef class AmortizingFloatingRateBond(Bond):
4+
pass
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from cython.operator cimport dereference as deref
2+
from libcpp cimport bool
3+
from libcpp.vector cimport vector
4+
5+
from quantlib.handle cimport static_pointer_cast
6+
cimport quantlib.indexes._ibor_index as _ii
7+
from quantlib.indexes.ibor_index cimport IborIndex
8+
from quantlib.types cimport Natural, Integer, Real, Rate, Spread
9+
from quantlib.time.businessdayconvention cimport BusinessDayConvention, Following, Unadjusted
10+
from quantlib.time.schedule cimport Schedule
11+
from quantlib.time.daycounter cimport DayCounter
12+
from quantlib.time.date cimport Date, Period
13+
from quantlib.time.calendar cimport Calendar
14+
from quantlib.utilities.null cimport Null
15+
from . cimport _amortizingfloatingratebond as _afb
16+
17+
cdef class AmortizingFloatingRateBond(Bond):
18+
def __init__(self, Natural settlement_days, vector[Real] notional, Schedule schedule, IborIndex index, DayCounter accrual_day_counter,
19+
BusinessDayConvention payment_convention = Following, Natural fixing_days = Null[Natural](), vector[Real] gearings = [1.0],
20+
vector[Spread] spreads = [0.0],
21+
vector[Rate] caps=[], vector[Rate] floors=[], bool in_arrears = False, Date issue_date = Date(),
22+
Period ex_coupon_period = Period(), Calendar ex_coupon_calendar=Calendar(),
23+
BusinessDayConvention ex_coupon_convention=Unadjusted,
24+
bool ex_coupon_end_of_month=False,
25+
vector[Real] redemptions=[100.0],
26+
Integer payment_lag = 0):
27+
self._thisptr.reset(
28+
new _afb.AmortizingFloatingRateBond(
29+
settlement_days,
30+
notional, schedule._thisptr, static_pointer_cast[_ii.IborIndex](index._thisptr),
31+
deref(accrual_day_counter._thisptr), payment_convention, fixing_days, gearings,
32+
spreads, caps, floors, in_arrears, deref(issue_date._thisptr),
33+
deref(ex_coupon_period._thisptr), ex_coupon_calendar._thisptr,
34+
ex_coupon_convention, ex_coupon_end_of_month,
35+
redemptions,
36+
payment_lag
37+
)
38+
)

0 commit comments

Comments
 (0)