A Sample notebook based on the EurEX Tutorial
This notebook demonstrates the use of importable notebooks in the Knowledge Anyhow Workbench (KAWB).
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()
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'])
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)
In [ ]:
data = eurex.getDataSet('st50','/resources/eurextutorial_1.h5')
data.head()
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
In [ ]:
from pylab import *
data.plot(subplots=True, figsize=(9, 4), color='blue', grid=True)
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.
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)
In [ ]:
data.pct_change().head()
In [ ]:
data.pct_change().hist(color='b', alpha=.5, bins=100)
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)
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'])