summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2017-11-16 14:55:44 -0500
committerGuillaume Horel <guillaume.horel@gmail.com>2017-11-16 15:08:33 -0500
commitd6268113ac807e7f137b54aed71f07486645c3fb (patch)
tree0fb14f642092fafe82d3ab5e585dcd72dec942cd
parenta708e5b1c8e43f2cc1298d6ed5bcd0a21a6f74c9 (diff)
downloadpyisda-d6268113ac807e7f137b54aed71f07486645c3fb.tar.gz
return numpy array
-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.