From 2bceb65952f5007d92e8cbd723f96f5a4e699e69 Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Tue, 28 Nov 2017 16:17:45 -0500 Subject: try to implement pickle for index --- pyisda/credit_index.pyx | 7 +++++++ 1 file changed, 7 insertions(+) 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: -- cgit v1.2.3-70-g09d2