From 36f6bec51667a7df7606eba7d53879dca54a1575 Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Wed, 6 Jul 2016 15:58:45 -0400 Subject: add inspect function for FeeLeg --- legs.pxd | 5 ++++- legs.pyx | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/legs.pxd b/legs.pxd index 0b1ded3..c9df02b 100644 --- a/legs.pxd +++ b/legs.pxd @@ -9,7 +9,10 @@ cdef extern from "isda/cx.h": pass ctypedef struct TFeeLeg: - pass + int nbDates + TDate* accStartDates + TDate* accEndDates + TDate* payDates cdef extern from "isda/bastypes.h": ctypedef struct TCashFlow: diff --git a/legs.pyx b/legs.pyx index f45dce1..0a07a9b 100644 --- a/legs.pyx +++ b/legs.pyx @@ -58,6 +58,19 @@ cdef class FeeLeg: if self._thisptr is NULL: raise ValueError + def inspect(self): + cdef list acc_start_dates = [] + cdef list acc_end_dates = [] + cdef list pay_dates = [] + cdef size_t i + for i in range(self._thisptr.nbDates): + acc_start_dates.append(TDate_to_pydate(self._thisptr.accStartDates[i])) + acc_end_dates.append(TDate_to_pydate(self._thisptr.accEndDates[i])) + pay_dates.append(TDate_to_pydate(self._thisptr.payDates[i])) + return {'acc_start_dates': acc_start_dates, + 'acc_end_dates': acc_end_dates, + 'pay_dates': pay_dates} + @property def cashflows(self): cdef TCashFlowList* cfl = JpmcdsFeeLegFlows(self._thisptr) -- cgit v1.2.3-70-g09d2