diff options
Diffstat (limited to 'python/process_queue.py')
| -rw-r--r-- | python/process_queue.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/python/process_queue.py b/python/process_queue.py index e3a85cc6..40b6cbd4 100644 --- a/python/process_queue.py +++ b/python/process_queue.py @@ -55,7 +55,8 @@ def bbg_process(cursor, session, trade): cursor.execute("SELECT FROM securities WHERE identifier=%s", (trade['identifier'],)) fields = ["MTG_FACTOR_SET_DT", "INT_ACC"] if not cursor.fetchone(): - fields += ["MATURITY", "CRNCY", "NAME", "MTG_FACE_AMT"] + fields += ["MATURITY", "CRNCY", "NAME", "MTG_FACE_AMT", "FLOATER", + "FLT_SPREAD", "CPN", "CPN_FREQ", "FIRST_CPN_DT", "MTG_PAY_DELAY"] bbg_id = (trade['cusip'] or trade['isin']) + ' Mtge' bbg_type = 'Mtge' @@ -77,10 +78,16 @@ def bbg_process(cursor, session, trade): cursor.execute("UPDATE bonds SET principal_payment = %s, accrued_payment = %s " "WHERE id = %s", (principal_payment, accrued_payment, trade['id'])) if len(fields) > 2: #we don't have the data in the securities table - sqlstr = "INSERT INTO securities VALUES({0})".format(",".join(["%s"] * 9)) + sqlstr = "INSERT INTO securities VALUES({0})".format(",".join(["%s"] * 15)) + isfloater = bbg_data['FLOATER'] == 'Y' cursor.execute(sqlstr, (trade['identifier'], trade['cusip'], trade['isin'], - bbg_data['NAME'], bbg_data['MTG_FACE_AMT'], bbg_data['MATURITY'], - bbg_data['CRNCY'], bbg_type, trade['asset_class'])) + bbg_data['NAME'], bbg_data.get('MTG_FACE_AMT'), + bbg_data.get('MATURITY'), isfloater, + bbg_data.get('FLT_SPREAD') if isfloater else None, + bbg_data.get('CPN') if not isfloater else None, + bbg_data.get('CPN_FREQ'), bbg_data.get('FIRST_CPN_DT'), + int(bbg_data.get('MTG_PAY_DELAY', 0)), + bbg_data.get('CRNCY'), bbg_type, trade['asset_class'])) #mark it at buy price if trade.buysell: sqlstr = "INSERT INTO marks VALUES(%s, %s, %s)" |
