diff options
| -rw-r--r-- | pyisda/curve.pyx | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/pyisda/curve.pyx b/pyisda/curve.pyx index c88a9bf..84f93d0 100644 --- a/pyisda/curve.pyx +++ b/pyisda/curve.pyx @@ -645,13 +645,10 @@ cdef class YieldCurve(Curve): forward_rates(curve1.fArray, curve1.fBaseDate, n1, f1, t1) forward_rates(curve2.fArray, curve2.fBaseDate, n2, f2, t2) - for i in range(n1): - t1[i] -= curve2.fBaseDate - curve1.fBaseDate - i = 0 j = 0 while i < n1 and j < n2: - cs.s.push_back(f1[j] / f2[i] - 1) + cs.s.push_back(f1[i] / f2[j] - 1) if t1[i] < t2[j]: cs.t.push_back(t1[i]) i += 1 @@ -679,6 +676,7 @@ cdef class YieldCurve(Curve): int n1, n2 int t1, t2 double *f + int* t vector[double] f_shocked vector[int] t_shocked double acc @@ -693,20 +691,20 @@ cdef class YieldCurve(Curve): while i < n1 and j < shock.t.size(): f_shocked.push_back(f[i] * (1 + shock.s[j])) if t[i] < shock.t[j]: - i += 1 t_shocked.push_back(t[i]) + i += 1 elif shock.t[j] < t[i]: - j += 1 t_shocked.push_back(shock.t[j]) + j += 1 else: + t_shocked.push_back(t[i]) i += 1 j += 1 - t_shocked.push_back(t[i]) free(t) free(f) shocked_yc.buf_size = sizeof(TCurve) + f_shocked.size() * sizeof(TRatePt) - buf = <char*>malloc(self.buf_size) + buf = <char*>malloc(shocked_yc.buf_size) shocked_yc.buf.reset(buf, char_free) shocked_curve = <TCurve*>buf shocked_curve.fNumItems = f_shocked.size() |
