diff options
| -rw-r--r-- | pyisda/credit_index.pyx | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/pyisda/credit_index.pyx b/pyisda/credit_index.pyx index 1d7db78..428fea9 100644 --- a/pyisda/credit_index.pyx +++ b/pyisda/credit_index.pyx @@ -517,12 +517,13 @@ cdef class CreditIndex(CurveList): self._start_date, self.cal_file.c_str()) legs_short = get_legs(maturity_short_c, self._start_date, self.cal_file.c_str()) - with nogil: + with nogil, parallel(): + fl_pv_short = cl_pv_short = fl_pv_long = cl_pv_long = 0.0 for i in prange(self._curves.size()): curve = <TCurve*>(self._curves[i].get()) recovery_rate = <double*>(self._curves[i].get() + self.offset_recovery_rates[i]) JpmcdsContingentLegPV(legs_long.first, - self.base_date, + curve.fBaseDate, cash_settle_date_c, step_in_date_c, yc.get_TCurve(), @@ -530,7 +531,7 @@ cdef class CreditIndex(CurveList): deref(recovery_rate), &cl_pv_long) JpmcdsContingentLegPV(legs_short.first, - self.base_date, + curve.fBaseDate, cash_settle_date_c, step_in_date_c, yc.get_TCurve(), @@ -538,7 +539,7 @@ cdef class CreditIndex(CurveList): deref(recovery_rate), &cl_pv_short) JpmcdsFeeLegPV(legs_long.second, - self.base_date, + curve.fBaseDate, step_in_date_c, cash_settle_date_c, yc.get_TCurve(), @@ -546,19 +547,17 @@ cdef class CreditIndex(CurveList): True, &fl_pv_long) JpmcdsFeeLegPV(legs_short.second, - self.base_date, + curve.fBaseDate, step_in_date_c, cash_settle_date_c, yc.get_TCurve(), curve, True, &fl_pv_short) - r[i] = self._weights[i] * (cl_pv_long - cl_pv_short - (fl_pv_long - fl_pv_short) * fixed_rate) - + r[i] = self._weights[i] * (carry + cl_pv_long - cl_pv_short - (fl_pv_long - fl_pv_short ) * fixed_rate) return arr - def protection_leg(self, step_in_date, cash_settle_date, maturity, YieldCurve yc not None): cdef: TDate step_in_date_c = pydate_to_TDate(step_in_date) |
