aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/db_csvheader.py1
-rw-r--r--python/headers.py68
-rw-r--r--python/trade_dataclasses.py43
3 files changed, 104 insertions, 8 deletions
diff --git a/python/db_csvheader.py b/python/db_csvheader.py
index 6b9d4f66..12032ef8 100644
--- a/python/db_csvheader.py
+++ b/python/db_csvheader.py
@@ -16,6 +16,7 @@ if __name__ == "__main__":
csvreader = csv.reader(csvfile)
for row in csvreader:
row = [header.replace("\n", "") for header in row]
+ print(row)
try:
with open(f"headers/{file_name}.py", "a") as template_file:
template_file.write(f"\n{header_name}={row}")
diff --git a/python/headers.py b/python/headers.py
index 19ef3f8d..e6c94d3a 100644
--- a/python/headers.py
+++ b/python/headers.py
@@ -824,6 +824,74 @@ MTM_HEADERS = {
"Remaining Party",
"DTCC Remaining CounterParty ID",
],
+ DealType.TRS: [
+ "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 ",
+ "Initial Payment",
+ "Initial Payment Currency",
+ "Original Issue Date",
+ "Interest Payment Method Description",
+ "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",
+ "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 Type",
+ "Master Document Version",
+ "",
+ "",
+ "Annex Date",
+ "Supplement Date",
+ "Documentation Type",
+ "Calculation Agent Business Center",
+ "",
+ "Strategy",
+ "Electronic Consent Ineligible",
+ "External OMS ID",
+ "Traded Rate/Price",
+ "Independent Amount Currency",
+ "Independent Amount Payer",
+ "Trade Revision",
+ "Alternate Swap ID",
+ "Alternate Trade ID",
+ "Definitions Type",
+ "Initial Fixing Amount",
+ "2nd Leg Index",
+ "2nd Leg Spread",
+ "2nd Leg Initial Floating Rate",
+ ],
}
diff --git a/python/trade_dataclasses.py b/python/trade_dataclasses.py
index 43d92da3..45fb7f79 100644
--- a/python/trade_dataclasses.py
+++ b/python/trade_dataclasses.py
@@ -398,6 +398,8 @@ class MTMDeal:
cls.product_type = "TRN"
elif deal_type == DealType.Termination:
cls.product_type = "TERM"
+ elif deal_type == DealType.TRS:
+ cls.product_type = "CDI"
@classmethod
def mtm_upload(cls):
@@ -920,7 +922,7 @@ class FxSwapDeal(
@dataclass
class TRSDeal(
- # MTMDeal,
+ MTMDeal,
Deal,
deal_type=DealType.TRS,
table_name="trs",
@@ -933,14 +935,18 @@ class TRSDeal(
folder: str = field(metadata={"globeop": "Folder"})
cash_account: str = field(metadata={"globeop": "Cash Account"})
cp_code: str = field(metadata={"globeop": "Counterparty"})
- trade_date: datetime.date = field(metadata={"globeop": "Trade Date"})
- effective_date: datetime.date
- maturity_date: datetime.date
+ trade_date: datetime.date = field(
+ metadata={"globeop": "Trade Date", "mtm": "Trade Date"}
+ )
+ effective_date: datetime.date = field(
+ init=False, metadata={"mtm": "Effective Date"}
+ )
+ maturity_date: datetime.date = field(metadata={"mtm": "Maturity Date"})
funding_index: str
buysell: bool
underlying_security: str
price: float
- accrued: float
+ accrued: float = field(metadata={"mtm": "Initial Payment"})
funding_freq: str
funding_daycount: str
funding_payment_roll_convention: str
@@ -949,10 +955,10 @@ class TRSDeal(
asset_daycount: str
asset_payment_roll_convention: str
initial_margin_percentage: float = field(
- metadata={"globeop": "InitialMarginPercent"}
+ metadata={"globeop": "InitialMarginPercent", "mtm": "Independent Amount (%)"}
)
- notional: float
- currency: str
+ notional: float = field(metadata={"mtm": "1st Leg Notional"})
+ currency: str = field(metadata={"mtm": "Currency Code"})
interest_calc_method: str
compound_avg_frequency: str
fixing_frequency: str
@@ -962,6 +968,27 @@ class TRSDeal(
default=None, metadata={"insert": False, "mtm": "Swap ID", "globeop": "Deal Id"}
)
+ def __post_init__(self):
+ self.effective_date = self.trade_date + datetime.timedelta(days=1)
+
+ def to_markit(self):
+ _trs_red = {"IBOXHY": "4J623JAA8"}
+ obj = self.serialize("mtm")
+ obj["Trade ID"] = obj["Swap ID"]
+ obj["Initial Payment Currency"] = obj["Currency Code"]
+ if obj["Initial Payment"] >= 0:
+ obj["Transaction Code"] = "Receive"
+ else:
+ obj["Transaction Code"] = "Pay"
+ obj["Initial Payment"] = round(abs(obj["Initial Payment"]), 2)
+ obj["Product Sub Type"] = "IBOXX" # Hardcoded for now
+ obj["RED"] = _trs_red[obj["underlying_security"]]
+ obj["Transaction Type"] = "New"
+ obj["Protection"] = "Buy" if obj["buysell"] else "Sell"
+ obj["Master Document Date"] = datetime.date(2020, 12, 18)
+ obj["Supplement Date"] = datetime.date(2015, 2, 18)
+ return obj
+
def to_admin(self):
obj = self.serialize("globeop")
if obj["buysell"]: