diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/load_intex_collateral.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/python/load_intex_collateral.py b/python/load_intex_collateral.py index 8afc97b5..49990155 100644 --- a/python/load_intex_collateral.py +++ b/python/load_intex_collateral.py @@ -10,7 +10,7 @@ import sys fields = ['Asset Name', 'Issuer', 'Contributed Balance', 'Maturity Date', 'Asset Subtype', \ 'Asset Type', 'Gross Coupon', 'Spread', 'Frequency', 'Next Paydate', 'Second Lien', \ 'LoanX ID', 'CUSIP', 'Market Price', 'Market Price Source', 'Price Date', 'Fixed or Float', \ - 'Defaulted Flag', 'Security Sub-Category', 'Structured Finance Security'] + 'Defaulted Flag', 'Security Sub-Category', 'Structured Finance Security', 'Life Floor'] def convertToNone(s): return None if s=='' else s @@ -59,12 +59,18 @@ def upload_data(workdate, conn, cursor): break except AttributeError as detail: print dealname + if 'Spread' in missingfields: + line['Spread'] = line['Gross Margin'] for field in ['Spread', 'Gross Coupon', 'Market Price', 'Contributed Balance']: if line[field]: line[field] = sanitize_float(line[field]) - r = [convertToNone(line[field]) for field in fields] + #we store the Libor FLoor in the database, so Life Floor is really Libor Floor + if line['Life Floor'] == "No limit": + line['Life Floor'] = 0 + elif line['Life Floor']: + line['Life Floor'] = float(line['Life Floor']) - float(line['Spread']) data.append(r) cursor.execute( "select distinct(updatedate) from et_collateral where dealname='{0}'".format(dealname)) @@ -96,7 +102,7 @@ def upload_data(workdate, conn, cursor): "Maturity", "AssetSubtype", "AssetType", "GrossCoupon", "Spread", "Frequency", "NextPaydate", "SecondLien", "LoanXID", "Cusip", "IntexPrice", "IntexPriceSource", "IntexPriceDate", - "FixedOrFloat", "DefaultedFlag", "CovLite", "isCDO"] + "FixedOrFloat", "DefaultedFlag", "CovLite", "isCDO", "Liborfloor"] sqlstr = "INSERT INTO ET_COLLATERAL({0}) VALUES({1})".format(",".join(sql_fields), ",".join(["%s"] * len(sql_fields))) @@ -113,6 +119,8 @@ def upload_data(workdate, conn, cursor): row[0] = row[0] + "_tag_" + str(tag) tag = tag+1 cursor.execute(sqlstr, (dealname, updatedate) + tuple(row)) + except TypeError: + pdb.set_trace() conn.commit() if __name__ == "__main__": @@ -124,4 +132,3 @@ if __name__ == "__main__": common.cursor.close() common.conn.close() print "done" - |
