diff options
| -rw-r--r-- | python/analytics/basket_index.py | 2 | ||||
| -rw-r--r-- | python/cds_curve.py | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/python/analytics/basket_index.py b/python/analytics/basket_index.py index 0701e713..0398a6f6 100644 --- a/python/analytics/basket_index.py +++ b/python/analytics/basket_index.py @@ -45,6 +45,8 @@ class BasketIndex(CreditIndex): index_col='tenor', params=(index_type, series), parse_dates=['maturity', 'issue_date']) + if self.index_desc.empty: + raise ValueError(f"Index {index_type} {series} doesn't exist") r = _engine.execute("SELECT lastdate, indexfactor/100 AS factor, cumulativeloss/100, version " \ "FROM index_version " \ "WHERE index = %s AND series = %s" \ diff --git a/python/cds_curve.py b/python/cds_curve.py index 2b321e59..027c61e9 100644 --- a/python/cds_curve.py +++ b/python/cds_curve.py @@ -30,7 +30,10 @@ def all_curves_pv(curves, today_date, jp_yc, start_date, step_in_date, value_dat def calibrate_portfolio(index_type, series, tenors=['3yr', '5yr', '7yr', '10yr'], start_date=None): - index = MarkitBasketIndex(index_type, series, tenors) + try: + index = MarkitBasketIndex(index_type, series, tenors) + except ValueError: + return if start_date: index.index_quotes = index.index_quotes[start_date:] for value_date, v in index.index_quotes.groupby('date')['id']: |
