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.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/python/quote_parsing/parse_emails.py b/python/quote_parsing/parse_emails.py
index f42dc9f5..5b307737 100644
--- a/python/quote_parsing/parse_emails.py
+++ b/python/quote_parsing/parse_emails.py
@@ -548,7 +548,10 @@ def parse_barc_block(fh, indextype):
option_data, pay_data, delta, rec_data, vol_data = [
item.strip() for item in line.split("|")
]
- strike, _ = option_data.split(" ")
+ try:
+ strike, _ = option_data.split(" ")
+ except ValueError: # Spread is not always provided
+ strike = option_data
vol = vol_data.split(" ")[0]
vals = [strike, *rec_data.split("/"), None, *pay_data.split("/"), delta, vol]
if indextype == "HY":
@@ -863,16 +866,20 @@ def parse_gs_eu(fh, index_desc):
def parse_barc(fh, index_desc):
option_stack = {}
fwd_index = []
- regex = r"(?P<expiry>\d{1,2}[A-Za-z]{3}\d{2}) \(Fwd\s+(?P<fwdprice>\d+\.\d+)"
+ regex = r"(?P<expiry>\d{1,2}[A-Za-z]{3}\d{2}) \(Fwd\s+(?P<fwd>\d+\.\d+)[\s,]+(?P<fwdspread>\d+\.\d+)?"
pat = re.compile(regex)
line = next(fh).strip()
while True:
- if "00Jan00" in line:
+ if ("00Jan00" in line) or ("(Fwd , FwdDV01 )" in line):
break
elif "(" in line:
if m := pat.match(line):
d = m.groupdict()
d["expiry"] = pd.to_datetime(d["expiry"], format="%d%b%y")
+ if d["fwdspread"]:
+ d["fwdprice"] = d.pop("fwd")
+ else:
+ d["fwdspread"] = d.pop("fwd")
fwd_index.append({**index_desc, **d})
(
option_stack[