summaryrefslogtreecommitdiffstats
path: root/zerocurve.pyx
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@serenitascapital.com>2016-06-29 15:41:19 -0400
committerGuillaume Horel <guillaume.horel@serenitascapital.com>2016-06-29 15:43:41 -0400
commit698e0ddb347fa4b67a9ded9d1b8dbb452d8cffbc (patch)
tree770d1131c9751ee91d235df878b47209caa23d79 /zerocurve.pyx
parentfa3c124b5da1b3ef07efeb8c1d279680b514c1ff (diff)
downloadpyisda-698e0ddb347fa4b67a9ded9d1b8dbb452d8cffbc.tar.gz
add convenience function to convert python dates
Diffstat (limited to 'zerocurve.pyx')
-rw-r--r--zerocurve.pyx17
1 files changed, 4 insertions, 13 deletions
diff --git a/zerocurve.pyx b/zerocurve.pyx
index d86c0bd..6760d41 100644
--- a/zerocurve.pyx
+++ b/zerocurve.pyx
@@ -2,8 +2,8 @@ from cpython cimport datetime
from libc.stdlib cimport malloc, free
from pyisda.zerocurve cimport JpmcdsBuildIRZeroCurve
from pyisda.yearfrac cimport dcc
-from pyisda.date cimport (JpmcdsStringToDateInterval, JpmcdsDateIntervalToFreq,
- JpmcdsDate, JpmcdsDateFwdThenAdjust)
+from pyisda.date cimport (JpmcdsStringToDateInterval, pydate_to_TDate,
+ JpmcdsDateIntervalToFreq, JpmcdsDateFwdThenAdjust)
cdef int SUCCESS = 0
@@ -30,12 +30,7 @@ cdef class ZeroCurve:
double float_freq
TDateInterval ivl
char* routine = 'zerocurve'
- TDate value_date
-
- if isinstance(date, datetime.date):
- value_date = JpmcdsDate(date.year, date.month, date.day)
- else:
- raise ValueError
+ TDate value_date = pydate_to_TDate(date)
self._dates = <TDate*>malloc(len(periods) * sizeof(TDate))
cdef TDateInterval tmp
@@ -77,9 +72,5 @@ cdef class ZeroCurve:
def discount_factor(self, date):
if self._thisptr is NULL:
raise ValueError('curve is empty')
- cdef TDate discount_date
- if isinstance(date, datetime.date):
- discount_date = JpmcdsDate(date.year, date.month, date.day)
- else:
- raise ValueError
+ cdef TDate discount_date = pydate_to_TDate(date)
return JpmcdsZeroPrice(self._thisptr, discount_date)