aboutsummaryrefslogtreecommitdiffstats
path: root/python/mtm_upload.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/mtm_upload.py')
-rw-r--r--python/mtm_upload.py60
1 files changed, 5 insertions, 55 deletions
diff --git a/python/mtm_upload.py b/python/mtm_upload.py
index e48a26b6..358a878d 100644
--- a/python/mtm_upload.py
+++ b/python/mtm_upload.py
@@ -6,10 +6,10 @@ from serenitas.utils.env import DAILY_DIR
from serenitas.utils.remote import SftpClient
from serenitas.analytics.dates import next_business_day
import datetime
+from trade_dataclasses import CDSDeal
HEADERS = {
"tranche": [
- "Markit Field Name",
"Swap ID",
"Allocation ID",
"Description",
@@ -43,8 +43,7 @@ HEADERS = {
"Settlement Amount",
"Trader",
"Executing Broker",
- "Dealer",
- "Trade ID",
+ "Dealer Trade ID",
"Notes",
"Parent Transaction Code",
"Parent Trade Date",
@@ -84,58 +83,9 @@ HEADERS = {
def tranche_trades(conn):
- with conn.cursor() as c:
- trades = []
- c.execute(
- "SELECT * FROM cds where attach is not NULL and trade_date > %s and id=3445",
- (datetime.date(2020, 12, 1),),
- )
- for row in c:
- obj = row._asdict()
- rename_keys(
- obj,
- {
- "dealid": "Swap ID",
- "cp_code": "Broker Id",
- "trade_date": "Trade Date",
- "effective_date": "Effective Date",
- "maturity": "Maturity Date",
- "notional": "1st Leg Notional",
- "fixed_rate": "1st Leg Rate",
- "upfront": "Initial Payment",
- "security_id": "RED",
- "orig_attach": "Attachment Point",
- "orig_detach": "Exhaustion Point",
- "currency": "Currency Code",
- "upfront_settle_date": "First Payment Date",
- "cp_code": "Broker Id",
- },
- )
- if obj["Initial Payment"] >= 0:
- obj["Transaction Code"] = "Receive"
- else:
- obj["Initial Payment"] = abs(obj["Initial Payment"])
- obj["Transaction Code"] = "Pay"
- obj["Swap ID"] = "test_1"
- obj["Trade ID"] = obj["Swap ID"]
- obj["Product Type"] = "TRN"
- obj["Transaction Type"] = "NEW"
- obj["Protection"] = "Buy" if obj["protection"] == "Buyer" else "Sell"
- # obj["Trader"] = "Serenitas_Trader"
- obj["Entity Matrix"] = "Publisher"
- obj["Definitions Type"] = "ISDA2014Credit"
- obj["Independent Amount (%)"] = obj["initial_margin_percentage"]
- if "ITRX" in obj["security_desc"]:
- obj["Include Contractual Supplement"] = "Y"
- obj["Contractual Supplement"] = "StandardiTraxxEuropeTranche"
- # Temporary Static Values
- obj["Account Abbreviation"] = "Serenitas-test1"
- # obj["Initial Payment Currency"] = "USD"
- # obj["First Payment Date"] = "2022-01-18"
- # obj["Broker Id"] = "0000571T"
- # obj['DTCC Ineligible'] = 'N'
- obj["Master Document Date"] = "2016-02-17"
- trades.append(obj)
+ trades = []
+ obj = CDSDeal.from_tradeid(3472).to_markit()
+ trades.append(obj)
return trades