diff options
| -rw-r--r-- | python/api_quotes/__main__.py | 6 | ||||
| -rw-r--r-- | python/api_quotes/quotes.py | 34 | ||||
| -rw-r--r-- | sql/serenitasdb.sql | 23 |
3 files changed, 55 insertions, 8 deletions
diff --git a/python/api_quotes/__main__.py b/python/api_quotes/__main__.py index 53a88ac9..26e97dc0 100644 --- a/python/api_quotes/__main__.py +++ b/python/api_quotes/__main__.py @@ -6,7 +6,11 @@ from .quotes import MarkitQuoteKind logger = logging.getLogger(__name__) if __name__ == "__main__": - for asset_class in ("ABS", "CD"): + for asset_class in ( + "CD", + "ABS", + "TRS", + ): after = None while True: if data := MarkitAPI.get_data(asset_class, after): diff --git a/python/api_quotes/quotes.py b/python/api_quotes/quotes.py index 04b6da09..daa3decb 100644 --- a/python/api_quotes/quotes.py +++ b/python/api_quotes/quotes.py @@ -26,6 +26,8 @@ class MarkitQuoteKind: return SingleNameQuote case "ABS": return BondQuote + case "TRS": + return TRSQuote class MarkitQuote(Deal, table_name=None, deal_type=None): @@ -114,6 +116,32 @@ class BondQuote(MarkitQuote, table_name="markit_bond_quotes", deal_type=None): d.update(base_attributes | additional_attributes) return cls.from_dict(**d) - @property - def message(self): - return QuoteDetails.from_tradeid(self.msg_id) + +@dataclass +class TRSQuote(MarkitQuote, table_name="markit_trs_quotes", deal_type=None): + quoteid: int + msg_id: str + quotesource: str + confidence: int + maturity: datetime.date + identifier: str = None + bidlevel: float = None + asklevel: float = None + nav: float = None + ref: float = None + firmness: firmness = None + funding_benchmark: str = None + quotedate: datetime.datetime = None + + @classmethod + def from_markit_line(cls, d): + base_attributes = super().from_markit_line(d) + additional_attributes = { + "identifier": d["ticker"], + "ref": d.get("reference"), + "nav": d.get("inavparsed"), + "funding_benchmark": d.get("parsedbenchmark"), + "maturity": maturity_dt(d), + } + d.update(base_attributes | additional_attributes) + return cls.from_dict(**d) diff --git a/sql/serenitasdb.sql b/sql/serenitasdb.sql index 994832e7..d50bf2d7 100644 --- a/sql/serenitasdb.sql +++ b/sql/serenitasdb.sql @@ -1294,18 +1294,33 @@ CREATE TABLE markit_bond_quotes ( CREATE TABLE markit_trs_quotes (
quoteid int8 primary key,
identifier text NOT NULL,
- bidprice float,
- askprice float,
+ bidlevel float,
+ asklevel float,
nav float,
ref float,
firmness quote_firmness,
msg_id text NOT NULL,
- maturity date NOT NULL,
+ maturity date,
quotedate timestamptz NOT NULL,
quotesource text NOT NULL,
- confidence int
+ confidence int,
+ funding_benchmark text
);
+CREATE TABLE markit_trs_quotes (
+ quoteid int8 primary key,
+ identifier text NOT NULL,
+ bidlevel float,
+ asklevel float,
+ nav float,
+ ref float,
+ firmness quote_firmness,
+ msg_id text NOT NULL,
+ maturity date NOT NULL,
+ quotedate timestamptz NOT NULL,
+ quotesource text NOT NULL,
+ confidence int );
+
CREATE TABLE hyg_vol_data (
"date" date NOT NULL,
price float8 NULL,
|
