aboutsummaryrefslogtreecommitdiffstats
path: root/python/analytics
diff options
context:
space:
mode:
Diffstat (limited to 'python/analytics')
-rw-r--r--python/analytics/basket_index.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/python/analytics/basket_index.py b/python/analytics/basket_index.py
index d595eef6..f3addf9b 100644
--- a/python/analytics/basket_index.py
+++ b/python/analytics/basket_index.py
@@ -10,13 +10,6 @@ import datetime
from scipy.optimize import brentq
from pandas.tseries.offsets import BDay
-def make_index(t, d, args):
- instance = t.__new__(t)
- for k, v in d.items():
- setattr(instance, k, v)
- CreditIndex.__init__(instance, *args)
- return instance
-
class BasketIndex(CreditIndex):
index_type: str
series: int
@@ -58,10 +51,18 @@ class BasketIndex(CreditIndex):
self.tweaks = []
super().__init__(self.issue_date, maturities, curves)
- def __reduce__(self):
+ def __getstate__(self):
_, args = CreditIndex.__reduce__(self)
- d = vars(self)
- return partial(make_index, self.__class__), (d, args)
+ return (self.__dict__.copy(), args)
+
+ def __setstate__(self, state):
+ self.__dict__.update(state[0])
+ print("I'm here")
+ print(state[1])
+ CreditIndex.__init__(self, *state[1])
+
+ def __hash__(self):
+ return CreditIndex.__hash__(self)
def _query_version(self, i):
for lastdate, *data in self._version: