diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/analytics/__init__.py | 2 | ||||
| -rw-r--r-- | python/analytics/tranche_basket.py | 17 |
2 files changed, 16 insertions, 3 deletions
diff --git a/python/analytics/__init__.py b/python/analytics/__init__.py index 86c80816..4ca3b19f 100644 --- a/python/analytics/__init__.py +++ b/python/analytics/__init__.py @@ -20,4 +20,4 @@ def init_ontr(value_date=datetime.date.today()): global _ontr, _beta _ontr = CreditIndex('HY', on_the_run("HY", value_date), '5yr', value_date) _ontr.mark() - _beta = {'HY': 1, 'IG': .3, 'EU': .22} + _beta = {'HY': 1, 'IG': .3, 'EU': .22, "BS": 0.5} diff --git a/python/analytics/tranche_basket.py b/python/analytics/tranche_basket.py index 26dfd437..b8db1183 100644 --- a/python/analytics/tranche_basket.py +++ b/python/analytics/tranche_basket.py @@ -291,6 +291,20 @@ class DualCorrTranche(): names=['spread_shock', 'corr_shock'])) def mark(self, **args): + if self.index_type == "BS": + return + sql_query = ("SELECT close_spread from index_quotes_pre " + "WHERE date=%s and index=%s and series=%s and " + "tenor=%s and source=%s") + conn = serenitas_engine.raw_connection() + with conn.cursor() as c: + c.execute(sql_query, (self.value_date, self.index_type, self.series, + self.tenor, args.get("source", "MKIT"))) + params = (self.value_date, self.index_type, self.series, + self.tenor, args.get("source", "MKIT")) + spread, = c.fetchone() + self._index.tweak([spread]) + if 'skew' in args: el, skew_fun = args['skew'] K_index_eq = np.clip(el/-self.index_pv().protection_leg * self.K, None, .999) @@ -301,7 +315,6 @@ class DualCorrTranche(): "WHERE a.index=%s AND a.series=%s AND a.tenor=%s " "AND quotedate::date=%s " "AND (a.detach = %s OR a.attach = %s) ORDER BY a.attach") - conn = serenitas_engine.raw_connection() with conn.cursor() as c: c.execute(sql_string, (self.index_type, self.series, self.tenor, self.value_date, @@ -318,7 +331,7 @@ class DualCorrTranche(): self._tranche_id = tranche_id except UnboundLocalError: pass - conn.close() + conn.close() def jump_to_default(self, skew): curves = self._index.curves |
