aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/cds_rebook.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/python/cds_rebook.py b/python/cds_rebook.py
index fa826913..165aaccf 100644
--- a/python/cds_rebook.py
+++ b/python/cds_rebook.py
@@ -6,15 +6,15 @@ from analytics.index import CreditIndex
from copy import copy
-def get_outstanding_positions(trade_date):
+def get_outstanding_positions(trade_date, fcm):
r = dawn_engine.execute(
"SELECT security_id, notional, folder, nextredindexcode, currency, "
"maturity, indexfactor "
- "FROM list_cds_positions_by_strat(%s) a "
+ "FROM list_cds_positions_by_strat_fcm(%s, %s) a "
"JOIN index_version_markit "
"ON a.security_id=index_version_markit.redindexcode "
"WHERE nextredindexcode IS NOT NULL",
- (trade_date,),
+ (trade_date, fcm),
)
return r
@@ -33,13 +33,18 @@ def default_adjustment(company_id, end_date):
return accrual_days, fee
-PORTFOLIO = {"HYOPTDEL": "OPTIONS", "HEDGE_MBS": "MORTGAGES"}
+PORTFOLIO = {
+ "HYOPTDEL": "OPTIONS",
+ "HEDGE_MBS": "MORTGAGES",
+ "HYINX": "TRANCHE",
+ "SER_IGCURVE": "CURVE",
+}
-def rebook(trade_date, company_id):
+def rebook(trade_date, company_id, fcm):
upfront_settle_date = trade_date + 3 * BDay()
effective_date = trade_date + datetime.timedelta(days=1)
- for r in get_outstanding_positions(trade_date):
+ for r in get_outstanding_positions(trade_date, fcm):
accrual_days, fee = default_adjustment(company_id, r["maturity"])
index_new = CreditIndex(
redcode=r["nextredindexcode"],
@@ -58,7 +63,7 @@ def rebook(trade_date, company_id):
"action": "NEW",
"portfolio": PORTFOLIO[r["folder"]],
"folder": r["folder"],
- "cp_code": "INTERCO",
+ "cp_code": "CONTRA",
"custodian": "NONE",
"trade_date": trade_date,
"effective_date": effective_date,
@@ -75,6 +80,7 @@ def rebook(trade_date, company_id):
"upfront": index_new.pv,
"upfront_settle_date": upfront_settle_date,
"swap_type": "CD_INDEX",
+ "account_code": fcm,
}
trade_prev = copy(trade_new)
trade_prev["protection"] = (
@@ -93,4 +99,7 @@ if __name__ == "__main__":
# PKD
# rebook(datetime.date(2019, 1, 24), 101148)
# WINDSSE
- rebook(datetime.date(2019, 4, 8), 36806879)
+ # rebook(datetime.date(2019, 4, 8), 36806879)
+ # WFT
+ rebook(datetime.date(2019, 7, 26), 103633, "WF")
+ rebook(datetime.date(2019, 7, 26), 103633, "BAML")