aboutsummaryrefslogtreecommitdiffstats
path: root/python/cds_rebook.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/cds_rebook.py')
-rw-r--r--python/cds_rebook.py77
1 files changed, 51 insertions, 26 deletions
diff --git a/python/cds_rebook.py b/python/cds_rebook.py
index bf13de33..761b3809 100644
--- a/python/cds_rebook.py
+++ b/python/cds_rebook.py
@@ -26,7 +26,9 @@ def get_outstanding_positions(conn, trade_date, fcm, fund="SERCGMAST"):
yield from c
-def new_version_quotes(conn, auction_date: datetime.date, recovery, accrual_days, coupon=0.05):
+def new_version_quotes(
+ conn, auction_date: datetime.date, recovery, accrual_days, coupon=0.05
+):
adj_recovery = 100 * (
recovery + accrual_days * coupon / 360 - cds_accrued(auction_date, coupon)
)
@@ -159,19 +161,41 @@ def insert_newids(dawndb, d: datetime.date, df: pd.DataFrame):
def send_csv(dawndb, d: datetime.date, ticker):
- columns = ["dealid", "folder", "cp_code", "trade_date", "effective_date", "maturity",
- "currency", "payment_rolldate", "notional", "fixed_rate", "day_count",
- "frequency", "protection", "security_id", "security_desc", "upfront",
- "upfront_settle_date", "swap_type", "account_code", "portfolio", "fund",
- "indexfactor", "version"]
+ columns = [
+ "dealid",
+ "folder",
+ "cp_code",
+ "trade_date",
+ "effective_date",
+ "maturity",
+ "currency",
+ "payment_rolldate",
+ "notional",
+ "fixed_rate",
+ "day_count",
+ "frequency",
+ "protection",
+ "security_id",
+ "security_desc",
+ "upfront",
+ "upfront_settle_date",
+ "swap_type",
+ "account_code",
+ "portfolio",
+ "fund",
+ "indexfactor",
+ "version",
+ ]
buf = BytesIO()
with dawndb.cursor() as c:
- sql_str = (f"COPY (SELECT {','.join(columns)} "
- "FROM cds "
- "JOIN index_version "
- "ON security_id=redindexcode "
- f"WHERE fund='BOWDST' AND cp_code='CONTRA' AND trade_date='{d}')"
- " TO STDOUT WITH (FORMAT CSV, HEADER)")
+ sql_str = (
+ f"COPY (SELECT {','.join(columns)} "
+ "FROM cds "
+ "JOIN index_version "
+ "ON security_id=redindexcode "
+ f"WHERE fund='BOWDST' AND cp_code='CONTRA' AND trade_date='{d}')"
+ " TO STDOUT WITH (FORMAT CSV, HEADER)"
+ )
c.copy_expert(sql_str, buf)
dawndb.commit()
buf = buf.getvalue()
@@ -182,20 +206,21 @@ This are the the rebookings due to {ticker} credit event on {d:%m/%d}. Let me kn
Thanks,
Guillaume"""
- em.send_email(f"{ticker} credit event",
- body,
- to_recipients=(
- "caagtradecapture@bnymellon.com",
- "hm-operations@bnymellon.com",
- "julie.picariello@bnymellon.com",
- ),
- cc_recipients=(
- "sa1futures.optionsprocessing@bnymellon.com",
- "bowdoin-ops@lmcg.com",
- "Viraphong.Douangmany@BNYMellon.com"
- ),
- attach=(FileAttachment(name=f"{ticker}_rebooking.csv", content=buf),)
- )
+ em.send_email(
+ f"{ticker} credit event",
+ body,
+ to_recipients=(
+ "caagtradecapture@bnymellon.com",
+ "hm-operations@bnymellon.com",
+ "julie.picariello@bnymellon.com",
+ ),
+ cc_recipients=(
+ "sa1futures.optionsprocessing@bnymellon.com",
+ "bowdoin-ops@lmcg.com",
+ "Viraphong.Douangmany@BNYMellon.com",
+ ),
+ attach=(FileAttachment(name=f"{ticker}_rebooking.csv", content=buf),),
+ )
if __name__ == "__main__":