aboutsummaryrefslogtreecommitdiffstats
path: root/python/quote_parsing/parse_emails.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/quote_parsing/parse_emails.py')
-rw-r--r--python/quote_parsing/parse_emails.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/python/quote_parsing/parse_emails.py b/python/quote_parsing/parse_emails.py
index defb568f..b206e1f5 100644
--- a/python/quote_parsing/parse_emails.py
+++ b/python/quote_parsing/parse_emails.py
@@ -156,8 +156,9 @@ def parse_baml_block(fh, indextype):
return makedf(r, indextype, "BAML"), line
-def parse_bnp_block(fh, indextype):
- next(fh) # skip header
+def parse_bnp_block(fh, indextype, skip_header=True):
+ if skip_header:
+ next(fh) # skip header
r = []
for line in fh:
line = line.strip()
@@ -532,12 +533,15 @@ def parse_bnp(fh, indextype, series, quotedate, expiration_dates):
fwd_index = []
d = {"quotedate": quotedate, "index": indextype, "series": series}
regex = (
- r"Ref\s(?P<ref>[\d.]+) - (?P<expiry>\w{3}\d{2}) - Fwd\s(?P<fwdspread>[\d.]+)"
+ r"Ref\s(?P<ref>[\d.]+) -\s+(?P<expiry>\w{3}\d{2}) - Fwd\s(?P<fwdspread>[\d.]+)"
)
pat = re.compile(regex)
for line in fh:
line = line.strip()
if line.startswith("Ref"):
+ c = line.find("Strike")
+ if c != -1:
+ line = line[:c].rstrip()
m = pat.match(line)
if m:
d.update(**m.groupdict())
@@ -546,7 +550,7 @@ def parse_bnp(fh, indextype, series, quotedate, expiration_dates):
d for d in expiration_dates if d.month == expiry_month
)
fwd_index.append(d.copy())
- option_stack[d["expiry"]] = parse_bnp_block(fh, indextype)
+ option_stack[d["expiry"]] = parse_bnp_block(fh, indextype, c == -1)
else:
logger.error("Can't parse expiry line:", line, "filename:", fh.name)
fwd_index = pd.DataFrame.from_records(fwd_index, index="quotedate")