Skip to content

Commit

Permalink
Merge pull request #195 from thrasibule/new_dategeneration_rule
Browse files Browse the repository at this point in the history
add new dategeneration rule
  • Loading branch information
dpinte committed Aug 16, 2017
2 parents 0f26a4d + 1b90d64 commit 5394649
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
3 changes: 2 additions & 1 deletion quantlib/time/_schedule.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ cdef extern from 'ql/time/dategenerationrule.hpp' namespace \
OldCDS # Same as TwentiethIMM with unrestricted date ends and log/short
# stub coupon period (old CDS convention).
CDS # Credit derivatives standard rule since 'Big Bang' changes in 2009.

CDS2015 # Credit derivatives standard rule since December 20th, 2015.

cdef extern from 'ql/time/schedule.hpp' namespace 'QuantLib':

cdef cppclass Schedule:
Expand Down
21 changes: 11 additions & 10 deletions quantlib/time/schedule.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ from date cimport date_from_qldate, Date, Period

import warnings

cdef public enum Rule:
cpdef public enum Rule:
# Backward from termination date to effective date.
Backward = _schedule.Backward
# Forward from effective date to termination date.
Expand All @@ -39,6 +39,7 @@ cdef public enum Rule:
# Credit derivatives standard rule since 'Big Bang' changes
# in 2009.
CDS = _schedule.CDS
CDS2015 = _schedule.CDS2015

cdef class Schedule:
""" Payment schedule. """
Expand All @@ -56,8 +57,8 @@ cdef class Schedule:
DeprecationWarning)

self._thisptr = new _schedule.Schedule(
deref(effective_date._thisptr.get()),
deref(termination_date._thisptr.get()),
deref(effective_date._thisptr),
deref(termination_date._thisptr),
deref(tenor._thisptr.get()),
deref(calendar._thisptr),
business_day_convention,
Expand Down Expand Up @@ -87,7 +88,7 @@ cdef class Schedule:
business_day_convention,
optional[BusinessDayConvention](
termination_date_convention),
make_optional[_calendar.Period](tenor is not None, deref(tenor._thisptr.get())),
make_optional[_calendar.Period](tenor is not None, deref(tenor._thisptr)),
optional[_schedule.Rule](<_schedule.Rule>date_generation_rule),
optional[bool](end_of_month),
is_regular
Expand All @@ -106,14 +107,14 @@ cdef class Schedule:

cdef Schedule instance = cls.__new__(cls)
instance._thisptr = new _schedule.Schedule(
deref(effective_date._thisptr.get()),
deref(termination_date._thisptr.get()),
deref(tenor._thisptr.get()),
deref(effective_date._thisptr),
deref(termination_date._thisptr),
deref(tenor._thisptr),
deref(calendar._thisptr),
business_day_convention,
termination_date_convention,
<_schedule.Rule>date_generation_rule, end_of_month,
deref(first_date._thisptr.get()), deref(next_to_lastdate._thisptr.get())
deref(first_date._thisptr), deref(next_to_lastdate._thisptr)
)
return instance

Expand All @@ -131,13 +132,13 @@ cdef class Schedule:

def next_date(self, Date reference_date):
cdef _date.Date dt = self._thisptr.nextDate(
deref(reference_date._thisptr.get())
deref(reference_date._thisptr)
)
return date_from_qldate(dt)

def previous_date(self, Date reference_date):
cdef _date.Date dt = self._thisptr.previousDate(
deref(reference_date._thisptr.get())
deref(reference_date._thisptr)
)
return date_from_qldate(dt)

Expand Down

0 comments on commit 5394649

Please sign in to comment.