diff options
| -rw-r--r-- | python/load_refentity.py | 22 | ||||
| -rw-r--r-- | sql/serenitasdb.sql | 9 |
2 files changed, 24 insertions, 7 deletions
diff --git a/python/load_refentity.py b/python/load_refentity.py index 4b3e2864..ea9ca6bd 100644 --- a/python/load_refentity.py +++ b/python/load_refentity.py @@ -31,7 +31,10 @@ def dispatch_parsing(col, uselist): else: return Json(todict(col, uselist)) else: - return col.text + if col.tag == "holdco": + return col.text == "TRUE" + else: + return col.text def insert_refentity(fname): tree = etree.parse(fname, @@ -41,7 +44,8 @@ def insert_refentity(fname): 'entitycusip', 'lei', 'entitytype', 'jurisdiction', 'depthlevel', 'markitsector', 'isdatradingdefinition', 'recorddate', 'ratings', 'entityform', 'companynumber', 'alternativenames', - 'isdatransactiontypes', 'validto', 'validfrom', 'events'] + 'isdatransactiontypes', 'validto', 'validfrom', 'events', + 'holdco', 'country',] # these are tags which enclose a list uselist = set(['events', 'isdatransactiontypes', 'nextredentitycodes', 'prevredentitycodes', 'isdatransactiontypes', 'tiers', 'auctions']) @@ -69,7 +73,8 @@ def insert_refobligation(fname): names_redpair = ['redpaircode', 'role', 'referenceentity', 'redentitycode', 'tier', 'pairiscurrent', 'pairvalidfrom', 'pairvalidto', 'ticker', 'ispreferred', 'preferreddate', 'indexconstituents', - 'recorddate', 'publiccomments', 'myticker'] + 'recorddate', 'publiccomments', 'myticker', + 'subordinationtype', 'holdco', 'preferredremovaldate'] names_refobligation = ['obligationname', 'prospectusinfo', 'refentities', 'type', 'isconvert', 'isperp', 'coupontype', 'ccy', 'maturity', 'issuedate', 'coupon', 'isin', 'cusip', 'event'] @@ -84,6 +89,14 @@ def insert_refobligation(fname): ",".join(["%s"] * len(names_refobligation)), ",".join(f"{name}=EXCLUDED.{name}" for name in names_refobligation[1:]))) skipfirst = True + def simple_parse(e): + if e.tag == 'indexconstituents': + return [ic.text for ic in e] + elif e.tag == 'holdco': + return e.text == "TRUE" + else: + return e.text + with conn.cursor() as c: for child in tree.getroot(): if skipfirst: @@ -92,8 +105,7 @@ def insert_refobligation(fname): d = {col.tag: col if len(col) else col.text for col in child} with conn.cursor() as c2: for el in d['refentities']: - redpair = {e.tag: [ic.text for ic in e] if e.tag == 'indexconstituents' - else e.text for e in el} + redpair = {e.tag: simple_parse(e) for e in el} c2.execute(redpair_insert, [redpair.get(name) for name in names_redpair]) conn.commit() d['refentities'] = [el.text for el in d['refentities'].iterfind('.//redpaircode')] diff --git a/sql/serenitasdb.sql b/sql/serenitasdb.sql index 925e47c7..8b5b03d8 100644 --- a/sql/serenitasdb.sql +++ b/sql/serenitasdb.sql @@ -223,7 +223,9 @@ CREATE TABLE IF NOT EXISTS RefEntity( isdatransactiontypes jsonb,
validto date,
validfrom date,
- events jsonb);
+ events jsonb,
+ holdco bool,
+ country varchar(3));
CREATE TABLE IF NOT EXISTS RefObligation(
id serial PRIMARY KEY,
@@ -257,7 +259,10 @@ CREATE TABLE IF NOT EXISTS RedPairMapping( indexconstituents text[],
recorddate date NOT NULL,
publiccomments text,
- myticker text);
+ myticker text,
+ subordinationtype text,
+ holdco bool,
+ preferredremovaldate date);
CREATE TYPE curr AS ENUM('USD', 'EUR', 'JPY', 'GBP', 'CAD');
CREATE TYPE sen AS ENUM('Senior', 'Subordinated');
|
