aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/recon_bowdst.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/python/recon_bowdst.py b/python/recon_bowdst.py
index d5d95266..afa9eddf 100644
--- a/python/recon_bowdst.py
+++ b/python/recon_bowdst.py
@@ -11,6 +11,12 @@ from pandas.tseries.offsets import BDay
import numpy as np
import pandas_market_calendars as mcal
+# def last_weekday(date):
+# if date.weekday() in range(1,5):
+# return date
+# else:
+# return (date - BDay(1)).date()
+
def get_dir(date):
p = DAILY_DIR / "BOWD_recon" / f"{date:%Y_%m}"
@@ -159,7 +165,7 @@ def recon(hierarchy_file, date):
tranche_trades = pd.read_sql_query(
f"select security_desc, maturity, orig_attach, orig_detach, sum(notional * tranche_factor) as db_notional, sum(admin_notional) as admin_notional, sum(serenitas_clean_nav) as db_mv, sum(admin_clean_nav) as admin_mv from tranche_risk_bowdst where date=%s group by security_desc, maturity, orig_attach, orig_detach ;",
dawndb,
- params=(date,),
+ params=(last_bus_day(date),),
)
cdx_trades = pd.read_sql_query(
@@ -194,20 +200,28 @@ def recon(hierarchy_file, date):
"cdx_swaption_trades",
"ir_swaption_trades",
]
- message = ""
+ overview = []
em = ExchangeMessage()
attachments = []
for kind, name in zip(kinds, names):
buf = StringIO()
- difference(kind.round(decimals=2).fillna(0)).to_csv(buf)
+ difference(kind.round(decimals=0).fillna(0)).to_csv(buf)
attachments.append(
FileAttachment(name=f"{name}_{date}.csv", content=buf.getvalue().encode())
)
pd.set_option("display.float_format", lambda x: "%.2f" % x)
- message += f"\n{name}: {pd.DataFrame(sums(kind), columns=['sums'])}"
+ df = pd.DataFrame(sums(kind), columns=["sums"])
+ df["name"] = name
+ df.set_index("name")
+ overview.append(df)
+ buf = StringIO()
+ pd.concat(overview).round(decimals=0).to_csv(buf)
+ attachments.append(
+ FileAttachment(name=f"overview.csv", content=buf.getvalue().encode())
+ )
em.send_email(
subject=f"Notional Totals {date}",
- body=message,
+ body="See attached",
to_recipients=("fyu@lmcg.com",),
attach=attachments,
)