diff options
Diffstat (limited to 'python/report_ops')
| -rw-r--r-- | python/report_ops/sma.py | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/python/report_ops/sma.py b/python/report_ops/sma.py index 16c58675..807a1a25 100644 --- a/python/report_ops/sma.py +++ b/python/report_ops/sma.py @@ -99,7 +99,7 @@ _sql_query = { "cdx_swaption": "SELECT abs(spr.notional) AS active_notional, spr.serenitas_nav, swaptions.*, index_version_markit.annexdate FROM list_swaption_positions_and_risks(%s, %s) spr LEFT JOIN swaptions ON deal_id=dealid LEFT JOIN index_version_markit ON swaptions.security_id=redindexcode;", "ir_swaption": "SELECT abs(spr.notional) AS active_notional, spr.nav as serenitas_nav, swaptions.*, index_version_markit.effectivedate FROM list_ir_swaption_positions(%s, %s) spr LEFT JOIN swaptions ON deal_id=dealid LEFT JOIN index_version_markit ON swaptions.security_id=redindexcode;", "cdx": "SELECT cds.*, ivm.effectivedate FROM list_cds_marks(%s, null, %s) cds LEFT JOIN index_version_markit ivm ON security_id=redindexcode;", - "ir": "SELECT * FROM ir_swap_risk isr LEFT JOIN irs ON id=swp_id WHERE date=%s AND fund=%s;", + "irs": "SELECT isr.pv, irs.*, accounts2.name FROM ir_swap_risk isr LEFT JOIN irs ON id=swp_id LEFT JOIN accounts2 USING (cash_account) WHERE date=%s AND irs.fund=%s;", } _fund_custodian = {"BOWDST": "BONY2", "ISOSEL": "NT"} @@ -195,6 +195,15 @@ class PositionReport(Deal, deal_type=None, table_name=None): def to_position(self): obj = self.serialize("position") obj["Product Type"] = self.asset_class + match self.asset_class: + case "irs": + obj["TransactionIndicator (Buy/Sell)"] = ( + "Pay Fixed" if self.buysell else "Receive Fixed" + ) + case _: + obj["TransactionIndicator (Buy/Sell)"] = ( + "Buy" if self.buysell else "Sell" + ) return obj @@ -289,6 +298,7 @@ class CDXPosition(PositionReport, asset_class="cdx"): "effectivedate": "effective_date", "security_desc": "description", "security_id": "identifier", + "name": "primebroker", }, ) d["FixedRate"] = d["coupon"] * 100 @@ -296,7 +306,30 @@ class CDXPosition(PositionReport, asset_class="cdx"): d["notional"] = abs(d["notional"]) * d["factor"] d["mtm"] = d["clean_nav"] + d["accrued"] d["cp_code"] = _fund_fcm[fund] + d["primebroker"] = _fund_fcm[fund] d["currency"] = "EUR" if d["index"] in ("EU", "XO") else "USD" d["clearing_house"] = "ICE" d["dealid"] = "Aggregated" return cls.from_dict(**d) + + +class IRSPosition(PositionReport, asset_class="irs"): + @classmethod + def from_query(cls, d: dict, cob, fund): + d = super().from_query(d, cob, fund) + rename_keys( + d, + { + "trade_date": "start_date", + "effectivedate": "effective_date", + "pv": "mtm_valuation", + "maturity_date": "maturity", + "float_index": "identifier", + "swap_type": "description", + "payreceive": "buysell", + "cash_account": "account", + }, + ) + d["clearing_house"] = "ICE" + d["primebroker"] = _fund_fcm[fund] + return cls.from_dict(**d) |
