aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/api_quotes/quotes.py30
1 files changed, 23 insertions, 7 deletions
diff --git a/python/api_quotes/quotes.py b/python/api_quotes/quotes.py
index 3925ff9d..599ef493 100644
--- a/python/api_quotes/quotes.py
+++ b/python/api_quotes/quotes.py
@@ -19,8 +19,28 @@ def maturity_dt(d):
return
+class MarkitQuoteKind:
+ def __class_getitem__(cls, trade_type: str):
+ match trade_type:
+ case "CD":
+ return Quote
+
+
+class MarkitQuote(Deal, table_name=None, deal_type=None):
+ @classmethod
+ def from_markit_line(cls, d):
+ base_attributes = {
+ "msg_id": d["message"]["id"],
+ "quotedate": datetime.datetime.fromtimestamp(
+ d["receiveddatetime"] / 1000
+ ).replace(tzinfo=datetime.timezone.utc),
+ "quotesource": d["sourceshortname"],
+ }
+ return base_attributes
+
+
@dataclass
-class Quote(Deal, table_name="markit_singlename_quotes", deal_type=None):
+class Quote(MarkitQuote, table_name="markit_singlename_quotes", deal_type=None):
quoteid: int
msg_id: str
quotesource: str
@@ -41,16 +61,12 @@ class Quote(Deal, table_name="markit_singlename_quotes", deal_type=None):
@classmethod
def from_markit_line(cls, d):
+ base_attributes = super().from_markit_line(d)
additional_attributes = {
"maturity": maturity_dt(d),
- "msg_id": d["message"]["id"],
- "quotedate": datetime.datetime.fromtimestamp(
- d["receiveddatetime"] / 1000
- ).replace(tzinfo=datetime.timezone.utc),
- "quotesource": d["sourceshortname"],
"tenor": f"{d['tenor']}Y",
}
- d.update(additional_attributes)
+ d.update(base_attributes | additional_attributes)
return cls.from_dict(**d)
@property