aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/intex/load_indicative.py29
1 files changed, 14 insertions, 15 deletions
diff --git a/python/intex/load_indicative.py b/python/intex/load_indicative.py
index 50e29557..0686ca92 100644
--- a/python/intex/load_indicative.py
+++ b/python/intex/load_indicative.py
@@ -14,9 +14,10 @@ def convertToNone(s):
return None if s in ["", "-", "NR"] else s
def insert_new_cusip(conn, line):
- line['Pari-Passu Tranche'] = line['Pari-Passu Tranche'].split(",")
- to_insert = (line['CUSIP'], line['ISIN'], line['Bloomberg Ticker'], dealname,
- tranche, line['Pari-Passu Tranche'])
+ if line['Pari-Passu Tranches']:
+ line['Pari-Passu Tranches'] = line['Pari-Passu Tranches'].split(",")
+ to_insert = (line['CUSIP'], line['ISIN'], line['Bloomberg Ticker'],
+ line['dealname'], line['tranche'], line['Pari-Passu Tranches'])
for key in ['Orig Balance', 'Orig Attachment Point','Orig Detachment Point',
'Floater Spread/Margin']:
if line[key]:
@@ -24,8 +25,8 @@ def insert_new_cusip(conn, line):
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'])
- sqlstr = "INSERT INTO cusip_ref VALUES({0})".format(",".join(["%s"]*12))
+ line['Floater Index'], line['Floater Spread/Margin'], line['Type'])
+ sqlstr = "INSERT INTO cusip_ref VALUES({0})".format(",".join(["%s"]*13))
with conn.cursor() as c:
try:
c.execute(sqlstr, to_insert)
@@ -63,19 +64,17 @@ def upload_cusip_data(conn, filename):
sqlstring = "SELECT cusip FROM cusip_ref WHERE cusip=%s"
with conn.cursor() as c:
c.execute(sqlstring, (line['CUSIP'],))
- if c is None:
- try:
- insert_new_cusip(conn, line)
- except ValueError:
- continue
+ r = c.fetchone()
+ if r is None:
+ try:
+ insert_new_cusip(conn, line)
+ except ValueError:
+ continue
sqlstring = "SELECT max(updatedate) FROM cusip_update WHERE cusip = %s"
with conn.cursor() as c:
c.execute(sqlstring, (line['CUSIP'],))
- try:
- curr_date, = c.fetchone()
- except TypeError:
- curr_date = dealupdate[dealname] - 1
- if curr_date < dealupdate[dealname]:
+ curr_date, = c.fetchone()
+ if curr_date is None or curr_date < dealupdate[dealname]:
try:
for key in ['Curr Balance', 'Curr Attachment Point (def at MV)',
'Curr Detachment Point (def at MV)', 'Factor', 'Coupon']: