aboutsummaryrefslogtreecommitdiffstats
path: root/python/collateral
diff options
context:
space:
mode:
Diffstat (limited to 'python/collateral')
-rw-r--r--python/collateral/gs_fcm.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/python/collateral/gs_fcm.py b/python/collateral/gs_fcm.py
index 851d8618..33d25bfd 100644
--- a/python/collateral/gs_fcm.py
+++ b/python/collateral/gs_fcm.py
@@ -36,16 +36,29 @@ def collateral(d: datetime.date, positions, *, engine, fund, positions_irs, **kw
"Instrument",
"CCP Trade ID",
"Pay Notional",
+ "Pay Leg Rate/Index",
+ "Receive Leg Rate/Index",
],
parse_dates=["COB Date", "Maturity Date"],
index_col=["Red Code", "Maturity Date"],
thousands=",",
)
- df_rates = (
- df[df["Instrument"] == "IRS"]
- .drop(["Instrument", "Notional"], axis=1)
- .set_index("CCP Trade ID")
+ df_rates = df[df["Instrument"] == "IRS"].drop(["Instrument", "Notional"], axis=1)
+ df_rates = df_rates.reset_index()
+ df_rates.loc[df_rates["Direction"] == "Receive", "Pay Notional"] *= -1
+ df_rates["fixed_rate"] = df_rates.apply(
+ lambda row: row["Receive Leg Rate/Index"]
+ if row["Direction"] == "Receive"
+ else row["Pay Leg Rate/Index"],
+ axis=1,
)
+ # Going to fix roll day at IMM for now until we have the column updated
+ df_rates["roll_day"] = "IMM"
+ df_rates = df_rates.rename(columns={"Pay Notional": "NOTIONAL"})
+ df_rates = df_rates.groupby(by=["Maturity Date", "fixed_rate", "roll_day"])[
+ ["NOTIONAL", "NPV (local)"]
+ ].sum()
+ df_rates.index.names = ["maturity_date", "fixed_rate", "roll_day"]
df = df[df["Instrument"] == "CDS"].drop(
["Instrument", "CCP Trade ID", "Pay Notional"], axis=1
)