aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/parse_emails.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/python/parse_emails.py b/python/parse_emails.py
index 65a8b091..f9ad9d9c 100644
--- a/python/parse_emails.py
+++ b/python/parse_emails.py
@@ -5,7 +5,7 @@ import pdb
from download_emails import update_emails
import datetime
-def makedf(r, indextype, ref):
+def makedf(r, indextype):
if indextype=='IG':
cols = ['Strike', 'RecBid', 'RecOffer', 'DeltaRec', 'PayBid',
'PayOffer', 'DeltaPay', 'Vol', 'Gamma']
@@ -13,7 +13,6 @@ def makedf(r, indextype, ref):
cols = ['Strike', 'RecBid', 'RecOffer', 'DeltaRec', 'PayBid',
'PayOffer', 'DeltaPay', 'Vol', 'PxVol', 'Gamma']
df = pd.DataFrame.from_records(r, columns = cols)
- df['ref'] = ref
for col in ['DeltaRec', 'DeltaPay', 'Vol', 'PxVol', 'Gamma']:
if col in df:
df[col] = df[col].str.strip("%").astype('float')/100
@@ -60,7 +59,7 @@ def parse_email(email_path):
try:
d = m.groupdict()
d['quotedate'] = quotedate
- d['index'] = indextype
+ d['indextype'] = indextype
d['series'] = series
d['expiry'] = pd.to_datetime(d['expiry'], format='%d-%b-%y')
except AttributeError:
@@ -77,13 +76,13 @@ def parse_email(email_path):
r.append(vals)
continue
else:
- option_stack[d['expiry']] = makedf(r, indextype, d['ref'])
+ option_stack[d['expiry']] = makedf(r, indextype)
fwd_index.append(d)
flag = False
r = []
continue
if flag:
- option_stack[d['expiry']] = makedf(r, indextype, d['ref'])
+ option_stack[d['expiry']] = makedf(r, indextype)
fwd_index.append(d)
if option_stack:
fwd_index = pd.DataFrame.from_records(fwd_index,
@@ -103,13 +102,13 @@ if __name__=="__main__":
except RuntimeError as e:
print(e)
else:
- swaption_stack[key] = pd.concat(option_stack, names=['expiry', 'strike'])
+ swaption_stack[key] = pd.concat(option_stack, names=['expiry', 'Strike'])
index_data = index_data.append(fwd_index)
for col in ['fwdbpv', 'fwdprice', 'fwdspread', 'ref']:
index_data[col] = index_data[col].astype('float')
- index_data['index'] = index_data['index'].astype('category')
+ index_data['indextype'] = index_data['indextype'].astype('category')
swaption_stack = pd.concat(swaption_stack, names=['quotedate', 'indextype', 'series'])
- with pd.HDFStore('swaptions.hdf', mode = 'w', complevel=4,
+ with pd.HDFStore('../../data/swaptions.hdf', mode = 'w', complevel=4,
complib='blosc', fletcher32=True) as swaptions:
swaptions.append('swaptions', swaption_stack)
swaptions.append('index_data', index_data)