summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--curve.pxd17
-rw-r--r--curve.pyx15
2 files changed, 27 insertions, 5 deletions
diff --git a/curve.pxd b/curve.pxd
index b365b5a..bd36e09 100644
--- a/curve.pxd
+++ b/curve.pxd
@@ -5,9 +5,6 @@ cdef extern from "isda/zerocurve.h":
ctypedef long int TDate
- ctypedef struct TCurve:
- pass
-
ctypedef struct TDateInterval:
pass
@@ -23,6 +20,18 @@ cdef extern from "isda/zerocurve.h":
long floatSwapDCC,
long badDayConv,
char* holidayFile)
+cdef extern from "isda/bastypes.h":
+ ctypedef struct TCurve:
+ int fNumItems
+ TRatePt* fArray
+ TDate fBaseDate
+ double fBasis
+ long fDayCountConv
+
+ ctypedef struct TRatePt:
+ TDate fDate
+ double fRate
+
cdef extern from "isda/cds.h":
TCurve* JpmcdsCleanSpreadCurve(
@@ -81,3 +90,5 @@ cdef class ZeroCurve(Curve):
cdef class SpreadCurve(Curve):
pass
+
+cdef fArray_to_list(TRatePt* fArray, int fNumItems)
diff --git a/curve.pyx b/curve.pyx
index 7aa620a..c956295 100644
--- a/curve.pyx
+++ b/curve.pyx
@@ -3,6 +3,7 @@ from curve cimport JpmcdsBuildIRZeroCurve, JpmcdsZeroPrice
from date cimport (JpmcdsStringToDateInterval, pydate_to_TDate, dcc,
JpmcdsDateIntervalToFreq, JpmcdsDateFwdThenAdjust, TDate_to_pydate,
JpmcdsDateFromBusDaysOffset)
+from date import dcc_tostring
from cdsone cimport JpmcdsStringToStubMethod, TStubMethod
cdef int SUCCESS = 0
@@ -18,7 +19,17 @@ cdef class Curve:
JpmcdsFreeTCurve(self._thisptr)
def inspect(self):
- return {'base_date': TDate_to_pydate(self._thiptr.fBaseDate)}
+ return {'base_date': TDate_to_pydate(self._thisptr.fBaseDate),
+ 'basis': self._thisptr.fBasis,
+ 'day_count_convention': dcc_tostring(self._thisptr.fDayCountConv),
+ 'data': fArray_to_list(self._thisptr.fArray, self._thisptr.fNumItems)}
+
+cdef fArray_to_list(TRatePt* fArray, int fNumItems):
+ cdef size_t i
+ cdef list l = []
+ for i in range(fNumItems):
+ l.append((TDate_to_pydate(fArray[i].fDate), fArray[i].fRate))
+ return l
cdef class ZeroCurve(Curve):
@@ -49,7 +60,7 @@ cdef class ZeroCurve(Curve):
period_bytes = p.encode('utf-8')
if JpmcdsStringToDateInterval(period_bytes, routine, &tmp) != SUCCESS:
raise ValueError
- if JpmcdsDateFwdThenAdjust(settle_date, &tmp, NONE,
+ if JpmcdsDateFwdThenAdjust(settle_date, &tmp, MODIFIED,
"None", &self._dates[i]) != SUCCESS:
raise ValueError('Invalid interval')