diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/handle_default.py | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/python/handle_default.py b/python/handle_default.py index 161ede62..25f4a7a8 100644 --- a/python/handle_default.py +++ b/python/handle_default.py @@ -1,4 +1,3 @@ -from __future__ import division from db import dbconn import datetime from sys import argv @@ -45,6 +44,28 @@ def update_indexmembers(newids, company_id, conn): and company_id != %s)""", (newid, oldid, company_id)) conn.commit() +def update_redcodes(index_type): + if index_type == 'HY': + index_subfamily = 'CDX.NA.HY' + elif index_type == 'IG': + index_subfamily = 'CDX.NA.IG' + elif index_type == 'EU': + index_subfamily = 'iTraxx Europe' + elif index_type == 'XO': + index_subfamily = 'iTraxx Europe Crossover' + + with conn.cursor() as c: + c.execute( + "UPDATE index_version SET redindexcode=index_version_markit.redindexcode " + "FROM index_version_markit WHERE index_version.series=index_version_markit.series " + "AND index_version.version=index_version_markit.version " + "AND index_version.index=%s " + "AND index_version_markit.indexsubfamily=%s" + "AND index_version.redindexcode IS NULL", + (index_type, index_subfamily)) + conn.commit() + + if __name__=="__main__": if len(argv) == 1: print("""Usage: @@ -58,6 +79,5 @@ For instance: recovery = float(argv[3]) n_issuers = float(argv[4]) recordslist = affected_indices(company_id, serenitasdb) - print(recordslist) newids = create_newindices(recordslist, lastdate, n_issuers, serenitasdb) update_indexmembers(newids, company_id, serenitasdb) |
