aboutsummaryrefslogtreecommitdiffstats
path: root/python/api_quotes
diff options
context:
space:
mode:
Diffstat (limited to 'python/api_quotes')
-rw-r--r--python/api_quotes/quotes.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/python/api_quotes/quotes.py b/python/api_quotes/quotes.py
index 278f1e49..c1d36817 100644
--- a/python/api_quotes/quotes.py
+++ b/python/api_quotes/quotes.py
@@ -10,6 +10,15 @@ firmness = Literal["FIRM", "INDICATIVE"]
asset_class = Literal["CD"]
+def maturity_dt(d):
+ try:
+ return datetime.date(
+ int(d["maturityyear"]), int(d["maturitymonth"]), int(d["maturityday"])
+ )
+ except ValueError: # Sometimes maturity isn't included but we still have tenor
+ return
+
+
@dataclass
class QuoteDetails(Deal, table_name="markit_quote_details", deal_type=None):
quotetime: datetime
@@ -41,9 +50,7 @@ class Quote(Deal, table_name="markit_quotes", deal_type=None):
@classmethod
def from_markit_line(cls, d):
additional_attributes = {
- "maturity": datetime.date(
- int(d["maturityyear"]), int(d["maturitymonth"]), int(d["maturityday"])
- ),
+ "maturity": maturity_dt(d),
"msg_id": d["message"]["id"],
"quotedate": datetime.datetime.fromtimestamp(
d["receiveddatetime"] / 1000