diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/trade_dataclasses.py | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/python/trade_dataclasses.py b/python/trade_dataclasses.py index b4071119..525907b4 100644 --- a/python/trade_dataclasses.py +++ b/python/trade_dataclasses.py @@ -30,6 +30,8 @@ _fcms = { "GOLD": "GS", "WB": "WF", } + +_client_name = {"SERCGMAST": "Serenitas", "BOWDST": "HEDGEMARK", "BRINKER": "LMCG"} cdx_broker_codes = { "GOLDNY": ("GS", "GSMX"), "JPCBNY": ("JPGP", "JPDR", "JPOS", "JP"), @@ -521,11 +523,16 @@ class TerminationDeal( insert_ignore=("id", "dealid", "orig_cp", "currency", "fund", "product_type"), ): termination_fee: float = field(metadata={"mtm": "Initial Payment"}) - fee_payment_date: datetime.date = field(metadata={"mtm": "Settle Date"}) + fee_payment_date: datetime.date = field( + metadata={"mtm": "Settle Date", "globeop": "FeePaymentDate"} + ) termination_cp: str = field(metadata={"mtm": "Broker Id"}) - termination_amount: float = field(metadata={"mtm": "1st Leg Notional"}) + termination_amount: float = field( + metadata={"mtm": "1st Leg Notional", "globeop": "TerminationAmount"} + ) termination_date: datetime.date = field( - default_factory=datetime.date.today(), metadata={"mtm": "Trade Date"} + default_factory=datetime.date.today(), + metadata={"mtm": "Trade Date", "globeop": "TerminationDate"}, ) id: int = field(default=None, metadata={"insert": False}) dealid: str = field(default=None, metadata={"insert": False, "mtm": "Swap ID"}) @@ -544,22 +551,33 @@ class TerminationDeal( product_type: str = field( init=False, metadata={"mtm": "Product Type", "insert": False} ) + deal_type: str = field( + init=False, metadata={"insert": False, "globeop": "DealType"} + ) + globeop_id: str = field(init=False, default=None, metadata={"globeop": "gtid"}) def __post_init__(self): if self.dealid.startswith("SWPTN"): self.product_type = "CDISW" + self.deal_type = "SwaptionDeal" table_name = "swaptions" elif self.dealid.startwith("SCCDS"): self.product_type = "TRN" + self.deal_type = "CdsDeal" table_name = "cds" sql_str = ( "SELECT cp_code, currency, fund FROM terminations " f"LEFT JOIN {table_name} USING (dealid) " "WHERE terminations.id = %s" ) + id_sql = "SELECT globeop_id FROM id_mapping WHERE serenitas_id = %s ORDER BY date DESC LIMIT 1;" + with self._conn.cursor() as c: c.execute(sql_str, (self.id,)) self.orig_cp, self.currency, self.fund = c.fetchone() + c.execute(id_sql, (self.id,)) + if globeopid := c.fetchone(): + self.globeop_id = c.fetchone()[0] def to_markit(self): obj = self.serialize("mtm") @@ -576,3 +594,16 @@ class TerminationDeal( ) obj["Effective Date"] = obj["Trade Date"] return obj + + def to_globeop(self): + obj = self.serialize("globeop") + obj["FeesPaid"] = ( + -obj["termination_fee"] if obj["termination_fee"] < 0 else None + ) + obj["FeesReceived"] = ( + obj["termination_fee"] if obj["termination_fee"] > 0 else None + ) + obj["Action"] = "UPDATE" + obj["Client"] = _client_name[obj["fund"]] + obj["SubAction"] = "Termination" + return obj |
