aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/parse_gs.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/python/parse_gs.py b/python/parse_gs.py
index 7a0ec006..3e25c6cb 100644
--- a/python/parse_gs.py
+++ b/python/parse_gs.py
@@ -7,7 +7,6 @@ data_dir = "/home/share/guillaume/swaptions"
all_df = {}
fwd_index = []
for f in os.listdir(data_dir):
- print(f)
with open(os.path.join(data_dir, f), "rb") as fh:
flag = False
masterdf = {}
@@ -65,7 +64,7 @@ for f in os.listdir(data_dir):
df.set_index('Strike', inplace=True)
d = {'quotedate': quotedate,
'expiry': date,
- 'indextype': indextype,
+ 'index': indextype,
'series': series,
'ref': refspread if indextype =="IG" else refprice}
if indextype == "IG":
@@ -79,19 +78,22 @@ for f in os.listdir(data_dir):
r = []
continue
all_df[(quotedate, indextype, series)] = pd.concat(masterdf, names=['expiry'])
-all_df = pd.concat(all_df, names = ['quotedate', 'indextype', 'series'])
+all_df = pd.concat(all_df, names = ['quotedate', 'index', 'series'])
all_df['DeltaPay'] = - all_df['DeltaPay']/100
-index_df = pd.DataFrame.from_records(fwd_index)
-# with pd.HDFStore('../../data/swaptions_gs.hdf', mode = 'w', complevel=4,
-# complib='blosc', fletcher32=True) as swaptions:
-# swaptions.append('swaptions', all_df)
-# swaptions.append('index_data', index_df)
+index_df = pd.DataFrame(fwd_index)
+
+all_df.reset_index(inplace=True)
all_df = all_df.rename(columns={'Strike':'strike',
'Vol': 'vol',
'PayOffer': 'pay_offer',
'PayBid': 'pay_bid',
- 'RecOffer': 'rec_offer'
+ 'RecOffer': 'rec_offer',
'RecBid': 'rec_bid',
'Tail': 'tail',
'DeltaPay': 'delta_pay'})
-})
+del all_df['VolBpd'], all_df['VolChg'], all_df['Sprd']
+all_df['quote_source'] = 'GS'
+from db import dbengine
+serenitasdb = dbengine('serenitasdb')
+all_df.to_sql('swaption_quotes', serenitasdb, if_exists='append', index=False)
+index_df.to_sql('swaption_ref_quotes', serenitasdb, if_exists='append', index=False)