diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/clo_universe.py | 11 | ||||
| -rw-r--r-- | python/cusip_universe.py | 5 |
2 files changed, 13 insertions, 3 deletions
diff --git a/python/clo_universe.py b/python/clo_universe.py index 75d8fd72..47dfb65d 100644 --- a/python/clo_universe.py +++ b/python/clo_universe.py @@ -7,10 +7,19 @@ import pdb import re import sys import common +import psycopg2 def convertToNone(s): return None if s=="-" or s=="" or s == "NR" else s +def sanitize_float(intex_float): + intex_float = intex_float.replace(",", "") + if "(" in intex_float: + intex_float = - float(intex_float[1:-1]) + else: + intex_float = float(intex_float) + return intex_float + def upload_data(workdate, conn, cursor): cursor.execute("select dealname, max(\"Latest Update\") from clo_universe group by dealname") deallist = dict(cursor.fetchall()) @@ -42,7 +51,7 @@ def upload_data(workdate, conn, cursor): "CDO Pct of Assets that are Structured Finance Obligations", "CDO Defaulted Security Balance (Reported)"]: if line[key]: - line[key] = line[key].replace(",", "") + line[key] = sanitize_float(line[key]) dealname = line['Deal,Tr/CUSIP/ISIN'] line['defaultedbal'] = line["CDO Defaulted Security Balance (Reported)"] line['Deal CUSIP List'] = line['Deal CUSIP List'].split(",") diff --git a/python/cusip_universe.py b/python/cusip_universe.py index 8e665e14..b389aee0 100644 --- a/python/cusip_universe.py +++ b/python/cusip_universe.py @@ -44,8 +44,9 @@ def upload_data(workdate, conn, cursor): if not curr_date or curr_date[0] < dealupdate[dealname]: deals_to_update.append(dealname) line['updatedate'] = dealupdate[dealname] - for key in ['Curr Balance', 'Orig Balance', 'Orig Attachment Point', 'Curr Attachment Point', - 'Orig Detachment Point', 'Curr Detachment Point', 'Factor', 'Coupon']: + for key in ['Curr Balance', 'Orig Balance', 'Orig Attachment Point', + 'Curr Attachment Point', 'Orig Detachment Point', + 'Curr Detachment Point', 'Factor', 'Coupon', 'Floater Spread']: if line[key]: line[key] = sanitize_float(line[key]) line[key] = convertToNone(line[key]) |
