summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pyisda/credit_index.pyx17
1 files changed, 9 insertions, 8 deletions
diff --git a/pyisda/credit_index.pyx b/pyisda/credit_index.pyx
index 66c475a..1bb86bb 100644
--- a/pyisda/credit_index.pyx
+++ b/pyisda/credit_index.pyx
@@ -239,12 +239,14 @@ cdef class CreditIndex(CurveList):
TDate value_date_c = pydate_to_TDate(value_date)
TDate maturity_c = pydate_to_TDate(maturity)
vector[double] h
- pair[TContingentLeg,TFeeLeg] legs = get_legs(maturity_c,
- self.start_date,
- self.contingent_legs,
- self.fee_legs,
- self.maturities)
+ pair[TContingentLeg,TFeeLeg] legs
+
if old_pv != old_pv:
+ legs = get_legs(maturity_c,
+ self.start_date,
+ self.contingent_legs,
+ self.fee_legs,
+ self.maturities)
old_pv = pv(self.curves, self.base_date, step_in_date_c,
value_date_c, yc._thisptr.get(), legs,
recovery_rate, fixed_rate, self.weights,
@@ -256,10 +258,9 @@ cdef class CreditIndex(CurveList):
self.contingent_legs,
self.fee_legs,
self.maturities)
- return pv(self.curves, self.base_date, step_in_date_c, value_date_c,
+ return old_pv - pv(self.curves, self.base_date, step_in_date_c, value_date_c,
yc._thisptr.get(), legs, recovery_rate, fixed_rate,
- self.weights, 0., h, self.T, 0) - \
- old_pv + fixed_rate
+ self.weights, 0., h, self.T, 0) + fixed_rate
@cython.boundscheck(False)
def duration(self, step_in_date, value_date, maturity, YieldCurve yc not None):