diff options
Diffstat (limited to 'python/analytics/tranche_basket.py')
| -rw-r--r-- | python/analytics/tranche_basket.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/python/analytics/tranche_basket.py b/python/analytics/tranche_basket.py index 8297f83d..930a5a2a 100644 --- a/python/analytics/tranche_basket.py +++ b/python/analytics/tranche_basket.py @@ -167,7 +167,10 @@ class DualCorrTranche(): instance.direction = rec.protection if rec.index_ref is not None: instance._index.tweak([rec.index_ref]) - instance.reset_pv() + try: + instance.reset_pv() + except ValueError: + pass return instance @property @@ -365,7 +368,8 @@ class DualCorrTranche(): spread = args['spread'] else: if not self.index_type == "BS": - sql_query = ("SELECT close_spread from index_quotes_pre " + col_ref = "close_price" if self.index_type == "HY" else "close_spread" + sql_query = (f"SELECT {col_ref} from index_quotes_pre " "WHERE date=%s and index=%s and series=%s and " "tenor=%s and source=%s") conn = serenitas_engine.raw_connection() @@ -373,11 +377,11 @@ class DualCorrTranche(): c.execute(sql_query, (self.value_date, self.index_type, self.series, self.tenor, args.get("source", "MKIT"))) try: - spread, = c.fetchone() + ref, = c.fetchone() except TypeError: raise ValueError("No quote for that date") try: - self._index.tweak([spread]) + self._index.tweak([ref]) except NameError: pass |
