aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/cusip_universe.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/python/cusip_universe.py b/python/cusip_universe.py
index 91d9aa4f..b8d2d100 100644
--- a/python/cusip_universe.py
+++ b/python/cusip_universe.py
@@ -12,14 +12,13 @@ def convertToNone(s):
return None if s=="" else s
def sanitize_float(intex_float):
+ if intex_float.count(".") > 1:
+ raise ValueError
intex_float = intex_float.replace(",", "")
if "(" in intex_float:
intex_float = - float(intex_float[1:-1])
else:
- try:
- intex_float = float(intex_float)
- except ValueError:
- pdb.set_trace()
+ intex_float = float(intex_float)
return intex_float
def upload_data(workdate, conn, cursor):
@@ -50,12 +49,16 @@ def upload_data(workdate, conn, cursor):
if dealname not in deals_to_update:
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', 'Floater Spread']:
- if line[key]:
- line[key] = sanitize_float(line[key])
- line[key] = convertToNone(line[key])
+ try:
+ 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])
+ except ValueError:
+ continue
+
if "Curr Moody" not in line:
line['Curr Moody'] = line['Orig Moody']
sqlstring = "INSERT INTO cusip_universe(Cusip, ISIN, dealname, tranche, " \