diff options
| author | Guillaume Horel <guillaume.horel@gmail.com> | 2018-10-16 15:35:15 -0400 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@gmail.com> | 2018-10-16 15:35:15 -0400 |
| commit | a56917eeeadecf2a5282e65abebe737aeae05f87 (patch) | |
| tree | e3b4a920c03a9177bb3e3e880e4a42d25a1f92e7 | |
| parent | b0190750e6a4a1adf9a8cf24819c7a8625082e8a (diff) | |
| download | pyisda-a56917eeeadecf2a5282e65abebe737aeae05f87.tar.gz | |
fix for accrued
| -rw-r--r-- | pyisda/date.pyx | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/pyisda/date.pyx b/pyisda/date.pyx index 16b8e61..6bd30de 100644 --- a/pyisda/date.pyx +++ b/pyisda/date.pyx @@ -23,8 +23,7 @@ cpdef c_datetime.date TDate_to_pydate(TDate d): cdef long dcc(str day_count) except -1: cdef long r - dc_bytes = day_count.encode('utf-8') - cdef char* dc = dc_bytes + cdef char* dc = day_count cdef int err = JpmcdsStringToDayCountConv(dc, &r) if err == 0: return r @@ -59,7 +58,7 @@ cdef TDate _previous_twentieth(TDate d, bint roll) nogil: return -1 else: if roll: - return next_business_day(r) + return next_business_day(r, FOLLOW) else: return r @@ -72,7 +71,8 @@ def previous_twentieth(d, bint roll=True): @cython.cdivision(True) def cds_accrued(d, double coupon): cdef TDate date = pydate_to_TDate(d) + 1 - return (date - _previous_twentieth(date, True))/360. * coupon + cdef TDate date1 = next_business_day(date, PREVIOUS) + return (date - _previous_twentieth(date1, True))/360. * coupon cdef TMonthDayYear next_twentieth(TDate d) nogil: @@ -93,9 +93,9 @@ cdef TMonthDayYear next_twentieth(TDate d) nogil: mdy.year += 1 return mdy -cdef inline TDate next_business_day(TDate date) nogil: +cdef inline TDate next_business_day(TDate date, long method) nogil: cdef TDate r - if JpmcdsBusinessDay(date, FOLLOW, "NONE", &r) != SUCCESS: + if JpmcdsBusinessDay(date, method, "NONE", &r) != SUCCESS: return -1 else: return r |
