aboutsummaryrefslogtreecommitdiffstats
path: root/python/analytics/portfolio.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/analytics/portfolio.py')
-rw-r--r--python/analytics/portfolio.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/python/analytics/portfolio.py b/python/analytics/portfolio.py
index 34516172..71a42947 100644
--- a/python/analytics/portfolio.py
+++ b/python/analytics/portfolio.py
@@ -35,8 +35,9 @@ def portf_repr(method):
"HY Equiv": thousands,
"Strike": lambda x: "N/A" if np.isnan(x) else str(x),
"Type": lambda x: "N/A" if x is None else x,
+ "Corr01": thousands,
},
- "index": False,
+ "index": True,
}
if method == "string":
kwargs["line_width"] = 100
@@ -286,6 +287,10 @@ class Portfolio:
)
elif isinstance(t, DualCorrTranche):
name = f"{t.index_type}{t.series} {t.tenor}"
+ try:
+ theta = t.theta()
+ except ValueError:
+ theta = t.pv / t.notional / t.duration + t.tranche_running * 1e-4
r = (
"Tranche",
name,
@@ -296,10 +301,10 @@ class Portfolio:
None,
None,
None,
- t.upfront,
+ t.pv,
t.delta,
t.gamma,
- t.theta,
+ theta,
getattr(t, "corr01", None),
getattr(t, "IRDV01", None),
None,
@@ -312,7 +317,11 @@ class Portfolio:
else:
raise TypeError
rec.append(r)
- return pd.DataFrame.from_records(rec, columns=headers, index=self.trade_ids)
+ if isinstance(self.trade_ids[0], tuple):
+ index = [tid[1] for tid in self.trade_ids]
+ else:
+ index = self.trade_ids
+ return pd.DataFrame.from_records(rec, columns=headers, index=index)
__repr__ = portf_repr("string")