aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/exploration/option_trades.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/python/exploration/option_trades.py b/python/exploration/option_trades.py
index cbb1bf2f..e3217e07 100644
--- a/python/exploration/option_trades.py
+++ b/python/exploration/option_trades.py
@@ -95,12 +95,18 @@ def rolling_vol(df, col='atm_vol', term=[3]):
# MS quotes don't have fwdspread so they end up as NA
return df.dropna()
-def vol_var(percentile=0.99, index='IG'):
- df = atm_vol(index, datetime.date(2014, 6, 11))
+def vol_var(percentile=0.975, index='IG', start_date=datetime.date(2014, 6, 11)):
+ """compute lo and hi percentiles of atm volatility daily change
+
+ Probably overestimates:
+ - we don't check that the quotes come from the same dealer
+ - we should group it by series
+ """
+ df = atm_vol(index, start_date)
df = rolling_vol(df, term=[1,2,3])
df = df.sort_index()
df = df.groupby(df.index.date).nth(-1)
- return df.pct_change().quantile(percentile)
+ return df.diff().quantile([1-percentile, percentile])
def get_index_spread(index, series, date, conn):
with conn.cursor() as c: