aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/bowdst.py45
1 files changed, 42 insertions, 3 deletions
diff --git a/python/bowdst.py b/python/bowdst.py
index b6b4fb16..efc3aa00 100644
--- a/python/bowdst.py
+++ b/python/bowdst.py
@@ -1,7 +1,10 @@
import datetime
import pandas as pd
from env import DAILY_DIR
-from exchange import ExchangeMessage
+from exchange import ExchangeMessage, Message
+from exchangelib import FileAttachment
+from io import StringIO
+from remote import SftpClient
from utils.db import dbconn
em = ExchangeMessage()
@@ -27,7 +30,8 @@ df = pd.read_csv(p, thousands=",")
df = df[df["Asset Type"] == "FIXED INCOME SECURITIES"]
df = df.set_index("CUSIP")
df = df[["Shares/Par", "Base Price", "Local Market Value"]]
-df["Local Market Value"] = pd.to_numeric(df["Local Market Value"].str.replace(",", ""))
+for col in df.select_dtypes(include=["object"]).columns:
+ df[col] = pd.to_numeric(df[col].str.replace(",", ""))
dawndb = dbconn("dawndb")
df_blotter = pd.read_sql_query(
"SELECT * FROM risk_positions(%s, NULL, %s)",
@@ -35,4 +39,39 @@ df_blotter = pd.read_sql_query(
params=(workdate, "BOWDST"),
index_col=["identifier"],
)
-check = df.join(df_blotter)
+check = df_blotter.join(df)
+
+cds_positions = pd.read_sql_query(
+ "SELECT * FROM list_cds_marks_pre(%s, NULL, %s)",
+ dawndb,
+ params=(workdate, "BOWDST"),
+)
+
+
+def send_email(workdate: datetime.date, df_bonds: pd.DataFrame, df_cds: pd.DataFrame):
+ email = Message(
+ account=em._account,
+ folder=em._account.sent,
+ subject=f"{workdate} positions",
+ body="",
+ to_recipients=("reconfiles@bnymellon.com", "hm-operations@bnymellon.com"),
+ cc_recipients=("bowdoin-ops@lmcg.com",),
+ )
+ buf = StringIO()
+ df_bonds.to_csv(buf)
+ bond_attach = FileAttachment(
+ name=f"{workdate} bonds.csv", content=buf.getvalue().encode()
+ )
+ buf.close()
+ email.attach(bond_attach)
+ buf = StringIO()
+ df_cds.to_csv(buf, index=False)
+ cds_attach = FileAttachment(
+ name=f"{workdate} cds.csv", content=buf.getvalue().encode()
+ )
+ buf.close()
+ email.attach(cds_attach)
+ email.send_and_save()
+
+
+# sftp = SftpClient.from_creds("gs")