aboutsummaryrefslogtreecommitdiffstats
path: root/python/pnl_explain.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/pnl_explain.py')
-rw-r--r--python/pnl_explain.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/python/pnl_explain.py b/python/pnl_explain.py
index d67bd536..7103e36b 100644
--- a/python/pnl_explain.py
+++ b/python/pnl_explain.py
@@ -129,6 +129,13 @@ def get_tranche_pv(
return df
+def get_pv(**kwargs):
+ if (pnl_type := kwargs.pop("pnl_type")) == "swaption":
+ return get_swaption_pv(**kwargs)
+ else:
+ return get_tranche_pv(**kwargs)
+
+
if __name__ == "__main__":
import argparse
from utils.db import dbconn
@@ -162,23 +169,19 @@ if __name__ == "__main__":
help="instrument for which we want the pnl (one of 'tranche' or 'swaption')",
)
args = parser.parse_args()
- swaption_strats = ("IGTOPTDEL", "HYOPTDEL")
+ swaption_strats = ("IGOPTDEL", "HYOPTDEL")
tranche_strats = ("IGINX", "HYINX", "XOINX")
- pnl_type = "tranche"
if args.pnl_type == "tranche":
index_strats = tranche_strats
else:
index_strats = swaption_strats
- df_index = get_index_pv(args.start_date, args.end_date, dawndb, tranche_strats)
+ df_index = get_index_pv(args.start_date, args.end_date, dawndb, index_strats)
- if args.pnl_type == "tranche":
- df_instrument = get_tranche_pv(conn=dawndb, **vars(args))
- else:
- df_instrument = get_swaption_pv(conn=dawndb, **vars(args))
+ df_instrument = get_pv(conn=dawndb, **vars(args))
pnl_index = df_index.pv.diff() + df_index.daily
pnl_instrument = df_instrument.pv.diff() + df_instrument.daily
- pnl = pd.concat([pnl_index, pnl_instrument], keys=["index", pnl_type], axis=1)
+ pnl = pd.concat([pnl_index, pnl_instrument], keys=["index", args.pnl_type], axis=1)
print(
pd.concat(
[pnl.sum(axis=1), pnl.sum(axis=1).cumsum()],