diff options
Diffstat (limited to 'python/collateral/ms.py')
| -rw-r--r-- | python/collateral/ms.py | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/python/collateral/ms.py b/python/collateral/ms.py index 28909ae3..127199ac 100644 --- a/python/collateral/ms.py +++ b/python/collateral/ms.py @@ -53,15 +53,18 @@ def collateral(d, dawn_trades, *, fund="Serenitas", **kwargs): else: collat = float(collat) df = pd.read_excel(DAILY_DIR / fund / "MS_reports" / f"Trade_Detail_{d:%Y%m%d}.xls") - df_fx = pd.read_excel( - DAILY_DIR / fund / "MS_reports" / f"Trade_Detail_FX_{d:%Y%m%d}.xls" - ) - net_fx_exposure = ( - df_fx.loc[df_fx.buy_ccy == "EUR", "amt_buy_ccy"].sum() - - df_fx.loc[df_fx.sell_ccy == "EUR", "amt_sell_ccy"].sum() - ) - fx_ia = net_fx_exposure * 0.05 * get_fx(d, "EUR") - df = pd.concat([df, df_fx]) + try: + df_fx = pd.read_excel( + DAILY_DIR / fund / "MS_reports" / f"Trade_Detail_FX_{d:%Y%m%d}.xls" + ) + net_fx_exposure = ( + df_fx.loc[df_fx.buy_ccy == "EUR", "amt_buy_ccy"].sum() + - df_fx.loc[df_fx.sell_ccy == "EUR", "amt_sell_ccy"].sum() + ) + fx_ia = net_fx_exposure * 0.05 * get_fx(d, "EUR") + df = pd.concat([df, df_fx]) + except FileNotFoundError: # We don't always have FX files + pass # df = df.dropna(subset=["trade_ccy"]) df = df.merge(dawn_trades, how="left", left_on="trade_id", right_on="cpty_id") missing_ids = df.loc[df.cpty_id.isnull(), "trade_id"] @@ -71,7 +74,10 @@ def collateral(d, dawn_trades, *, fund="Serenitas", **kwargs): df["Currency"] = "USD" df = df.reset_index() df.columns = ["Strategy", "Amount", "Currency"] - df.loc[df.Strategy == "TCSH", "Amount"] -= fx_ia + try: + df.loc[df.Strategy == "TCSH", "Amount"] -= fx_ia + except UnboundLocalError: + pass df.loc[len(df.index)] = ["M_CSH_CASH", -collat - df.Amount.sum(), "USD"] df["date"] = d return df.set_index("Strategy") |
