aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/trade_dataclasses.py45
1 files changed, 38 insertions, 7 deletions
diff --git a/python/trade_dataclasses.py b/python/trade_dataclasses.py
index 2396e02e..dbea6ad6 100644
--- a/python/trade_dataclasses.py
+++ b/python/trade_dataclasses.py
@@ -19,19 +19,29 @@ Portfolio = Literal[
"OPTIONS", "IR", "MORTGAGES", "CURVE", "TRANCHE", "CLO", "HEDGE_MAC"
] # deprecated IG, HY, STRUCTURED
-_funds = {"SERENITAS_CGMF": "SERCGMAST", "BOWDOINST": "BOWDST"}
-_fcms = {"Bank of America, N.A.": "BAML", "Goldman Sachs": "GS"}
+_funds = {
+ "SERENITAS_CGMF": "SERCGMAST",
+ "BOWDOINST": "BOWDST",
+ "SERENITAS_CGMF": "SERCGMAST",
+ "BOWDOINST": "BOWDST",
+}
+_fcms = {
+ "Bank of America, N.A.": "BAML",
+ "Goldman Sachs": "GS",
+ "BOA": "BAML",
+ "GOLD": "GS",
+}
cdx_broker_codes = {
"GOLDNY": ("GS", "GSMX"),
- "JPCBNY": ("JPGP", "JPDR", "JPOS"),
- "MSCSNY": ("MSDU", "MSTI"),
+ "JPCBNY": ("JPGP", "JPDR", "JPOS", "JP"),
+ "MSCSNY": ("MSDU", "MSTI", "MS"),
"JEFF": ("JFF",),
"BAMSNY": ("BMLE", "BMLM"),
- "BARCNY": ("BARX",),
- "CITINY": ("CGCI", "CGCX", "CGIO"),
+ "BARCNY": ("BARX", "BARC"),
+ "CITINY": ("CGCI", "CGCX", "CGIO", "CG"),
"CSFBBO": ("CSDA",),
"BNPBNY": ("EBNP",),
- "WELFEI": ("WFCD",),
+ "WELFEI": ("WFCD", "WFBS"),
"BSEONY": ("BSEF",),
}
@@ -169,6 +179,15 @@ class FrequencyDumper(Int2BinaryDumper):
adapters.register_dumper(Frequency, FrequencyDumper)
+def desc_str(index_type, series, tenor):
+ if index_type in ("IG", "HY", "HYBB"):
+ return f"CDX {index_type} CDSI S{series} {tenor}Y"
+ elif index_type == "XO":
+ return f"ITRX XOVER CDSI S{series} {tenor}Y"
+ elif index_type == "EU":
+ return f"ITRX EUR CDSI S{series} {tenor}Y"
+
+
class DealType(Enum):
Bond = "BOND"
CDS = "CDX"
@@ -340,6 +359,18 @@ class CDSDeal(
@classmethod
def from_bbg_line(cls, line: dict):
+ if line["Coupon"] == "":
+ with cls._conn.cursor() as c:
+ c.execute(
+ "SELECT coupon, index, series, tenor FROM index_maturity_markit LEFT JOIN index_version USING (redindexcode) WHERE redindexcode=%s AND maturity =%s;",
+ (
+ line["Red Code"],
+ datetime.datetime.strptime(line["Mat Dt"], "%m/%d/%Y").date(),
+ ),
+ )
+ coupon, index, series, tenor = c.fetchone()
+ line["Security"] = desc_str(index, series, tenor.removesuffix("yr"))
+ line["Coupon"] = coupon
cls._bbg_insert_queue.append(list(line.values()))
return cls(
fund=_funds[line["Account"]],