diff options
| author | Guillaume Horel <guillaume.horel@gmail.com> | 2017-05-18 13:00:16 -0400 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@gmail.com> | 2017-05-18 13:00:16 -0400 |
| commit | 99142814d1110cea40ac336952047c3aaedbecc7 (patch) | |
| tree | ff659cd712e25f60a8693cfdf15627e4457c6c8d | |
| parent | 6b6136b2fbbd9db33a2c99b01d13e11d9a896dc9 (diff) | |
| download | pyisda-99142814d1110cea40ac336952047c3aaedbecc7.tar.gz | |
fix theta computation
| -rw-r--r-- | pyisda/credit_index.pyx | 17 |
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): |
