aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/analytics/index.py10
-rw-r--r--python/analytics/portfolio.py8
2 files changed, 10 insertions, 8 deletions
diff --git a/python/analytics/index.py b/python/analytics/index.py
index 2b77862c..88b9d29c 100644
--- a/python/analytics/index.py
+++ b/python/analytics/index.py
@@ -399,7 +399,7 @@ class Index(object):
print(e)
return None
else:
- recovery = 0.4 if index_type == "IG" else 0.3
+ recovery = 0.4 if index_type in ['IG', 'EU'] else 0.3
instance = cls(trade_date, maturity, recovery, coupon, notional,
index_type == "HY", df.issue_date[0])
instance._version = tuple((ld.date(), factor / 100, version) for ld, factor, version in \
@@ -431,9 +431,10 @@ class Index(object):
ON security_id = redindexcode AND cds.maturity = index_desc.maturity
WHERE id=%s""", (trade_id,))
rec = r.fetchone()
- recovery = 0.4 if "IG" in rec.security_desc else 0.3
+ index_type = rec.index
+ recovery = 0.4 if index_type in ['IG', 'EU'] else 0.3
instance = cls(rec.trade_date, rec.maturity, recovery, rec.fixed_rate * 100,
- rec.notional, recovery==0.3, rec.issue_date)
+ rec.notional, recovery, rec.issue_date)
r = _engine.execute("SELECT lastdate, indexfactor/100 AS factor, version FROM index_version " \
"WHERE index=%s and series=%s", (rec.index, rec.series))
instance._version = tuple(tuple(t) for t in r)
@@ -445,6 +446,9 @@ class Index(object):
instance.pv = rec.upfront
instance._original_clean_pv = instance._clean_pv
instance._original_trade_date = rec.trade_date
+ instance.index_type = index_type
+ instance.series = rec.series
+ instance.tenor = rec.tenor
return instance
def __repr__(self):
diff --git a/python/analytics/portfolio.py b/python/analytics/portfolio.py
index 1e803c1f..50b43477 100644
--- a/python/analytics/portfolio.py
+++ b/python/analytics/portfolio.py
@@ -98,11 +98,9 @@ class Portfolio:
else:
self._vs[k] = vs[surface_id]
for swaption in self.swaptions:
- vol_surface = self._vs[(swaption.index.trade_date, ) + \
- _key_from_index(swaption.index)]
- swaption.sigma = float(self._vs[(swaption.index.trade_date, ) \
- + _key_from_index(swaption.index)].
- ev(swaption.T, swaption.moneyness))
+ ind = swaption.index
+ vol_surface = self._vs[(ind.trade_date, ind.index_type, ind.series, ind.tenor)]
+ swaption.sigma = float(vol_surface.ev(swaption.T, swaption.moneyness))
@property
def ref(self):