import psycopg2 import datetime import pdb conn = psycopg2.connect(database="mlpdb") cursor = conn.cursor() # offset=182950 # index = [[offset, 'EU', 19, psycopg2.Date(2016, 06, 20), 'Y3', 100, 0], # [offset, 'EU', 19, psycopg2.Date(2018, 06, 20), 'Y5', 100, 0], # [offset, 'EU', 19, psycopg2.Date(2020, 06, 20), 'Y7', 100, 0], # [offset, 'EU', 19, psycopg2.Date(2023, 06, 20), 'Y10', 100, 0]] # index = [[offset, 'HY', 17, psycopg2.Date(2014, 12, 20), 'Y3', 96, 0.027075], # [offset, 'HY', 17, psycopg2.Date(2016, 12, 20), 'Y5', 96, 0.027075], # [offset, 'HY', 17, psycopg2.Date(2018, 12, 20), 'Y7', 96, 0.027075], # [offset+10, 'HY', 19, psycopg2.Date(2015, 12, 20), 'Y3', 100, 0], # [offset+10, 'HY', 19, psycopg2.Date(2017, 12, 20), 'Y5', 100, 0], # [offset+10, 'HY', 19, psycopg2.Date(2019, 12, 20), 'Y7', 100, 0], # [offset+20, 'IG', 19, psycopg2.Date(2015, 12, 20), 'Y3', 100, 0], # [offset+20, 'IG', 19, psycopg2.Date(2017, 12, 20), 'Y5', 100, 0], # [offset+20, 'IG', 19, psycopg2.Date(2019, 12, 20), 'Y7', 100, 0], # [offset+20, 'IG', 19, psycopg2.Date(2022, 12, 20), 'Y10', 100, 0], # [offset+30, 'HY', 15, psycopg2.Date(2015, 12, 20), 'Y3', 96, 0.026375], # [offset+30, 'HY', 15, psycopg2.Date(2013, 12, 20), 'Y5', 96, 0.026375], # [offset+30, 'HY', 15, psycopg2.Date(2013, 12, 20), 'Y7', 96, 0.026375], # ]; # for line in index: # cursor.execute("INSERT INTO index_desc VALUES({0})".format(",".join(["%s"] * 7)), line) # conn.commit() # cursor.close() # conn.close() # index = [[offset, 'HY', 17, psycopg2.Date(2014, 12, 20), 'Y3', 96, 0.027075], # [offset, 'HY', 17, psycopg2.Date(2016, 12, 20), 'Y5', 96, 0.027075], # [offset, 'HY', 17, psycopg2.Date(2016, 12, 20), 'Y7', 96, 0.027075], # [offset+10, 'HY', 19, psycopg2.Date(2015, 12, 20), 'Y3', 100, 0], # [offset+10, 'HY', 19, psycopg2.Date(2017, 12, 20), 'Y5', 100, 0], # [offset+10, 'HY', 19, psycopg2.Date(2017, 12, 20), 'Y7', 100, 0], # [offset+20, 'IG', 19, psycopg2.Date(2017, 12, 20), 'Y3', 100, 0], # [offset+20, 'IG', 19, psycopg2.Date(2017, 12, 20), 'Y5', 100, 0], # [offset+20, 'IG', 19, psycopg2.Date(2019, 12, 20), 'Y7', 100, 0], # [offset+20, 'IG', 19, psycopg2.Date(2022, 12, 20), 'Y10', 100, 0], # [offset+30, 'HY', 15, psycopg2.Date(2015, 12, 20), 'Y3', 96, 0.026375], # [offset+30, 'HY', 15, psycopg2.Date(2013, 12, 20), 'Y5', 96, 0.026375], # [offset+30, 'HY', 15, psycopg2.Date(2013, 12, 20), 'Y7', 96, 0.026375], # ]; # igbasketid = 182920 # igattach = [0, 3, 7, 15, 100] # igtenors = ['Y3', 'Y5', 'Y7', 'Y10'] # for tenor in igtenors: # for i, (attach, detach) in enumerate(zip(igattach[:-1], igattach[1:])): # tranche = [igbasketid+i, igbasketid, tenor, attach, detach] # cursor.execute("INSERT INTO tranche_desc VALUES(%s, %s, %s, %s, %s)", tranche) # hyattach = [0, 15, 25, 35, 100] # hytenors = ['Y3', 'Y5', 'Y7'] # for basketid in [182900, 182930, 182910]: # for tenor in hytenors: # for i, (attach, detach) in enumerate(zip(hyattach[:-1], hyattach[1:])): # tranche = [basketid+i, basketid, tenor, attach, detach] # cursor.execute("INSERT INTO tranche_desc VALUES(%s, %s, %s, %s, %s)", tranche) euattach = [0, 3, 6, 9, 12, 22, 100] eutenors = ['Y3', 'Y5', 'Y7'] eubasketid = 182950 for tenor in eutenors: for i, (attach, detach) in enumerate(zip(euattach[:-1], euattach[1:])): tranche = [eubasketid+i, eubasketid, tenor, attach, detach] cursor.execute("INSERT INTO tranche_desc VALUES(%s, %s, %s, %s, %s)", tranche) conn.commit() cursor.close() conn.close()