diff options
| -rw-r--r-- | python/intex/common.py | 3 | ||||
| -rw-r--r-- | python/intex/load_indicative.py | 25 |
2 files changed, 13 insertions, 15 deletions
diff --git a/python/intex/common.py b/python/intex/common.py index 65bae4a0..db7f5e89 100644 --- a/python/intex/common.py +++ b/python/intex/common.py @@ -1,6 +1,3 @@ -import os - - def sanitize_float(intex_float): try: intex_float = intex_float.replace(",", "") diff --git a/python/intex/load_indicative.py b/python/intex/load_indicative.py index 53124801..c9bc5bfd 100644 --- a/python/intex/load_indicative.py +++ b/python/intex/load_indicative.py @@ -28,22 +28,25 @@ def insert_new_cusip(conn, line): line["tranche"], line["Pari-Passu Tranches"], ) - for key in [ + for key in ( "Orig Balance", "Orig Attachment Point", "Orig Detachment Point", "Floater Spread/Margin", - ]: - if line[key]: - line[key] = sanitize_float(line[key]) - line[key] = convertToNone(line[key]) + "Coupon", + ): + if key in line: + if line[key]: + line[key] = sanitize_float(line[key]) + line[key] = convertToNone(line[key]) + to_insert += ( line["Orig Balance"], line.get("Orig Moody"), line["Orig Attachment Point"], line["Orig Detachment Point"], - line["Floater Index"], - line["Floater Spread/Margin"], + line.get("Floater Index"), + line.get("Floater Spread/Margin", line["Coupon"]), line["Type"], ) sqlstr = ( @@ -55,7 +58,7 @@ def insert_new_cusip(conn, line): with conn.cursor() as c: try: c.execute(sqlstr, to_insert) - cusip_id, = c.fetchone() + (cusip_id,) = c.fetchone() return cusip_id except psycopg2.DataError as e: logger.error(e) @@ -66,8 +69,6 @@ def upload_cusip_data(conn, filename): dealupdate = {} with open(filename, "r") as fh: dr = csv.DictReader(fh, dialect="excel-tab") - data = [] - deals_to_update = [] for line in dr: if "ISIN" not in line: @@ -88,7 +89,7 @@ def upload_cusip_data(conn, filename): (dealname,), ) try: - dealupdate[dealname], = c.fetchone() + (dealupdate[dealname],) = c.fetchone() except TypeError: logging.error(f"deal:{dealname} not in database") continue @@ -106,7 +107,7 @@ def upload_cusip_data(conn, filename): sqlstring = "SELECT max(updatedate) FROM cusip_update WHERE cusip_id = %s" with conn.cursor() as c: c.execute(sqlstring, (cusip_id,)) - curr_date, = c.fetchone() + (curr_date,) = c.fetchone() if curr_date is None or curr_date < dealupdate[dealname]: try: for key in [ |
