Analyzing Historical VSTOXX Data

A Sample notebook based on the EurEX Tutorial

SWIFT Object Store for EurEx

This notebook demonstrates the use of importable notebooks in the Knowledge Anyhow Workbench (KAWB).

Tutorial Tasks

  1. Import a KAWB notebook.
  2. Create a new HDF database using Eurex content in the SoftLayer Object Store.
  3. Extract content from the database
  4. Explore correlations in the extracted data.

KAWB Importable Notebook Magic

IBM's Knowledge Anyhow Workbench (KAWB) allows one notebookk to access the API of another notebook via the python import directive.


In [ ]:
# Import a KAWB Notebook
import kawb
import mywb.ibmetech_swift4eurex as ibmetech_swift4eurex

In [ ]:
# Print the help associated with the imported notebook.
ibmetech_swift4eurex.help()

Get Data

Acquire SoftLayer Object Store Credentials

Create a JSON files and add it to your workbench. The file should look like this:

  • Your SoftLayer Object Store Credentials
    {
      "username":"xxxxxxxxx", 
      "api_key":"xxxxxxxxxxxxx"
    }

In [ ]:
# Load SoftLayer Account Credentials
import json
with file('/resources/sl-swift-keys.json') as f:
    sl_key = json.load(f)
print("SoftLayer credentials are: \nusername={0}\napi_key={1}").format(sl_key['username'], sl_key['api_key'])

Create a database

Using the data files stored in a designated SoftLayer Object Store, create a local HFS Database. This is accomplished for us via the Eurex object defined in our importable notebook.


In [ ]:
USERNAME = sl_key['username']
API_KEY = sl_key['api_key']
DBNAME = "eurextutorial_1.h5"
eurex = ibmetech_swift4eurex.Eurex()
eurex.connect(USERNAME,API_KEY)
eurex.createHDF5(DBNAME)
eurex.listDataSets(DBNAME)

Load Data

Create a dataframe of STOXX 50 prices and VSTOXX (V2TX) values since 01 Jan 2000. This content is stored in the st50 dataset within the database. .


In [ ]:
data = eurex.getDataSet('st50','/resources/eurextutorial_1.h5')
data.head()

Data Analysis

Using our data from the SoftLayer Object Store, we can proceed with the analysis workflow outlined in the Basic Eurex Analysis of Historical Data


In [ ]:
%matplotlib inline

Plot the EURO STOXX 50 and VSTOXX indexes


In [ ]:
from pylab import *
data.plot(subplots=True, figsize=(9, 4), color='blue', grid=True)
Observation

The two indexes seem to be highly negatively correlated. When the EURO STOXX 50 goes up, the VSTOXX comes down and vice versa. Something sometimes called the leverage effect.

Computation of Changes

To calculate and visualize the absolute changes, we plot a histogram which shows the absolute differences and their absolute frequencies.


In [ ]:
data.diff().hist(color='b', alpha=.5, bins=100)

The figure shows the absolute returns of both indexes on daily basis.

Observation

The daily percentage changes might also be of interest. We can compute and plot them as well.


In [ ]:
data.pct_change().head()

In [ ]:
data.pct_change().hist(color='b', alpha=.5, bins=100)

Calculation of Log-Returns

In financial applications, one is often interested in daily log-returns. We will calculate them and store them in the Data Frame data. To this end, we generate two now columns using the shift method. Then we plot the results.


In [ ]:
data['esr'] = log(data['EUROSTOXX'] / data['EUROSTOXX'].shift(1))
data['vsr'] = log(data['VSTOXX'] / data['VSTOXX'].shift(1))
data.head()

In [ ]:
data[['esr', 'vsr']].plot(subplots=True, figsize=(9, 4), color='blue', grid=True)

Correlation between EURO STOXX 50 and VSTOXX

There are (at least) two possible ways to calculate the correlation between both log-returns. On the one hand, we can generate a correlation matrix as output (which would be preferred for more than two time series). On the other hand, we can compute the correlation directly between the two time series of interest:


In [ ]:
data[['esr','vsr']].corr()

In [ ]:
data['esr'].corr(data['vsr'])
Observation

The log-returns of both indexes are highly negatively correlated. Again support for the leverage effect which implies that with dropping index levels risk increases. Also, if index levels rise, risks come down in general.