aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/db.py3
-rw-r--r--python/intex/load_indicative.py9
2 files changed, 9 insertions, 3 deletions
diff --git a/python/db.py b/python/db.py
index 518a1539..e0ae3dd4 100644
--- a/python/db.py
+++ b/python/db.py
@@ -8,9 +8,11 @@ from sqlalchemy import create_engine
from sqlalchemy.engine.url import URL
import numpy as np
+
class InfDateAdapter:
def __init__(self, wrapped):
self.wrapped = wrapped
+
def getquoted(self):
if self.wrapped == datetime.date.max:
return b"'infinity'::date"
@@ -19,6 +21,7 @@ class InfDateAdapter:
else:
return psycopg2.extensions.DateFromPy(self.wrapped).getquoted()
+
def nan_to_null(f, _NULL=AsIs('NULL'),
_Float=psycopg2.extensions.Float):
if not np.isnan(f):
diff --git a/python/intex/load_indicative.py b/python/intex/load_indicative.py
index 3686aa85..84b7f653 100644
--- a/python/intex/load_indicative.py
+++ b/python/intex/load_indicative.py
@@ -1,25 +1,27 @@
import psycopg2
import os
import datetime
-from datetime import date
-import csv, sys, re
+import csv
import pdb
from common import sanitize_float
from db import dbconn
from contextlib import closing
import logging
+import re
+import sys
logger = logging.getLogger(__name__)
def convertToNone(s):
return None if s in ["", "-", "NR"] else s
+
def insert_new_cusip(conn, line):
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',
+ for key in ['Orig Balance', 'Orig Attachment Point', 'Orig Detachment Point',
'Floater Spread/Margin']:
if line[key]:
line[key] = sanitize_float(line[key])
@@ -35,6 +37,7 @@ def insert_new_cusip(conn, line):
logger.error(e)
conn.commit()
+
def upload_cusip_data(conn, filename):
dealupdate = {}
with open( filename, "r") as fh: