From 5d810dc7e1a9ce094c8458bf8e2aba69e073709d Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Thu, 13 Apr 2017 11:26:24 -0400 Subject: more __hash__ methods --- pyisda/legs.pyx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pyisda/legs.pyx b/pyisda/legs.pyx index f80f5f7..6decaa5 100644 --- a/pyisda/legs.pyx +++ b/pyisda/legs.pyx @@ -37,6 +37,10 @@ cdef class ContingentLeg: self._thisptr.notional, self._thisptr.protectStart)) + def __hash__(self): + return hash((self._thisptr.startDate, self._thisptr.endDate, + self._thisptr.notional, self._thisptr.protectStart)) + def pv(self, today, step_in_date, value_date, YieldCurve yc, SpreadCurve sc, double recovery_rate): """ @@ -117,6 +121,15 @@ cdef class FeeLeg: dcc_tostring(self._thisptr.dcc), self._thisptr.obsStartOfDay)) + def __hash__(self): + return hash((self._thisptr.accStartDates[0], + self._thisptr.payDates[self._thisptr.nbDates-1], + self._thisptr.accrualPayConv, + self._thisptr.notional, + self._thisptr.couponRate, + self._thisptr.dcc, + self._thisptr.obsStartOfDay)) + def inspect(self): """convenience method to study the C struct""" cdef list acc_start_dates = [] -- cgit v1.2.3-70-g09d2