Correlation between SX5E and V2TX

We can use the corr function to derive the correlation values between each column of values in the pandas DataFrame object, as in the following Python example:

>>> print log_returns.corr()
           EUROSTOXX    VSTOXX
EUROSTOXX   1.000000 -0.732545
VSTOXX     -0.732545  1.000000
[2 rows x 2 columns]

At -0.7325, the EURO STOXX 50 Index is negatively correlated with the STOXX. To help us better visualize this relationship, we can plot both the sets of the daily log return values as a scatter plot. The statsmodels.api module is used to obtain the ordinary least squares regression line between the scattered data:

>>> import statsmodels.api as sm
>>>
>>> log_returns.plot(figsize=(10,8),
...                  x="EUROSTOXX", 
...                  y="VSTOXX",
...                  kind='scatter')
>>>
>>> ols_fit = sm.OLS(log_returns['VSTOXX'].values, 
...             log_returns['EUROSTOXX'].values).fit()
>>>
>>> plot(log_returns['EUROSTOXX'], ols_fit.fittedvalues, 'r')
[<matplotlib.lines.Line2D at 0x117704550>]
Correlation between SX5E and V2TX

The downward-sloping regression line, as shown in the preceding graph, confirms the negative correlation relationship between the EURO STOXX 50 and the VSTOXX indices.

The rolling_corr function of pandas computes the moving-window correlation between two time series over time. We will use a value of 252 to represent the number of trading days in the moving window to compute the annual rolling correlation, using the following commands:

>>> pd.rolling_corr(log_returns['EUROSTOXX'], 
...                  log_returns['VSTOXX'], 
...                  window=252).plot(figsize=(10,8))
>>> plt.ylabel('Rolling Annual Correlation')
<matplotlib.text.Text at 0x118feb810>
Correlation between SX5E and V2TX

It can be seen from the preceding graph that the EURO STOXX 50 Index and VSTOXX are negatively correlated during the entire lifetime of the indices using 252 trading days per year.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.181.252