aboutsummaryrefslogtreecommitdiffstats
path: root/python/task_server/insert_tranche_quotes.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/task_server/insert_tranche_quotes.py')
-rw-r--r--python/task_server/insert_tranche_quotes.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/python/task_server/insert_tranche_quotes.py b/python/task_server/insert_tranche_quotes.py
index 632304bd..b4053306 100644
--- a/python/task_server/insert_tranche_quotes.py
+++ b/python/task_server/insert_tranche_quotes.py
@@ -18,6 +18,12 @@ def convert(x):
except ValueError:
return None
+def convert_int(x):
+ try:
+ return int(x)
+ except ValueError:
+ return None
+
tenordict = {'3': '3yr', '5': '5yr', '7':'7yr', '10':'10yr'}
runningdict1 = {0: 500, 3:100, 7:100, 15: 25}
runningdict2 = {0: 500, 3:500, 7:500, 10:100, 15:100, 30:100}
@@ -43,10 +49,11 @@ def insert_quotes(year=2015, quote_dir=None):
logger.error("%s: Date in the wrong format", csvdict['Date'])
attach = int(csvdict['Attach'])
+ detach = int(csvdict['Detach'])
series = int(csvdict['Series'])
version = int(csvdict['Version'])
if csvdict['Ref']=='': #no delta quote maybe
- continue
+ logger.info('ref missing')
#common values to all indices
try:
@@ -56,7 +63,7 @@ def insert_quotes(year=2015, quote_dir=None):
'series': series,
'version': version,
'attach': attach,
- 'detach': int(csvdict['Detach']),
+ 'detach': detach,
'tenor': tenordict[csvdict['Tenor']]
}
except KeyError:
@@ -71,7 +78,7 @@ def insert_quotes(year=2015, quote_dir=None):
except TypeError:
trancheupfrontmid = None
running = 0 if series in [9, 10] and attach==10 else 500
- d.update({'indexrefprice': float(csvdict['Ref']),
+ d.update({'indexrefprice': convert(csvdict['Ref']),
'indexrefspread': 375 if series==9 else 500,
'trancheupfrontbid' : trancheupfrontbid,
'trancheupfrontmid' : trancheupfrontmid,
@@ -97,7 +104,7 @@ def insert_quotes(year=2015, quote_dir=None):
else:
running = runningdict2[attach] if series<19 else runningdict1[attach]
try:
- d.update({'indexrefspread': int(float(csvdict['Ref'])),
+ d.update({'indexrefspread': convert_int(csvdict['Ref']),
'trancheupfrontbid' : trancheupfrontbid,
'trancheupfrontmid' : trancheupfrontmid,
'trancheupfrontask' : trancheupfrontask,
@@ -143,7 +150,7 @@ def insert_quotes(year=2015, quote_dir=None):
trancherunning = None
trancheupfrontbid = trancheupfrontmid = trancheupfrontask = 0
- d.update({'indexrefspread': int(float(csvdict['Ref'])),
+ d.update({'indexrefspread': convert_int(csvdict['Ref']),
'trancheupfrontbid' : trancheupfrontbid,
'trancheupfrontmid' : trancheupfrontmid,
'trancheupfrontask' : trancheupfrontask,
@@ -170,7 +177,7 @@ def insert_quotes(year=2015, quote_dir=None):
except TypeError:
trancherunningmid = None
trancheupfrontbid = trancheupfrontmid = trancheupfrontask = 0
- d.update({'indexrefspread': int(float(csvdict['Ref'])),
+ d.update({'indexrefspread': convert_int(csvdict['Ref']),
'trancheupfrontbid' : trancheupfrontbid,
'trancheupfrontmid' : trancheupfrontmid,
'trancheupfrontask' : trancheupfrontask,