aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/collateral/__main__.py2
-rw-r--r--python/collateral/ms.py26
2 files changed, 17 insertions, 11 deletions
diff --git a/python/collateral/__main__.py b/python/collateral/__main__.py
index 143933a6..3d234381 100644
--- a/python/collateral/__main__.py
+++ b/python/collateral/__main__.py
@@ -73,7 +73,7 @@ def run_collateral(cp, fund, positions, workdate, engine):
try:
return cp_mod.collateral(workdate, positions, engine=engine, fund=fund)
except FileNotFoundError as e:
- logger.info(e)
+ logger.warning(e)
lookback += 1
workdate = prev_business_day(workdate)
except ValueError as e:
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")