aboutsummaryrefslogtreecommitdiffstats
path: root/python/load_intex_collateral.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/load_intex_collateral.py')
-rw-r--r--python/load_intex_collateral.py26
1 files changed, 17 insertions, 9 deletions
diff --git a/python/load_intex_collateral.py b/python/load_intex_collateral.py
index 00b6f027..33c59c0a 100644
--- a/python/load_intex_collateral.py
+++ b/python/load_intex_collateral.py
@@ -7,10 +7,12 @@ import pdb
import common
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', 'Life Floor']
+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', 'Life Floor', 'Reinvest Collat']
def convertToNone(s):
return None if s=='' else s
@@ -56,8 +58,11 @@ def upload_data(workdate, conn, cursor):
try:
# make sure the string is utf8 safe
line['Issuer'] = line['Issuer'].decode('windows-1252')
- if line['Issuer']=='' or line['Issuer'].lower() == 'dummy':
- break
+ if line['Reinvest Collat'].upper() == 'Y' or line['Issuer'] == '' \
+ or line['Issuer'].lower() == 'dummy':
+ # assume it's a reinvestment asset
+ line['Reinvest Collat'] = True
+ line['Issuer'] = 'Reinvestment Asset'
except AttributeError as detail:
print dealname
if 'Spread' in missingfields:
@@ -70,10 +75,12 @@ def upload_data(workdate, conn, cursor):
if line['Life Floor'] == "No limit":
line['Life Floor'] = 0
elif line['Life Floor']:
- line['Life Floor'] = float(line['Life Floor']) - float(line['Spread'])
+ try:
+ line['Life Floor'] = float(line['Life Floor']) - float(line['Spread'])
+ except ValueError:
+ line['Life Floor'] = float('Nan')
r = [convertToNone(line[field]) for field in fields]
data.append(r)
-
cursor.execute( "select distinct(updatedate) from et_collateral where dealname='{0}'".format(dealname))
old_update_dates = [date[0] for date in cursor.fetchall()]
@@ -103,7 +110,8 @@ def upload_data(workdate, conn, cursor):
"Maturity", "AssetSubtype", "AssetType", "GrossCoupon",
"Spread", "Frequency", "NextPaydate", "SecondLien", "LoanXID",
"Cusip", "IntexPrice", "IntexPriceSource", "IntexPriceDate",
- "FixedOrFloat", "DefaultedFlag", "CovLite", "isCDO", "Liborfloor"]
+ "FixedOrFloat", "DefaultedFlag", "CovLite", "isCDO",
+ "Liborfloor", "ReinvFlag"]
sqlstr = "INSERT INTO ET_COLLATERAL({0}) VALUES({1})".format(",".join(sql_fields),
",".join(["%s"] * len(sql_fields)))