aboutsummaryrefslogtreecommitdiffstats
path: root/python/analytics/tranche_basket.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/analytics/tranche_basket.py')
-rw-r--r--python/analytics/tranche_basket.py30
1 files changed, 16 insertions, 14 deletions
diff --git a/python/analytics/tranche_basket.py b/python/analytics/tranche_basket.py
index b8db1183..8e484a32 100644
--- a/python/analytics/tranche_basket.py
+++ b/python/analytics/tranche_basket.py
@@ -291,19 +291,18 @@ 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 not self.index_type == "BS":
+ 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']
@@ -331,7 +330,10 @@ class DualCorrTranche():
self._tranche_id = tranche_id
except UnboundLocalError:
pass
- conn.close()
+ try:
+ conn.close()
+ except UnboundLocalError:
+ pass
def jump_to_default(self, skew):
curves = self._index.curves