diff options
| author | Guillaume Horel <guillaume.horel@serenitascapital.com> | 2016-10-26 12:39:22 -0400 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@serenitascapital.com> | 2016-10-26 12:39:22 -0400 |
| commit | f7ab19d4dfa4a9a8b4f5c098fe0a816f7ed4c40a (patch) | |
| tree | 456313e3c9da106b04fac1b4629f840d014e995b | |
| parent | 7beefa282fffea3e8f9540e5bde08e8687f13732 (diff) | |
| download | pyisda-f7ab19d4dfa4a9a8b4f5c098fe0a816f7ed4c40a.tar.gz | |
add a couple nogil
| -rw-r--r-- | pyisda/curve.pxd | 4 | ||||
| -rw-r--r-- | pyisda/curve.pyx | 4 | ||||
| -rw-r--r-- | pyisda/date.pxd | 4 |
3 files changed, 5 insertions, 7 deletions
diff --git a/pyisda/curve.pxd b/pyisda/curve.pxd index 52cfbed..f59bbe0 100644 --- a/pyisda/curve.pxd +++ b/pyisda/curve.pxd @@ -86,13 +86,13 @@ cdef extern from "isda/tcurve.h": cdef extern from "isda/cxzerocurve.h": double JpmcdsZeroPrice(TCurve* curve, TDate date) - double JpmcdsForwardZeroPrice(TCurve* curve, TDate startDate, TDate maturityDate) + double JpmcdsForwardZeroPrice(TCurve* curve, TDate startDate, TDate maturityDate) nogil cdef extern from "isda/cfinanci.h": int JpmcdsDiscountToRateYearFrac(double discount, # (I) Discount factor double yearFraction, # (I) See JpmcdsDayCountFraction double basis, # (I) Basis for the rate - double *rate) + double *rate) nogil cdef enum Basis: CONTINUOUS = 5000 DISCOUNT_RATE = 512 diff --git a/pyisda/curve.pyx b/pyisda/curve.pyx index ec75cf6..bee364c 100644 --- a/pyisda/curve.pyx +++ b/pyisda/curve.pyx @@ -189,11 +189,9 @@ cdef class YieldCurve(Curve): cdef double* rates = <double*>malloc(sizeof(double) * yc._ninstr) cdef size_t k cdef double df - cdef double df_forward_date = JpmcdsZeroPrice( - self._thisptr, forward_date_c) for k in range(yc._ninstr): yc._dates[k] = self._dates[i] - df = JpmcdsZeroPrice(self._thisptr, self._dates[i])/df_forward_date + df = JpmcdsForwardZeroPrice(self._thisptr, forward_date_c, self._dates[i]) JpmcdsDiscountToRateYearFrac( df, <double>(self._dates[i] - forward_date_c)/365., <double>1, &rates[k]) diff --git a/pyisda/date.pxd b/pyisda/date.pxd index b84d9e5..d04dca1 100644 --- a/pyisda/date.pxd +++ b/pyisda/date.pxd @@ -32,14 +32,14 @@ cdef extern from "isda/dateconv.h": cdef extern from "isda/ldate.h": int JpmcdsDateFwdThenAdjust(TDate date, TDateInterval* interval, long badDayMethod, - char* holidayFile, TDate *advAdjustedDate) + char* holidayFile, TDate *advAdjustedDate) nogil cdef extern from "isda/busday.h": int JpmcdsDateFromBusDaysOffset(TDate fromDate, # (I) input date long offset, # (I) number of business days char *holidayFile, # (I) holiday file specification - TDate *result); + TDate *result) nogil cdef TDate pydate_to_TDate(c_datetime.date d) cpdef c_datetime.date TDate_to_pydate(TDate d) |
