Python for Finance: Analyze Big Financial Data

(Elle) #1

the respective EXP_MONTH column of the DataFrame object. For convenience, we store the


maturity dates alongside the other futures data:


In  [ 14 ]: tf  =   lambda x:   third_fridays[x]
vstoxx_futures[‘MATURITY’] = vstoxx_futures[‘EXP_MONTH’].apply(tf)
In [ 15 ]: vstoxx_futures.tail()
Out[15]: DATE EXP_YEAR EXP_MONTH PRICE MATURITY
499 2014-03-31 2014 7 20.40 2014-07-18
500 2014-03-31 2014 8 20.70 2014-08-15
501 2014-03-31 2014 9 20.95 2014-09-19
502 2014-03-31 2014 10 21.05 2014-10-17
503 2014-03-31 2014 11 21.25 2014-11-21

VSTOXX Options Data


At any time, there are eight futures traded on the VSTOXX. In comparison, there are of


course many more options, such that we expect a much larger data set for the volatility


options. In fact, we have almost 47,000 option quotes for the first quarter of 2014:


In  [ 16 ]: vstoxx_options  =   pd.read_excel(‘./source/vstoxx_march_2014.xlsx’,
‘vstoxx_options’)
In [ 17 ]: vstoxx_options.info()
Out[17]: <class ‘pandas.core.frame.DataFrame’>
Int64Index: 46960 entries, 0 to 46959
Data columns (total 8 columns):
A_DATE 46960 non-null datetime64[ns]
A_EXP_YEAR 46960 non-null int64
A_EXP_MONTH 46960 non-null int64
A_CALL_PUT_FLAG 46960 non-null object
A_EXERCISE_PRICE 46960 non-null int64
A_SETTLEMENT_PRICE_SCALED 46960 non-null int64
A_PRODUCT_ID 46960 non-null object
SETTLE 46960 non-null float64
dtypes: datetime64[ns](1), float64(1), int64(4), object(2)

As before, not all columns are needed:


In  [ 18 ]: del vstoxx_options[‘A_SETTLEMENT_PRICE_SCALED’]
del vstoxx_options[‘A_PRODUCT_ID’]

A renaming of the columns simplifies later queries a bit:


In  [ 19 ]: columns =   [‘DATE’,    ‘EXP_YEAR’, ‘EXP_MONTH’,    ‘TYPE’, ‘STRIKE’,   ‘PRICE’]
vstoxx_options.columns = columns

We use the tf function to again store the maturity dates alongside the options data:


In  [ 20 ]: vstoxx_options[‘MATURITY’]  =   vstoxx_options[‘EXP_MONTH’].apply(tf)
In [ 21 ]: vstoxx_options.head()
Out[21]: DATE EXP_YEAR EXP_MONTH TYPE STRIKE PRICE MATURITY
0 2014-01-02 2014 1 C 1000 7.95 2014-01-17
1 2014-01-02 2014 1 C 1500 3.05 2014-01-17
2 2014-01-02 2014 1 C 1600 2.20 2014-01-17
3 2014-01-02 2014 1 C 1700 1.60 2014-01-17
4 2014-01-02 2014 1 C 1800 1.15 2014-01-17

A single options contract is on 100 times the index value. Therefore, the strike price is also


scaled up accordingly. To have a view of a single unit, we rescale the strike price by


dividing it by 100:


In  [ 22 ]: vstoxx_options[‘STRIKE’]    =   vstoxx_options[‘STRIKE’]    /   100.

All data from the external resources has now been collected and prepared. If needed, one


can save the three DataFrame objects for later reuse:


In  [ 23 ]: save    =   False
if save is True:
import warnings
Free download pdf