summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pyisda/credit_index.pxd2
-rw-r--r--pyisda/credit_index.pyx7
2 files changed, 8 insertions, 1 deletions
diff --git a/pyisda/credit_index.pxd b/pyisda/credit_index.pxd
index f3e61b8..005d166 100644
--- a/pyisda/credit_index.pxd
+++ b/pyisda/credit_index.pxd
@@ -7,7 +7,7 @@ from libcpp.string cimport string
cdef class CurveList:
cdef TDate base_date
- cdef public vector[double] weights
+ cdef vector[double] weights
cdef vector[double] T
cdef vector[shared_ptr[TCurve]] curves
cdef unordered_map[string, size_t] tickers
diff --git a/pyisda/credit_index.pyx b/pyisda/credit_index.pyx
index 663d6ed..bc3ee8f 100644
--- a/pyisda/credit_index.pyx
+++ b/pyisda/credit_index.pyx
@@ -84,6 +84,13 @@ cdef class CurveList:
yield (sc.ticker.decode(), self.weights[p.second], sc)
@property
+ def weights(self):
+ cdef np.npy_intp shape = self.weights.size()
+ cdef np.ndarray[np.float64_t] out = \
+ np.PyArray_SimpleNewFromData(1, &shape, np.NPY_DOUBLE, self.weights.data())
+ return out
+
+ @property
def curves(self):
"""returns the list of curves inside the porfolio.