aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/parse_emails.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/python/parse_emails.py b/python/parse_emails.py
index 5e71380c..edf95a56 100644
--- a/python/parse_emails.py
+++ b/python/parse_emails.py
@@ -66,7 +66,7 @@ def parse_quotedate(fh, date_received):
except ValueError:
continue
else:
- if quotedate.year == 1900: # p='%m/%d %H:%M:%S'
+ if quotedate.year == 1900: # p='%m/%d %H:%M:%S'
quotedate = quotedate.replace(year=date_received.year)
break
else:
@@ -115,7 +115,7 @@ def parse_baml(fh, indextype, series, quotedate, *args):
def parse_baml_block(fh, indextype):
- next(fh) ## skip header
+ next(fh) # skip header
r = []
line = ""
for line in fh:
@@ -124,7 +124,7 @@ def parse_baml_block(fh, indextype):
break
line = re.sub("[/|]", " ", line)
vals = re.sub(" +", " ", line).rstrip().split(" ")
- if len(vals) < 3: ## something went wrong
+ if len(vals) < 3: # something went wrong
line = ""
break
r.append(vals)
@@ -132,8 +132,8 @@ def parse_baml_block(fh, indextype):
def parse_ms_block(fh, indextype):
- line = next(fh) ## skip header
- if line.strip() == "": ## empty block
+ line = next(fh) # skip header
+ if line.strip() == "": # empty block
return None
r = []
for line in fh:
@@ -155,9 +155,10 @@ def parse_ms_block(fh, indextype):
vol = vol.strip()
if indextype == "HY":
try:
- price_vol, vol = vol.replace("[","").replace("]","").split()
+ price_vol, vol = vol.replace("[", "").replace("]", "").split()
except ValueError:
- price_vol, vol, vol_change, be = vol.replace("[","").replace("]","").split()
+ price_vol, vol, vol_change, be = (vol.replace("[", "").
+ replace("]", "").split())
vals += [vol, price_vol]
else:
if " " in vol:
@@ -170,7 +171,7 @@ def parse_ms_block(fh, indextype):
def parse_nomura_block(fh, indextype):
- next(fh) ## skip header
+ next(fh) # skip header
r = []
for line in fh:
line = line.rstrip()
@@ -185,7 +186,7 @@ def parse_nomura_block(fh, indextype):
vol = vol.strip()
vals = [strike, rec_bid, rec_offer, rec_delta,
pay_bid, pay_offer, pay_delta, vol]
- if indextype == "HY": # we don't have price vol
+ if indextype == "HY": # we don't have price vol
vals.append(None)
r.append(vals)
else:
@@ -230,7 +231,7 @@ def parse_gs_block(fh, indextype):
if line == "":
break
vals = line.split()
- if indextype=='HY':
+ if indextype == 'HY':
vals.pop(2)
vals.pop(9)
else:
@@ -238,7 +239,7 @@ def parse_gs_block(fh, indextype):
vals.pop(8)
strike = vals.pop(0)
if indextype == "HY":
- vals.pop(0) #pop the spread
+ vals.pop(0) # pop the spread
pay, pay_delta = vals[:2]
pay_bid, pay_offer = pay.split("/")
rec_bid, rec_offer = vals[2].split("/")
@@ -369,10 +370,10 @@ def write_todb(swaption_stack, index_data):
sql.SQL(", ").join(sql.Identifier(c) for c in columns),
sql.SQL(", ").join(sql.Placeholder() * len(columns)))
conn = dbconn('serenitasdb')
- query = sql.SQL("INSERT INTO {}({}) VALUES({}) " \
+ query = sql.SQL("INSERT INTO {}({}) VALUES({}) "
"ON CONFLICT DO NOTHING RETURNING ref_id")
sql_str = gen_sql_str(query, "swaption_ref_quotes", index_data.columns)
- query = sql.SQL("INSERT INTO {}({}) VALUES({}) " \
+ query = sql.SQL("INSERT INTO {}({}) VALUES({}) "
"ON CONFLICT DO NOTHING")
with conn.cursor() as c:
for t in index_data.itertuples(index=False):