aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/analytics/tranche_basket.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/python/analytics/tranche_basket.py b/python/analytics/tranche_basket.py
index b5e5f1af..38114670 100644
--- a/python/analytics/tranche_basket.py
+++ b/python/analytics/tranche_basket.py
@@ -23,7 +23,7 @@ from .utils import (
run_local,
)
from collections import namedtuple
-from . import dawn_engine, serenitas_engine, serenitas_pool
+from . import dawn_engine, serenitas_pool
from copy import deepcopy
from dateutil.relativedelta import relativedelta
from lru import LRU
@@ -150,12 +150,14 @@ class DualCorrTranche:
):
if all((redcode, maturity)):
- r = serenitas_engine.execute(
- "SELECT index, series, tenor FROM index_desc "
- "WHERE redindexcode=%s AND maturity = %s",
- (redcode, maturity),
- )
- index_type, series, tenor = next(r)
+ conn = serenitas_pool.getconn()
+ with conn.cursor() as c:
+ c.execute(
+ "SELECT index, series, tenor FROM index_desc "
+ "WHERE redindexcode=%s AND maturity = %s",
+ (redcode, maturity),
+ )
+ index_type, series, tenor = c.fetchone()
self._index = BasketIndex(index_type, series, [tenor], value_date=value_date)
self.index_type = index_type
@@ -577,7 +579,7 @@ class DualCorrTranche:
"WHERE date=%s and index=%s and series=%s and "
"tenor=%s and source=%s"
)
- conn = serenitas_engine.raw_connection()
+ conn = serenitas_pool.getconn()
with conn.cursor() as c:
c.execute(
sql_query,
@@ -595,6 +597,7 @@ class DualCorrTranche:
raise MissingDataError(
f"{type(self).__name__}: No market quote for date {self.value_date}"
)
+ serenitas_pool.putconn(conn)
try:
self._index.tweak([ref])
except NameError:
@@ -619,6 +622,8 @@ class DualCorrTranche:
break
moneyness_eq = self.K / self.expected_loss()
self.rho = self._skew(moneyness_eq)
+ if self.detach == 100:
+ self.rho[1] = np.nan
def jump_to_default(self, skew):
curves = self._index.curves