diff options
| -rw-r--r-- | python/pnl_explain.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/python/pnl_explain.py b/python/pnl_explain.py index b143bca7..c5d27b49 100644 --- a/python/pnl_explain.py +++ b/python/pnl_explain.py @@ -256,8 +256,8 @@ def bond_pnl( start_df = start_df.merge(cash_flow, how="left", on="identifier") start_df.interest = start_df.interest * start_df.notional / 100 start_df.principal = start_df.principal * start_df.notional / 100 - buys = trades[trades.buysell == True] - sells = trades[trades.buysell == False] + buys = trades.loc[trades.buysell] + sells = trades.loc[~trades.buysell] pnl = ( (end_df.usd_market_value.sum() + end_df.int_acc.sum()) @@ -319,14 +319,15 @@ if __name__ == "__main__": help="bond type for which we want the pnl ('Subprime', 'CLO', 'CRT')", ) args = parser.parse_args() - strats = {} - strats["swaption"] = ("IGOPTDEL", "HYOPTDEL") - strats["hedge"] = ("HEDGE_MBS", "HEDGE_CLO", "HEDGE_MAC") - strats["tranche"] = ("IGINX", "HYINX", "XOINX") + strats = { + "swaption": ("IGOPTDEL", "HYOPTDEL"), + "hedge": ("HEDGE_MBS", "HEDGE_CLO", "HEDGE_MAC"), + "tranche": ("IGINX", "HYINX", "XOINX"), + } if args.pnl_type in ("tranche", "swaption"): df_instrument = get_pv(conn=dawndb, **vars(args)) pnl_instrument = df_instrument.pv.diff() + df_instrument.daily - if args.pnl_type not in ("bond"): + if args.pnl_type != "bond": df_index = get_index_pv( args.start_date, args.end_date, args.fund, dawndb, strats[args.pnl_type] ) @@ -343,7 +344,7 @@ if __name__ == "__main__": keys=["daily", "cumulative"], ) ) - elif args.pnl_type not in ("bond"): + elif args.pnl_type == "hedge": print( pd.concat( [pnl_index, pnl_index.cumsum()], axis=1, keys=["daily", "cumulative"], |
