summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pyisda/curve.pyx2
-rw-r--r--pyisda/date.pxd2
-rw-r--r--pyisda/date.pyx24
3 files changed, 14 insertions, 14 deletions
diff --git a/pyisda/curve.pyx b/pyisda/curve.pyx
index 091ee6b..38ec250 100644
--- a/pyisda/curve.pyx
+++ b/pyisda/curve.pyx
@@ -615,7 +615,7 @@ cdef class SpreadCurve(Curve):
cdef TRatePt* ptr = NULL
if start_date is None:
- start_date_c = _previous_twentieth(today_c, True)
+ start_date_c = _previous_twentieth(today_c, True, b"NONE")
if start_date_c == -1:
raise ValueError("incorrect today's date: " + today)
else:
diff --git a/pyisda/date.pxd b/pyisda/date.pxd
index 0a081eb..0159ad8 100644
--- a/pyisda/date.pxd
+++ b/pyisda/date.pxd
@@ -91,4 +91,4 @@ cpdef TDate pydate_to_TDate(c_datetime.date d)
cpdef c_datetime.date TDate_to_pydate(TDate d)
cdef void _roll_date(TDate d, const double* tenors, int n_dates, TDate* output) nogil
-cdef TDate _previous_twentieth(TDate d, bint roll) nogil
+cdef TDate _previous_twentieth(TDate d, bint roll, char* cal) nogil
diff --git a/pyisda/date.pyx b/pyisda/date.pyx
index e3cc325..674413f 100644
--- a/pyisda/date.pyx
+++ b/pyisda/date.pyx
@@ -39,7 +39,7 @@ def dcc_tostring(long day_count):
return c_string
-cdef TDate _previous_twentieth(TDate d, bint roll) nogil:
+cdef TDate _previous_twentieth(TDate d, bint roll, char* cal) nogil:
cdef TMonthDayYear mdy
if JpmcdsDateToMDY(d, &mdy) != SUCCESS:
return -1
@@ -48,7 +48,7 @@ cdef TDate _previous_twentieth(TDate d, bint roll) nogil:
if JpmcdsMDYToDate(&mdy, &r) != SUCCESS:
return -1
if roll:
- return next_business_day(r, FOLLOW)
+ return next_business_day(r, FOLLOW, cal)
else:
return r
@@ -70,7 +70,7 @@ cdef inline void __previous_twentieth(TMonthDayYear* mdy) nogil:
-def previous_twentieth(c_datetime.date d, bint roll=True):
+def previous_twentieth(c_datetime.date d, bint roll=True, str cal="NONE"):
cdef:
TMonthDayYear mdy = [date_month(d), date_day(d), date_year(d)]
TDate r
@@ -79,12 +79,12 @@ def previous_twentieth(c_datetime.date d, bint roll=True):
if JpmcdsMDYToDate(&mdy, &r) != SUCCESS:
raise ValueError("Incorrect date")
else:
- return TDate_to_pydate(next_business_day(r, FOLLOW))
+ return TDate_to_pydate(next_business_day(r, FOLLOW, cal))
else:
return c_datetime.date_new(mdy.year, mdy.month, mdy.day)
-def next_twentieth(d, bint roll=True):
+def next_twentieth(d, bint roll=True, str cal="NONE"):
cdef:
TMonthDayYear mdy = [date_month(d), date_day(d), date_year(d)]
TDate r
@@ -93,20 +93,20 @@ def next_twentieth(d, bint roll=True):
if JpmcdsMDYToDate(&mdy, &r) != SUCCESS:
raise RuntimeError
else:
- return TDate_to_pydate(next_business_day(r, FOLLOW))
+ return TDate_to_pydate(next_business_day(r, FOLLOW, cal))
else:
return c_datetime.date_new(mdy.year, mdy.month, mdy.day)
@cython.cdivision(True)
-def cds_accrued(d, double coupon, bint include_cashflow=False):
+def cds_accrued(d, double coupon, bint include_cashflow=False, str cal="NONE"):
cdef:
TDate date = pydate_to_TDate(d) + 1
- TDate date1 = next_business_day(date, PREVIOUS)
- TDate date_prev = _previous_twentieth(date1, True)
+ TDate date1 = next_business_day(date, PREVIOUS, cal)
+ TDate date_prev = _previous_twentieth(date1, True, cal)
if date_prev == date and include_cashflow:
- date_prev = _previous_twentieth(date - 1, True)
+ date_prev = _previous_twentieth(date - 1, True, cal)
return (date - date_prev)/360. * coupon
@@ -126,9 +126,9 @@ cdef TMonthDayYear _next_twentieth(TMonthDayYear* mdy) nogil:
mdy.year += 1
-cdef inline TDate next_business_day(TDate date, long method) nogil:
+cdef inline TDate next_business_day(TDate date, long method, char* cal) nogil:
cdef TDate r
- if JpmcdsBusinessDay(date, method, "NONE", &r) != SUCCESS:
+ if JpmcdsBusinessDay(date, method, cal, &r) != SUCCESS:
return -1
else:
return r