aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/collateral/cs.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/python/collateral/cs.py b/python/collateral/cs.py
index 2fe89a31..2d47a4c8 100644
--- a/python/collateral/cs.py
+++ b/python/collateral/cs.py
@@ -1,8 +1,11 @@
import datetime
+import logging
import pandas as pd
from . import DAILY_DIR
from .common import load_pdf, next_business_day
+logger = logging.getLogger(__name__)
+
paths = {
"Serenitas": ["NYops", "Margin Calls CS"],
"BowdSt": ["BowdoinOps", "Margin CS"],
@@ -98,7 +101,7 @@ def load_cs_positions(d: datetime.date, fund: str, legacy=False):
skipfooter=29,
)
if df.empty:
- raise ValueError(f"empty collateral statement for {d}")
+ raise ValueError(f"empty position statement for {d}")
df.columns = [c.replace("\n", " ").strip() for c in df.columns]
df = df[1:]
for i, e in df["Structure ID"].items():
@@ -114,7 +117,18 @@ def load_cs_positions(d: datetime.date, fund: str, legacy=False):
def collateral(d, dawn_trades, *, fund="Serenitas", **kwargs):
collateral = get_collateral(next_business_day(d), fund)
- df = load_cs_positions(d, fund)
+ try:
+ df = load_cs_positions(d, fund)
+ except ValueError as e:
+ logger.warning(e)
+ return pd.DataFrame(
+ {
+ "Strategy": ["M_CSH_CASH"],
+ "Amount": [-collateral],
+ "Currency": ["USD"],
+ "date": [d],
+ }
+ ).set_index("Strategy")
df = df.merge(dawn_trades, how="left", left_on="Structure ID", right_on="cpty_id")
missing_ids = df.loc[df.cpty_id.isnull(), "Structure ID"]
if not missing_ids.empty: