aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/cds_curve.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/python/cds_curve.py b/python/cds_curve.py
index 74dcbd61..d7313e5c 100644
--- a/python/cds_curve.py
+++ b/python/cds_curve.py
@@ -1,4 +1,4 @@
-from pyisda.curve import YieldCurve, BadDay, SpreadCurve
+from pyisda.curve import YieldCurve, BadDay, SpreadCurve, fill_curve
from pyisda.credit_index import CreditIndex
from pyisda.legs import FeeLeg, ContingentLeg
from pyisda.logging import enable_logging
@@ -28,15 +28,17 @@ def get_singlenames_quotes(indexname, date):
return [r for r in c]
def build_curve(r, today_date, yc, start_date, step_in_date, value_date, end_dates):
- spread_curve = 1e-4 * np.array(r['spread_curve'][1:])
- upfront_curve = 1e-2 * np.array(r['upfront_curve'][1:])
- recovery_curve = np.array(r['recovery_curve'][1:])
+ spread_curve = 1e-4 * np.array(r['spread_curve'][1:], dtype='float')
+ upfront_curve = 1e-2 * np.array(r['upfront_curve'][1:], dtype='float')
+ recovery_curve = np.array(r['recovery_curve'][1:], dtype='float')
try:
sc = SpreadCurve(today_date, yc, start_date, step_in_date, value_date,
end_dates, spread_curve, upfront_curve, recovery_curve, True)
+ if np.any(np.isnan(upfront_curve)):
+ sc = fill_curve(sc, end_dates)
except ValueError as e:
print(e)
- pdb.set_trace()
+ import pdb;pdb.set_trace()
return (r['cds_ticker'], sc)
def grouper(iterable, n, fillvalue=None):