diff options
Diffstat (limited to 'python/cds_rebook.py')
| -rw-r--r-- | python/cds_rebook.py | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/python/cds_rebook.py b/python/cds_rebook.py index fbc505f5..f9b4b98d 100644 --- a/python/cds_rebook.py +++ b/python/cds_rebook.py @@ -11,12 +11,14 @@ from copy import copy def get_outstanding_positions(conn, trade_date, fcm, fund="SERCGMAST"): with conn.cursor() as c: c.execute( - "SELECT security_id, notional, folder, nextredindexcode, currency, " - "maturity, indexfactor " + "SELECT security_id, notional, folder, b.redindexcode, currency, " + "maturity, c.indexfactor " "FROM list_cds_positions_by_strat_fcm(%s, %s, %s) a " - "JOIN index_version_markit " - "ON a.security_id=index_version_markit.redindexcode " - "WHERE nextredindexcode IS NOT NULL AND nextredindexcode !='2I65BRUV0'", + "LEFT JOIN index_version_markit b " + "ON a.security_id=b.prevredindexcode " + "LEFT JOIN index_version_markit c " + "ON a.security_id=c.redindexcode " + "WHERE b.redindexcode IS NOT NULL AND b.activeversion", (trade_date, fcm, fund), ) yield from c @@ -54,7 +56,7 @@ def rebook(conn, trade_date, company_id, seniority, fcm, fund="SERCGMAST"): for r in get_outstanding_positions(dawndb, trade_date, fcm, fund): accrual_days, fee = default_adjustment(conn, company_id, seniority, r.maturity) index_new = CreditIndex( - redcode=r.nextredindexcode, + redcode=r.redindexcode, maturity=r.maturity, value_date=trade_date, notional=r.notional, @@ -83,7 +85,7 @@ def rebook(conn, trade_date, company_id, seniority, fcm, fund="SERCGMAST"): "day_count": "ACT/360", "frequency": 4, "protection": index_new.direction, - "security_id": r.nextredindexcode, + "security_id": r.redindexcode, "security_desc": f"CDX {index_new.index_type} CDSI S{index_new.series} 5Y", "upfront": index_new.pv, "upfront_settle_date": upfront_settle_date, @@ -141,7 +143,11 @@ if __name__ == "__main__": # rebook(conn, datetime.date(2020, 5, 14), 100337, "Senior", "WF") # rebook(conn, datetime.date(2020, 5, 14), 100337, "Senior", "GS", "BOWDST") # DO - rebook(conn, datetime.date(2020, 5, 26), 171248, "Senior", "BAML") - rebook(conn, datetime.date(2020, 5, 26), 171248, "Senior", "WF") - rebook(conn, datetime.date(2020, 5, 26), 171248, "Senior", "GS", "BOWDST") + # rebook(conn, datetime.date(2020, 5, 26), 171248, "Senior", "BAML") + # rebook(conn, datetime.date(2020, 5, 26), 171248, "Senior", "WF") + # rebook(conn, datetime.date(2020, 5, 26), 171248, "Senior", "GS", "BOWDST") + # NMG + rebook(conn, datetime.date(2020, 5, 29), 101056, "Senior", "BAML") + rebook(conn, datetime.date(2020, 5, 29), 101056, "Senior", "WF") + rebook(conn, datetime.date(2020, 5, 29), 101056, "Senior", "GS", "BOWDST") serenitas_pool.putconn(conn) |
