aboutsummaryrefslogtreecommitdiffstats
path: root/python/bbg_newids.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/bbg_newids.py')
-rw-r--r--python/bbg_newids.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/python/bbg_newids.py b/python/bbg_newids.py
index 9f670eab..241e57a8 100644
--- a/python/bbg_newids.py
+++ b/python/bbg_newids.py
@@ -1,11 +1,12 @@
-from sqlalchemy import create_engine, MetaData
+from sqlalchemy import create_engine, MetaData, select, Column, func, bindparam
+from collections import defaultdict
import pandas as pd
from db import conn
import numpy as np
from bbg_helpers import init_bbg_session, retreive_data, process_msgs
from psycopg2 import IntegrityError
-engine = create_engine('postgresql://et_user@debian/ET', echo=True)
+engine = create_engine('postgresql://et_user@debian/ET')
meta = MetaData(bind=engine)
meta.reflect(only = ['bloomberg_corp_ref', 'bloomberg_corp', 'deal_indicative'])
@@ -57,10 +58,10 @@ df.reset_index(inplace=True)
df['loanxid'] = mapping.loanxid
df.dropna(subset=['ID_BB_UNIQUE'], inplace=True)
df.loc[df.LN_TRANCHE_SIZE.isnull(),'LN_TRANCHE_SIZE'] = df[df.LN_TRANCHE_SIZE.isnull()].AMT_ISSUED.values
-df.set_index('ID_BB_UNIQUE', inplace=True, verify_integrity=True)
+df.drop_duplicates(subset='ID_BB_UNIQUE', inplace=True)
+df.set_index('ID_BB_UNIQUE', inplace=True, drop=False)
currentdata.set_index('id_bb_unique', inplace=True)
df = df.ix[df.index.difference(currentdata.index)]
-df.drop_duplicates(subset='ID_BB_UNIQUE', inplace=True)
sql_colnames = [c.name for c in bloomberg_corp_ref.columns]
to_insert = df[['ID_BB_UNIQUE', 'ID_CUSIP', 'ISSUER', 'MATURITY', 'CPN', 'CPN_TYP',
'CPN_FREQ', 'FLT_SPREAD', 'LIBOR_FLOOR', 'LN_TRANCHE_SIZE', 'LN_COVENANT_LITE',