diff options
| author | Guillaume Horel <guillaume.horel@gmail.com> | 2022-05-12 22:01:30 -0400 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@gmail.com> | 2022-05-12 22:01:30 -0400 |
| commit | 3f4630349da58dba5262346037c656a9a9d3d53a (patch) | |
| tree | f15991f2a11ab0717bfe0c5510f54660425f9aff | |
| parent | 4ab12785e381917148c935ec8da015e0dfb3a5bb (diff) | |
| download | pyisda-3f4630349da58dba5262346037c656a9a9d3d53a.tar.gz | |
catch error
| -rw-r--r-- | pyisda/curve.pyx | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/pyisda/curve.pyx b/pyisda/curve.pyx index f333e92..76dcd06 100644 --- a/pyisda/curve.pyx +++ b/pyisda/curve.pyx @@ -296,6 +296,7 @@ cdef class YieldCurve(Curve): TDateInterval ivl char* routine = 'zerocurve' TDate value_date = pydate_to_TDate(date) + TCurve* curve self.dates = vector[TDate](len(periods)) @@ -314,14 +315,13 @@ cdef class YieldCurve(Curve): period_bytes = p if JpmcdsStringToDateInterval(period_bytes, routine, &tmp) != SUCCESS: raise ValueError - if types[i] == 'M': - period_adjust = MODIFIED - else: - period_adjust = NONE + # according to Markit docs, Swap maturities should be Unadjusted + # but this doesn't match with Bloomberg + # period_adjust = MODIFIED if types[i] == 'M' else NONE + period_adjust = MODIFIED if JpmcdsDateFwdThenAdjust(settle_date, &tmp, period_adjust, "None", &self.dates[i]) != SUCCESS: raise ValueError('Invalid interval') - cdef char* fixed_bytes = fixed_swap_period cdef char* float_bytes = float_swap_period cdef char* types_bytes = types @@ -335,12 +335,16 @@ cdef class YieldCurve(Curve): if JpmcdsDateIntervalToFreq(&ivl, &float_freq) != SUCCESS: raise ValueError - self._thisptr.reset(JpmcdsBuildIRZeroCurve( + curve = JpmcdsBuildIRZeroCurve( value_date, types_bytes, self.dates.data(), &rates[0], self.dates.size(), dcc(mm_dcc), <long> fixed_freq, <long> float_freq, dcc(fixed_swap_dcc), dcc(float_swap_dcc), bad_day_conv, b"None" - ), JpmcdsFreeTCurve) + ) + if curve is NULL: + raise ValueError("Curve didn't build") + else: + self._thisptr.reset(curve, JpmcdsFreeTCurve) cdef size_t size(self) nogil: return Curve.size(self) + sizeof(size_t) + sizeof(TDate) * self.dates.size() |
