January 2020
Beginner to intermediate
432 pages
11h 24m
English
For the fifth fact, run the following steps to investigate the existence of the leverage effect.
df['moving_std_252'] = df[['log_rtn']].rolling(window=252).std()df['moving_std_21'] = df[['log_rtn']].rolling(window=21).std()
fig, ax = plt.subplots(3, 1, figsize=(18, 15), sharex=True) df.adj_close.plot(ax=ax[0]) ax[0].set(title='MSFT time series', ylabel='Stock price ($)') df.log_rtn.plot(ax=ax[1]) ax[1].set(ylabel='Log returns (%)') df.moving_std_252.plot(ax=ax[2], color='r', label='Moving Volatility 252d') df.moving_std_21.plot(ax=ax[2], color='g', label='Moving Volatility 21d') ax[2].set(ylabel='Moving Volatility', xlabel ...
Read now
Unlock full access