summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2018-10-12 13:01:13 -0400
committerGuillaume Horel <guillaume.horel@gmail.com>2018-10-12 13:01:13 -0400
commita4f6952f4515bda0ee7bc37595569405a30d1174 (patch)
tree15c4ef07c6f18d9affce05be68b88d588fe1000e
parent8f969e3a6c165ac208c8e0434a7d0b173dc45b18 (diff)
downloadpyisda-a4f6952f4515bda0ee7bc37595569405a30d1174.tar.gz
ugly fix for the missing 6m rate
-rw-r--r--pyisda/credit_index.pyx24
1 files changed, 16 insertions, 8 deletions
diff --git a/pyisda/credit_index.pyx b/pyisda/credit_index.pyx
index 6885aa9..5d8ee65 100644
--- a/pyisda/credit_index.pyx
+++ b/pyisda/credit_index.pyx
@@ -1,10 +1,10 @@
#cython: cdivision=True, boundscheck=False, c_string_type=unicode, c_string_encoding=ascii
from libc.stdlib cimport malloc, free
-from libc.math cimport nan
+from libc.math cimport nan, isnan
from libc.string cimport memcpy, memset
from libcpp.pair cimport pair
from libcpp.memory cimport unique_ptr
-from cython.operator cimport dereference as deref
+from cython.operator cimport dereference as deref, preincrement as preinc
from cpython cimport PyObject, Py_INCREF
from cython.parallel cimport prange, parallel
@@ -617,7 +617,7 @@ cdef double pv(const vector[shared_ptr[TCurve]]& curves,
TCurve *tweaked_curve
TCurve *orig_curve
size_t i = 0
- double recovery_rate
+ double* recovery_rate
if epsilon == 0.:
with parallel():
@@ -626,14 +626,18 @@ cdef double pv(const vector[shared_ptr[TCurve]]& curves,
for i in prange(curves.size()):
tweaked_curve = curves[i].get()
- recovery_rate = recovery_rates[i].get()[0]
+ recovery_rate = recovery_rates[i].get()
+ # FIXME: do something better
+ if isnan(deref(recovery_rate)):
+ preinc(recovery_rate)
+
JpmcdsContingentLegPV(legs.first,
base_date,
cash_settle_date,
step_in_date,
yc,
tweaked_curve,
- recovery_rate,
+ deref(recovery_rate),
&cl_pv)
JpmcdsFeeLegPV(legs.second,
base_date,
@@ -652,14 +656,18 @@ cdef double pv(const vector[shared_ptr[TCurve]]& curves,
for i in prange(curves.size()):
orig_curve = curves[i].get()
tweak_curve(orig_curve, tweaked_curve, epsilon, mask)
- recovery_rate = recovery_rates[i].get()[0]
+ recovery_rate = recovery_rates[i].get()
+ # FIXME: do something better
+ if isnan(deref(recovery_rate)):
+ preinc(recovery_rate)
+
JpmcdsContingentLegPV(legs.first,
base_date,
cash_settle_date,
- step_in_date,
+ step_in_date,
yc,
tweaked_curve,
- recovery_rate,
+ deref(recovery_rate),
&cl_pv)
JpmcdsFeeLegPV(legs.second,
base_date,