summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2017-04-13 11:26:24 -0400
committerGuillaume Horel <guillaume.horel@gmail.com>2017-04-13 11:26:24 -0400
commit5d810dc7e1a9ce094c8458bf8e2aba69e073709d (patch)
treecd40ad87c50b1fb0c6b10fb53f4ce606c3fd17c8
parent6640f53b9d25b041dfa410579119df4910fd915d (diff)
downloadpyisda-5d810dc7e1a9ce094c8458bf8e2aba69e073709d.tar.gz
more __hash__ methods
-rw-r--r--pyisda/legs.pyx13
1 files changed, 13 insertions, 0 deletions
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],
+ <int>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 = []