aboutsummaryrefslogtreecommitdiffstats
path: root/python/analytics
diff options
context:
space:
mode:
Diffstat (limited to 'python/analytics')
-rw-r--r--python/analytics/basket_index.py7
-rw-r--r--python/analytics/tranche_basket.py12
2 files changed, 13 insertions, 6 deletions
diff --git a/python/analytics/basket_index.py b/python/analytics/basket_index.py
index 4c08c157..612fb733 100644
--- a/python/analytics/basket_index.py
+++ b/python/analytics/basket_index.py
@@ -121,8 +121,11 @@ class BasketIndex(CreditIndex):
def _get_quotes(self, *args):
""" allow to tweak based on manually inputed quotes"""
- return {m: self._snacpv(s*1e-4, self.coupon(m), self.recovery, m)
- for m, s in zip(self.maturities, args[0])}
+ if self.index_type == "HY":
+ return {m: (100-p)/100 for m, p in zip(self.maturities, args[0])}
+ else:
+ return {m: self._snacpv(s*1e-4, self.coupon(m), self.recovery, m)
+ for m, s in zip(self.maturities, args[0])}
value_date = property(CreditIndex.value_date.__get__)
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