aboutsummaryrefslogtreecommitdiffstats
path: root/python/quote_diff_bowdst.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/quote_diff_bowdst.py')
-rw-r--r--python/quote_diff_bowdst.py77
1 files changed, 58 insertions, 19 deletions
diff --git a/python/quote_diff_bowdst.py b/python/quote_diff_bowdst.py
index dcd861fd..48f64141 100644
--- a/python/quote_diff_bowdst.py
+++ b/python/quote_diff_bowdst.py
@@ -2,28 +2,67 @@ from serenitas.utils.db import dbconn
import numpy as np
import datetime
import pandas as pd
+from serenitas.utils.exchange import ExchangeMessage
+from io import StringIO
+from exchangelib import FileAttachment
+import argparse
conn = dbconn("dawndb")
+parser = argparse.ArgumentParser(description="determine sender destination")
+parser.add_argument("--globeop", action="store_true", help="send to globeop")
+
+args = parser.parse_args()
+
with conn.cursor() as c:
- days = pd.bdate_range(end=datetime.date.today(), periods=60)
- for date in days:
- df = pd.read_sql(
- sql="SELECT * FROM list_bowd_quotes(%s)",
- con=conn,
- params=(date.date(),),
+ df = pd.read_sql(
+ sql="SELECT * FROM list_bowd_quotes(%s)",
+ con=conn,
+ params=(datetime.date.today() - datetime.timedelta(1),),
+ )
+ try:
+ diff = df[~np.isclose(df["bowd_price"], df["closeprice"], atol=0.15)].rename(
+ mapper={"closeprice": "our_price"}, axis=1
)
- try:
- print(df[~np.isclose(df["bowd_price"], df["closeprice"], atol=0.15)])
- except TypeError:
- pass
- # c.execute("select security_desc, tenor, price, closeprice from list_cds_marks(%s, null, 'BOWDST') a left join index_quotes using (index, series, version, tenor) where date = %s",
- # (date.date(), date.date(),))
+ except TypeError:
+ breakpoint()
+ else:
+
+ if not diff.empty:
+ buf = StringIO()
+ diff.to_csv(buf, index=False)
+ subject = "ACTION REQUESTED: Stale/Inaccurate Quotes"
+ msg = (
+ "Good morning,\n\n"
+ f"We notice a difference in our quotes by more than 15 cents for the following indices:\n\n"
+ f"{diff.to_string(index=False)}\n\n"
+ "We have also attached a copy of the csv for your convenience."
+ f"Thanks for your help.\n\n"
+ f"Flint"
+ )
+ attachments = [
+ FileAttachment(
+ name=f"quote_differences.csv", content=buf.getvalue().encode()
+ )
+ ]
+ em = ExchangeMessage()
+ if args.globeop:
+ recipients = (
+ "hm-operations@bnymellon.com",
+ "caagprim@bnymellon.com",
+ )
+ cc_recipients = (
+ "fyu@lmcg.com",
+ "Bowdoin-Ops@LMCG.com",
+ )
+ else:
+ recipients = ("fyu@lmcg.com",)
+ cc_recipients = ()
- # for row in c:
- # print(date)
- # print(row.price, row.closeprice)
- # if row.price != row.closeprice:
- # breakpoint()
- # if not np.isclose(row.price, row.closeprice, atol=.01):
- # print(row.security_desc, row.tenor, row.price, row.closeprice)
+ em.send_email(
+ subject,
+ msg,
+ to_recipients=recipients,
+ cc_recipients=cc_recipients,
+ attach=attachments,
+ )