aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/report_ops/sma.py41
1 files changed, 29 insertions, 12 deletions
diff --git a/python/report_ops/sma.py b/python/report_ops/sma.py
index caadba85..375701d0 100644
--- a/python/report_ops/sma.py
+++ b/python/report_ops/sma.py
@@ -29,7 +29,7 @@ def build_position_file(
for asset_class in asset_classes:
for position in PositionReport[asset_class].gen_positions(cob, fund):
PositionReport.staging_queue.append(position.to_position())
- buf, dest = PositionReport.build_buffer(cob, fund)
+ buf, dest = PositionReport.build_buffer(cob, fund, "bond" in asset_classes)
PositionReport.staging_queue.clear()
return buf, dest
@@ -149,6 +149,14 @@ _fund_custodian = {"BOWDST": "BONY2", "ISOSEL": "NT"}
_fund_client = {"BOWDST": "Hedgemark", "ISOSEL": "Innocap"}
_fund_fcm = {"BOWDST": "GS_FCM", "ISOSEL": "BOA_FC"}
+product_name_mapping = {
+ "future": "Future",
+ "tranche": "Credit Index Tranche",
+ "cdx_swaption": "CD Swaption",
+ "irs": "IRS Swaption",
+ "cdx": "Credit Index",
+}
+
def get_path(cob, fund):
match fund:
@@ -217,10 +225,12 @@ class PositionReport(Deal, deal_type=None, table_name=None):
yield cls.from_query(row._asdict(), cob, fund)
@classmethod
- def build_buffer(cls, cob, fund):
+ def build_buffer(cls, cob, fund, tail=True):
buf = StringIO()
csvwriter = csv.writer(buf)
headers = get_position_headers(fund)
+ if not tail:
+ headers = headers[:-4]
csvwriter.writerow(headers)
csvwriter.writerows(
[[obj.get(h) for h in headers] for obj in cls.staging_queue]
@@ -235,20 +245,19 @@ class PositionReport(Deal, deal_type=None, table_name=None):
d["client_name"] = _fund_client[fund]
d["fund"] = fund
d["cob"] = cob
+ d["mtm_currency"] = "USD"
return d
def to_position(self):
obj = self.serialize("position")
- obj["Product Type"] = self.asset_class
+ obj["Product Type"] = product_name_mapping.get(
+ self.asset_class, self.asset_class
+ )
match self.asset_class:
case "irs":
- obj["TransactionIndicator (Buy/Sell)"] = (
- "Pay Fixed" if self.buysell else "Receive Fixed"
- )
+ obj["TransactionIndicator (Buy/Sell)"] = "P" if self.buysell else "R"
case _:
- obj["TransactionIndicator (Buy/Sell)"] = (
- "Buy" if self.buysell else "Sell"
- )
+ obj["TransactionIndicator (Buy/Sell)"] = "B" if self.buysell else "S"
return obj
@@ -299,6 +308,7 @@ class TranchePosition(PositionReport, asset_class="tranche"):
"security_desc": "description",
"mtm": "mtm_valuation",
"security_id": "identifier",
+ "coupon": "fixed_rate",
},
)
d["primebroker"] = "Bilateral"
@@ -316,15 +326,22 @@ class SwaptionPosition:
"active_notional": "notional",
"trade_date": "start_date",
"effectivedate": "effective_date",
- "nav": "MTM Valuation",
+ "serenitas_nav": "mtm_valuation",
"expiration_date": "Underlying Maturity",
"security_id": "identifier",
"security_desc": "description",
},
)
+ d["putcall"] = d["option_type"] == "PAYER"
d["primebroker"] = "Bilateral"
+ d["exercise_type"] = "European"
return cls.from_dict(**d)
+ def to_position(self):
+ obj = super().to_position()
+ obj["PutCall Indicator (Call/Put)"] = "P" if self.putcall else "C"
+ return obj
+
class IRSwaptionPosition(SwaptionPosition, PositionReport, asset_class="ir_swaption"):
pass
@@ -347,10 +364,10 @@ class CDXPosition(PositionReport, asset_class="cdx"):
"name": "primebroker",
},
)
- d["FixedRate"] = d["coupon"] * 100
+ d["fixed_rate"] = d["coupon"] * 100
d["buysell"] = d["notional"] > 0
d["notional"] = abs(d["notional"]) * d["factor"]
- d["mtm"] = d["clean_nav"] + d["accrued"]
+ d["mtm_valuation"] = 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"