aboutsummaryrefslogtreecommitdiffstats
path: root/python/margin_estimates.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/margin_estimates.py')
-rw-r--r--python/margin_estimates.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/python/margin_estimates.py b/python/margin_estimates.py
index bfde115f..96f676e3 100644
--- a/python/margin_estimates.py
+++ b/python/margin_estimates.py
@@ -55,6 +55,34 @@ def get_total_collateral_citi(d):
)
+def get_collateral_cs(d: datetime.date, fund="Serenitas"):
+ DATA_DIR = DAILY_DIR / fund / "CS_reports"
+ collat = {}
+ full_name = {
+ "Serenitas": "SerenitasCGMF",
+ "BowdSt": "BostonBPStLLC",
+ }
+ for collat_type in ("RVM", "IM", "FXIM"):
+ pdf_file = (
+ DATA_DIR
+ / f"CollateralCptyStatement161{full_name[fund]}{collat_type}_{d:%m%d%Y}.pdf"
+ )
+ g = iter(load_pdf(pdf_file))
+ for e in g:
+ if e.text == "Cash USD (US Dollar)":
+ next(g)
+ value = next(g).text
+ collat[collat_type] = float(
+ value.strip().replace(",", "").replace("(", "-").replace(")", "")
+ )
+ break
+ return (
+ pd.DataFrame.from_dict(collat, orient="index", columns=["amount to receive"])
+ .rename_axis("account")
+ .reset_index()
+ )
+
+
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
@@ -106,6 +134,7 @@ if __name__ == "__main__":
params=((args.trade_date + BDay(1)).date(), (args.trade_date + BDay(3)).date()),
)
citi = get_total_collateral_citi(args.trade_date)
+ cs = get_collateral_cs(args.trade_date)
body = [
"<html><body>",
"<h3> Collateral Estimates Receive/(Pay) at ISDA :</h3>",
@@ -118,6 +147,8 @@ if __name__ == "__main__":
html_generator(payment_settlements, "receive"),
"<h3>Citi Breakdown :</h3>",
html_generator(citi, "amount to receive"),
+ "<h3>CS Breakdown :</h3>",
+ html_generator(cs, "amount to receive"),
"</body></html>",
]