diff options
| author | Guillaume Horel <guillaume.horel@gmail.com> | 2019-02-06 12:52:02 -0500 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@gmail.com> | 2019-02-06 12:52:02 -0500 |
| commit | 5643fadff431acefd9f34f4997da5ec9ec05dae3 (patch) | |
| tree | ec399725713e6af72497b745254dfbc255fbc69c | |
| parent | 3167341d4e9e28075b561666f9bd724d91dff062 (diff) | |
| download | pyisda-5643fadff431acefd9f34f4997da5ec9ec05dae3.tar.gz | |
simplify code
| -rw-r--r-- | pyisda/credit_index.pyx | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/pyisda/credit_index.pyx b/pyisda/credit_index.pyx index d8187dd..207a8e0 100644 --- a/pyisda/credit_index.pyx +++ b/pyisda/credit_index.pyx @@ -460,21 +460,15 @@ cdef class CreditIndex(CurveList): TDate maturity_c = pydate_to_TDate(maturity) TContingentLeg* cl size_t i - int found + double cl_pv, r = 0 + TCurve* sc + double* recovery_rate - found = get_maturity_index(maturity_c, self._maturities) - if found == -1: + with nogil: cl = JpmcdsCdsContingentLegMake(self.start_date, maturity_c, 1., True) - else: - cl = self.contingent_legs[found] - cdef: - double cl_pv, r = 0 - TCurve* sc - double* recovery_rate - with nogil: with parallel(): for i in prange(self._curves.size()): sc = self._curves[i].get() @@ -491,7 +485,6 @@ cdef class CreditIndex(CurveList): deref(recovery_rate), &cl_pv) r += self._weights[i] * cl_pv - if found == -1: free(cl) return r |
