diff options
Diffstat (limited to 'python/exploration')
| -rw-r--r-- | python/exploration/option_trades.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/python/exploration/option_trades.py b/python/exploration/option_trades.py index aadbddfd..ab61a520 100644 --- a/python/exploration/option_trades.py +++ b/python/exploration/option_trades.py @@ -19,11 +19,12 @@ def realized_vol(index, series, tenor='5yr', date=None, years=None, return_type= if years is None: raise ValueError("need to provide at least one of date or years") date = (pd.Timestamp.now() - pd.DateOffset(years=years)).date() - returns = index_returns(index=index, series=series, tenor=tenor, years=None) - # GARCH(1,1) volatility process with constant mean - am = arch_model(returns[return_type+'_return']) + returns = index_returns(index=index, series=series, tenor=tenor, years=None).dropna() + # GARCH(1,1) volatility process with constant mean, scale to help with fitting + scale = 10 + am = arch_model(scale * returns[return_type+'_return']) res = am.fit(update_freq=0, disp='off') - return (res.conditional_volatility * math.sqrt(252), res) + return (res.conditional_volatility * math.sqrt(252)/scale, res) def lr_var(res): r""" computes long run variance of the garch process |
