diff options
| -rw-r--r-- | python/markit_red.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/python/markit_red.py b/python/markit_red.py index 09b836e0..630ca472 100644 --- a/python/markit_red.py +++ b/python/markit_red.py @@ -35,17 +35,18 @@ def update_redcodes(conn, fname): with open(os.path.join(common.root, "Tranche_data", "RED_reports", fname)) as fh: et = etree.parse(fh) r = [] - for indextype in ['HY', 'IG', 'EU']: + for indextype in ['HY', 'IG', 'EU', 'XO']: if indextype in ['HY', 'IG']: subfamily = 'CDX.NA.{0}'.format(indextype) - else: + elif indextype in ['EU']: subfamily = 'iTraxx Europe' + elif indextype in ['XO']: + subfamily = 'iTraxx Europe Crossover' for index in et.xpath("./index/indexsubfamily[text()='{0}']/..".format(subfamily)): r.append([indextype] + [index.find(tag).text for tag in \ ['series', 'version', 'redindexcode', 'indexfactor']]) - sqlstr = """UPDATE index_version SET redindexcode=%s - where index=%s and series=%s and version=%s and indexfactor=%s""" + where index=%s and series=%s and version=%s and abs(indexfactor-%s)<0.001""" with conn.cursor() as c: c.executemany(sqlstr, [tuple([e[3], e[0], e[1], e[2], float(e[4])*100]) for e in r]) conn.commit() |
