summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pyisda/credit_index.pyx19
1 files changed, 10 insertions, 9 deletions
diff --git a/pyisda/credit_index.pyx b/pyisda/credit_index.pyx
index 0264272..017f9fe 100644
--- a/pyisda/credit_index.pyx
+++ b/pyisda/credit_index.pyx
@@ -630,7 +630,8 @@ cdef class CreditIndex(CurveList):
self._curves[i].reset(new_buf, char_free)
self.names[CurveName(new_buf + offset)] = i
- def survival_matrix(self, const TDate[::1] schedule=None, double epsilon=0., bint logsp=False):
+ @cython.wraparound(False)
+ def survival_matrix(self, const TDate[::1] schedule=None, double epsilon=0., bint log_dp=False):
cdef:
TCurve* sc
pair[CurveName, size_t] p
@@ -647,17 +648,17 @@ cdef class CreditIndex(CurveList):
n[0] = self._curves.size()
cdef:
- np.ndarray sp = np.PyArray_EMPTY(2, n, np.NPY_DOUBLE, 1)
- np.ndarray tickers = np.PyArray_EMPTY(1, n, np.NPY_OBJECT, 1)
- double[::1,:] sp_view = sp
+ np.ndarray[object, ndim=1] tickers = np.PyArray_EMPTY(1, n, np.NPY_OBJECT, 1)
+ np.ndarray[np.float64_t, ndim=2] sp = np.PyArray_EMPTY(2, n, np.NPY_DOUBLE, 1)
+ double[::1, :] sp_view = sp
j = 0
for p in self.names:
sc = <TCurve*>(self._curves[p.second].get())
- tickers[j] = string(p.first.ticker.begin(), p.first.ticker.end())
+ tickers[j] = PyUnicode_FromStringAndSize(p.first.ticker.data(), p.first.ticker.size())
for i in range(n[1]):
sp_view[j, i] = survival_prob(sc, self.base_date,
- schedule_ptr[i], epsilon, logsp)
+ schedule_ptr[i], epsilon, log_dp)
j += 1
return sp, tickers
@@ -846,7 +847,7 @@ cdef unsigned long fill_mask(const TDate maturity, const vector[TDate]& maturiti
mask |= 1 << i
return mask
-cdef inline int get_maturity_index(TDate maturity, const vector[TDate]& maturities):
+cdef inline int get_maturity_index(TDate maturity, const vector[TDate]& maturities) noexcept nogil:
cdef size_t i
for i in range(maturities.size()):
if maturities[i] == maturity:
@@ -856,7 +857,7 @@ cdef inline int get_maturity_index(TDate maturity, const vector[TDate]& maturiti
return i
cdef pair[TContingentLeg_ptr, TFeeLeg_ptr] get_legs(TDate maturity,
- TDate start_date, const char* cal) nogil:
+ TDate start_date, const char* cal) noexcept nogil:
cdef:
pair[TContingentLeg_ptr, TFeeLeg_ptr] r
TStubMethod stub_type
@@ -888,7 +889,7 @@ cdef double pv(const vector[shared_ptr[char]]& curves,
double fixed_rate,
const vector[double]& weights,
double epsilon,
- unsigned long mask) nogil:
+ unsigned long mask) noexcept nogil:
cdef:
double fl_pv, cl_pv, r = 0.0
TCurve *tweaked_curve