summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2023-12-06 15:21:14 -0500
committerGuillaume Horel <guillaume.horel@gmail.com>2023-12-06 15:21:14 -0500
commit91e26f9a55f61a9ffef6f9658f1b55b05e76ebb9 (patch)
tree0275d3bdc93204a4c46ac9b14dbf7ec93de1dcfc
parent5dae9f5ef287051da68aebea342af3663bf97398 (diff)
downloadpyisda-91e26f9a55f61a9ffef6f9658f1b55b05e76ebb9.tar.gz
add __len__ and full_tickers methods
-rw-r--r--pyisda/credit_index.pyx9
1 files changed, 9 insertions, 0 deletions
diff --git a/pyisda/credit_index.pyx b/pyisda/credit_index.pyx
index 9f56293..65dc439 100644
--- a/pyisda/credit_index.pyx
+++ b/pyisda/credit_index.pyx
@@ -106,6 +106,8 @@ cdef class CurveList:
for i in range(self._weights.size()):
self._weights[i] /= total_weight
+ def __len__(self):
+ return self._curves.size()
def __getitem__(self, tuple name not None):
cdef:
@@ -261,6 +263,13 @@ cdef class CurveList:
return out
@property
+ def full_tickers(self):
+ cdef:
+ pair[CurveName, size_t] p
+ for p in self.names:
+ yield (PyUnicode_FromStringAndSize(p.first.ticker.data(), p.first.ticker.size()), to_seniority(p.first.seniority), to_doc_clause(p.first.doc_clause))
+
+ @property
def value_date(self):
return TDate_to_pydate(self.base_date)