From bd8cca750b7fe47ba6b790b5ab35b699c6abe510 Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Mon, 26 Feb 2024 21:33:11 -0500 Subject: [PATCH] allow to build ActualActual with schedule --- quantlib/time/daycounters/_actual_actual.pxd | 7 ++++--- quantlib/time/daycounters/actual_actual.pyx | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/quantlib/time/daycounters/_actual_actual.pxd b/quantlib/time/daycounters/_actual_actual.pxd index 4c398a3d3..bd8afd1d1 100644 --- a/quantlib/time/daycounters/_actual_actual.pxd +++ b/quantlib/time/daycounters/_actual_actual.pxd @@ -1,9 +1,10 @@ from quantlib.time._daycounter cimport DayCounter +from quantlib.time._schedule cimport Schedule - -cdef extern from 'ql/time/daycounters/actualactual.hpp' namespace 'QuantLib': +cdef extern from 'ql/time/daycounters/actualactual.hpp' namespace 'QuantLib' nogil: cdef cppclass ActualActual(DayCounter): enum Convention: pass - ActualActual(Convention) + ActualActual(Convention c) + ActualActual(Convention c, const Schedule& schedule) diff --git a/quantlib/time/daycounters/actual_actual.pyx b/quantlib/time/daycounters/actual_actual.pyx index 80766ca84..92e5467ab 100644 --- a/quantlib/time/daycounters/actual_actual.pyx +++ b/quantlib/time/daycounters/actual_actual.pyx @@ -13,13 +13,15 @@ For more details, refer to https://www.isda.org/a/pIJEE/The-Actual-Actual-Day-Count-Fraction-1999.pdf ''' +from cython.operator cimport dereference as deref cimport quantlib.time._daycounter as _daycounter cimport quantlib.time.daycounters._actual_actual as _aa +from quantlib.time.schedule cimport Schedule from quantlib.time.daycounter cimport DayCounter cdef class ActualActual(DayCounter): - def __init__(self, Convention convention=Convention.ISDA): + def __init__(self, Convention convention=Convention.ISDA, Schedule schedule=Schedule.from_dates([])): """ Actual/Actual day count The day count can be calculated according to: @@ -35,7 +37,7 @@ cdef class ActualActual(DayCounter): https://www.isda.org/a/pIJEE/The-Actual-Actual-Day-Count-Fraction-1999.pdf """ self._thisptr = <_daycounter.DayCounter*> new \ - _aa.ActualActual(convention) + _aa.ActualActual(convention, deref(schedule._thisptr)) cdef _daycounter.DayCounter* from_name(str convention):