summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2017-11-28 16:17:45 -0500
committerGuillaume Horel <guillaume.horel@gmail.com>2017-11-29 13:57:27 -0500
commit2bceb65952f5007d92e8cbd723f96f5a4e699e69 (patch)
treee850f00ee96c26111b2367c911736932507856a9
parent3c425b3614e577edafca2b06375cee0acddcc61d (diff)
downloadpyisda-2bceb65952f5007d92e8cbd723f96f5a4e699e69.tar.gz
try to implement pickle for index
-rw-r--r--pyisda/credit_index.pyx7
1 files changed, 7 insertions, 0 deletions
diff --git a/pyisda/credit_index.pyx b/pyisda/credit_index.pyx
index 77f41cf..d13a8e9 100644
--- a/pyisda/credit_index.pyx
+++ b/pyisda/credit_index.pyx
@@ -200,6 +200,9 @@ cdef class CurveList:
copy.tickers = self.tickers
return copy
+ def __reduce__(self):
+ return (self.__class__, (self.curves, self.weights))
+
cdef class CreditIndex(CurveList):
def __init__(self, start_date, maturities, list curves, double[:] weights=None):
CurveList.__init__(self, curves, weights)
@@ -270,6 +273,10 @@ cdef class CreditIndex(CurveList):
copy.contingent_legs[i] = copyContingentLeg(self.contingent_legs[i])
return copy
+ def __reduce__(self):
+ return (self.__class__,
+ (TDate_to_pydate(self.start_date), self.maturities, self.curves, self.weights))
+
#@cython.initializedcheck(False)
def pv_vec(self, step_in_date, value_date, YieldCurve yc, double recovery_rate):
cdef: