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.py111
1 files changed, 3 insertions, 108 deletions
diff --git a/python/mtm_upload.py b/python/mtm_upload.py
index 40732386..2728fb11 100644
--- a/python/mtm_upload.py
+++ b/python/mtm_upload.py
@@ -6,112 +6,7 @@ from serenitas.utils.remote import SftpClient
from serenitas.analytics.dates import next_business_day
import datetime
from trade_dataclasses import CDSDeal, SwaptionDeal
-
-mtm_headers = {
- "tranche": [
- "Swap ID",
- "Allocation ID",
- "Description",
- "Broker Id",
- "DTCC CounterParty ID",
- "Trade ID",
- "Trade Date",
- "Effective Date",
- "Settle Date",
- "Maturity Date",
- "Account Abbreviation",
- "1st Leg Notional",
- "Currency Code",
- "1st Leg Rate",
- "Initial Payment",
- "Initial Payment Currency",
- "Original Issue Date",
- "Interest Payment Method Description",
- "First Payment Date",
- "Product Type",
- "Product Sub Type",
- "Transaction Type",
- "Protection",
- "Transaction Code",
- "Remaining Party",
- "DTCC Remaining CounterParty ID",
- "Independent Amount (%)",
- "Independent Amount ($)",
- "RED",
- "Issuer Name",
- "Settlement Amount",
- "Trader",
- "Executing Broker",
- "Dealer Trade ID",
- "Notes",
- "Parent Transaction Code",
- "Parent Trade Date",
- "Parent Notional",
- "Parent Currency Code",
- "Parent Net Amount",
- "Parent Effective Date",
- "Parent First Payment Date",
- "Parent Settle Date",
- "ComplianceHubAction",
- "DTCC Ineligible",
- "Master Document Date",
- "Master Document Version",
- "Include Contractual Supplement",
- "Contractual Supplement",
- "Supplement Date",
- "Entity Matrix",
- "Entity Matrix Date",
- "Modified Equity Delivery",
- "Calculation Agent Business Center",
- "Calculation Agent",
- "Attachment Point",
- "Exhaustion Point",
- "Strategy",
- "First Payment Period Accrual Start Date",
- "TieOut Ineligible",
- "Electronic Consent Ineligible",
- "External OMS ID",
- "Independent Amount Currency",
- "Independent Amount Payer",
- "Trade Revision",
- "Alternate Swap ID",
- "Alternate Trade ID",
- "Definitions Type",
- ],
- "swaption": [
- "Swap ID",
- "Broker Id",
- "Trade ID",
- "Trade Date",
- "Settle Date",
- "Supplement Date",
- "Supplement 2 Date",
- "Maturity Date",
- "Account Abbreviation",
- "1st Leg Notional",
- "Currency Code",
- "1st Leg Rate",
- "Initial Payment Currency",
- "Initial Payment",
- "Product Type",
- "Transaction Type",
- "Transaction Code",
- "Independent Amount (%)",
- "RED",
- "Issuer Name",
- "Entity Matrix",
- "Definitions Type",
- "Swaption Expiration Date",
- "Strike Price",
- "Swaption Settlement Type",
- "Master Document Date",
- "OptionBuySellIndicator",
- "Clearing House",
- "Protection",
- "Swaption Quotation Rate Type",
- "Effective Date",
- ],
-}
+from headers import MTM_HEADERS
def rename_keys(d, mapping):
@@ -177,13 +72,13 @@ def tranche_term_trades(conn):
def build_line(obj, asset_type):
- return [obj.get(h, None) for h in mtm_headers[asset_type]]
+ return [obj.get(h, None) for h in MTM_HEADERS[asset_type]]
def process_upload(trades, asset_type, upload):
buf = StringIO()
csvwriter = csv.writer(buf)
- csvwriter.writerow(mtm_headers[asset_type])
+ csvwriter.writerow(MTM_HEADERS[asset_type])
csvwriter.writerows(build_line(trade, asset_type) for trade in trades)
buf = buf.getvalue().encode()
fname = f"MTM.{datetime.datetime.now():%Y%m%d.%H%M%S}.{asset_type.capitalize()}.csv"