diff options
| -rw-r--r-- | python/position_file_bowdst.py | 28 | ||||
| -rw-r--r-- | python/report_ops/sma.py | 35 |
2 files changed, 49 insertions, 14 deletions
diff --git a/python/position_file_bowdst.py b/python/position_file_bowdst.py index 3fcc1d7d..779c5b75 100644 --- a/python/position_file_bowdst.py +++ b/python/position_file_bowdst.py @@ -9,21 +9,23 @@ from serenitas.analytics.dates import prev_business_day def main(cob, fund, upload): buf, dest = build_position_file( - cob, fund, ["bond", "future", "tranche", "ir_swaption", "cdx_swaption"] + cob, + fund, + ["bond", "future", "tranche", "ir_swaption", "cdx_swaption", "irs", "cdx"], ) - if upload: - client = Client.from_creds("hm_globeop") - client.put(buf, dest.name) - em = ExchangeMessage() - em.send_email( - subject=f"Position_files for Bowdoin Street as of {cob}", - body=f"Please see monthend positions for Bowdoin Street as of {cob}. They have been uploaded to the SFTP as well.", - to_recipients=_cc_recipients[fund], - cc_recipients=_cc_recipients[fund], - reply_to=_cc_recipients[fund], - attach=[FileAttachment(name=dest.name, content=buf)], - ) + # if upload: + # client = Client.from_creds("hm_globeop") + # client.put(buf, dest.name) + # em = ExchangeMessage() + # em.send_email( + # subject=f"Position_files for Bowdoin Street as of {cob}", + # body=f"Please see monthend positions for Bowdoin Street as of {cob}. They have been uploaded to the SFTP as well.", + # to_recipients=_cc_recipients[fund], + # cc_recipients=_cc_recipients[fund], + # reply_to=_cc_recipients[fund], + # attach=[FileAttachment(name=dest.name, content=buf)], + # ) parser = argparse.ArgumentParser( 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) |
