aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/quote_parsing/parse_emails.py32
1 files changed, 17 insertions, 15 deletions
diff --git a/python/quote_parsing/parse_emails.py b/python/quote_parsing/parse_emails.py
index ba203c0f..fbeb2868 100644
--- a/python/quote_parsing/parse_emails.py
+++ b/python/quote_parsing/parse_emails.py
@@ -3,6 +3,7 @@ import re
import psycopg2.sql as sql
import datetime
import pickle
+import traceback
from . import logger
from functools import partial, lru_cache
from pathlib import Path
@@ -340,21 +341,21 @@ def parse_gs_block(fh, indextype):
continue
if line.startswith("Expiry") or line.startswith("Assumes"):
break
+ line = line.replace("|", " ")
vals = line.split()
- if indextype == "HY":
- vals.pop(2)
- vals.pop(9)
- else:
- vals.pop(1)
- vals.pop(8)
strike = vals.pop(0)
- if indextype == "HY":
+ if indextype == "HY" and "/" not in vals[0]:
vals.pop(0) # pop the spread
pay, pay_delta = vals[:2]
- pay_bid, pay_offer = pay.split("/")
- rec_bid, rec_offer = vals[2].split("/")
- vol = vals[3]
- tail = vals[6]
+ pay_bid, pay_offer = pay.split("/", 1)
+ rec_bid, rec_offer = vals[2].split("/", 1)
+ if rec_offer.count(".") == 2:
+ rec_offer, vol = rec_offer[:6], rec_offer[6:]
+ print(rec_offer, vol)
+ tail = vals[5]
+ else:
+ vol = vals[3]
+ tail = vals[6]
vals = [strike, rec_bid, rec_offer, None, pay_bid, pay_offer, pay_delta, vol]
if indextype == "HY":
vals.append(None)
@@ -493,9 +494,10 @@ def parse_gs(fh, index_desc):
)
try:
option_stack[expiry], line = parse_gs_block(fh, index_desc["index"])
- except IndexError:
- logger.error(f"Something went wrong wifh file {Path(fh.name).stem}")
- break
+ except IndexError as e:
+ logger.debug(traceback.format_exc())
+ logger.error(f"Something is wrong with file {Path(fh.name).stem}")
+ raise RuntimeError()
else:
logger.error("Can't parse expiry line:", line)
elif line.startswith("Assumes"):
@@ -580,7 +582,7 @@ def parse_bnp(fh, index_desc):
# subject_baml = re.compile(r"(?:Fwd:){0,2}(?:BAML )?(\D{2})(\d{1,2})\s")
subject_baml = re.compile(r"(?:Fwd:){0,2}(?:BofA )?(\D{2})(\d{1,2}).*Ref[^\d]*([\d.]+)")
subject_ms = re.compile(
- r"[^$]*\$\$ MS CDX OPTIONS: (IG|HY)(\d{2})[^-]*- REF[^\d]*([\d.]+)"
+ r"[^$]*\${1,2} MS CDX OPTIONS: (IG|HY)(\d{2})[^-]*- REF[^\d]*([\d.]+)"
)
subject_nom = re.compile(r"(?:Fwd:)?CDX (IG|HY)(\d{2}).*- REF:[^\d]*([\d.]+)")
subject_gs = re.compile(r"(?:FW: |Fwd: )?GS (IG|HY)(\d{2}) 5y.*- Ref [^\d]*([\d.]+)")