diff options
Diffstat (limited to 'python/process_queue.py')
| -rw-r--r-- | python/process_queue.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/python/process_queue.py b/python/process_queue.py index 719c003a..a1cc8ae1 100644 --- a/python/process_queue.py +++ b/python/process_queue.py @@ -53,10 +53,12 @@ def build_line(obj): def bbg_process(cursor, session, trade): fields = ["MTG_FACTOR_SET_DT", "INT_ACC"] - cursor.execute("SELECT identifier FROM securities WHERE identifier=%s", (trade['identifier'],)) + cursor.execute("SELECT identifier FROM securities WHERE identifier=%s", + (trade['identifier'],)) if not cursor.fetchone(): fields += ["MATURITY", "CRNCY", "NAME", "MTG_FACE_AMT", "FLOATER", - "FLT_SPREAD", "CPN", "CPN_FREQ", "FIRST_CPN_DT", "MTG_PAY_DELAY"] + "FLT_SPREAD", "CPN", "CPN_FREQ", "FIRST_CPN_DT", "MTG_PAY_DELAY", + "DAY_CNT_DES"] bbg_id = (trade['cusip'] or trade['isin']) + ' Mtge' bbg_type = 'Mtge' @@ -81,6 +83,10 @@ def bbg_process(cursor, session, trade): sqlstr = "INSERT INTO securities VALUES({0})".format(",".join(["%s"] * 15)) isfloater = bbg_data['FLOATER'] == 'Y' pay_delay = bbg_data.get('MTG_PAY_DELAY', 0) + day_count = bbg_data.get('DAY_CNT_DES') + m = re.match("[^(\s]+", day_count) + if m: + day_count = m.group(0) if isinstance(pay_delay, str): pay_delay = int(pay_delay.split(' ')[0]) cursor.execute(sqlstr, (trade['identifier'], trade['cusip'], trade['isin'], @@ -88,8 +94,8 @@ def bbg_process(cursor, session, trade): 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'), - pay_delay, + bbg_data.get('CPN_FREQ'), day_count, + bbg_data.get('FIRST_CPN_DT'), pay_delay, bbg_data.get('CRNCY'), bbg_type, trade['asset_class'])) #mark it at buy price if trade.buysell: |
