Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Mastering Python for Finance. - Second Edition

You're reading from  Mastering Python for Finance. - Second Edition

Product type Book
Published in Apr 2019
Publisher Packt
ISBN-13 9781789346466
Pages 426 pages
Edition 2nd Edition
Languages
Author (1):
James Ma Weiming James Ma Weiming
Profile icon James Ma Weiming

Table of Contents (16) Chapters

Preface Section 1: Getting Started with Python
Overview of Financial Analysis with Python Section 2: Financial Concepts
The Importance of Linearity in Finance Nonlinearity in Finance Numerical Methods for Pricing Options Modeling Interest Rates and Derivatives Statistical Analysis of Time Series Data Section 3: A Hands-On Approach
Interactive Financial Analytics with the VIX Building an Algorithmic Trading Platform Implementing a Backtesting System Machine Learning for Finance Deep Learning for Finance Other Books You May Enjoy

Interactive Financial Analytics with the VIX

Investors use volatility derivatives to diversify and hedge their risk in equity and credit portfolios. Since long-term investors in equity funds are exposed to downside risk, volatility can be used as a hedge for the tail risk and replacement for the put options. In the United States, the Chicago Board Options Exchange (CBOE) Volatility Index (VIX), or simply called the VIX, measures the short-term volatility implied by S&P 500 stock index options with an average expiration of 30 days. Many people around the world use the VIX to measure stock market volatility over the next 30-day period. In Europe, the equivalent volatility counterpart indicator is the EURO STOXX 50 Volatility (VSTOXX) Market Index. For benchmark strategies utilizing the S&P 500 Index, the nature of its negative correlation with the VIX presents a viable way...

Volatility derivatives

The two most popular volatility indexes worldwide are the VIX and VSTOXX, which are available in the United States and Europe respectively. The VIX is based on the S&P 500 Index that is disseminated on the CBOE. While the VIX is not traded directly, derivative products of the VIX such as options, futures, exchange-traded funds, and a host of volatility-based securities are available to investors. The CBOE website provides comprehensive information on many options and market indices such as the S&P 500 standard and weekly options, and the VIX, which we can analyze. We begin by understanding the background of these products before performing financial analytics on them in the later sections of this chapter.

STOXX and the Eurex

...

Financial analytics of the S&P 500 and the VIX

In this section, we will study the relationship between the VIX and the S&P 500 Market Index.

Gathering the data

We will be using Alpha Vantage as our data provider. Let's download the SPX and VIX datasets in the following steps:

  1. Query for the all-time S&P 500 historical data with the ticker symbol ^GSPC:
In [ ]:
from alpha_vantage.timeseries import TimeSeries

# Update your Alpha Vantage API key here...
ALPHA_VANTAGE_API_KEY = 'PZ2ISG9CYY379KLI'

ts = TimeSeries(key=ALPHA_VANTAGE_API_KEY, output_format='pandas')
df_spx_data, meta_data = ts.get_daily_adjusted(
symbol='^GSPC', outputsize=&apos...

Calculating the VIX Index

In this section, we will perform a step-by-step replication of the VIX Index. Calculation of the VIX Index is documented on the CBOE website. You may obtain a copy of the CBOE VIX white paper at http://www.cboe.com/micro/vix/vixwhite.pdf.

Importing SPX options data

Suppose you had gathered SPX options data from your broker or purchased historical data from an external source such as the CBOE website. For the purpose of this chapter, the end-of-day SPX option chain prices are observed from Monday, October 15, 2018 to Friday, October 19, 2018 and saved into Comma-separated Values (CSV) files. Sample copies of these files are provided under the files folder of the source codes repository.

...

Summary

In this chapter, we looked at volatility derivatives and their uses by investors to diversify and hedge their risk in equity and credit portfolios. Since long-term investors in equity funds are exposed to downside risk, volatility can be used as a hedge for the tail risk and in replacement for the put options. In the United States, the CBOE VIX measures the short-term volatility implied by SPX option prices. In Europe, the VSTOXX Market Index is based on the market prices of a basket of OESX, and measures the implied market volatility over the next 30 days on the EURO STOXX 50 Index. Many people around the world use the VIX as a popular measurement tool for the stock market volatility over the next 30-day period. To help us better understand how the VIX Index is calculated, we looked at its components and at formulas used in determining its value.

To help us determine...

lock icon The rest of the chapter is locked
You have been reading a chapter from
Mastering Python for Finance. - Second Edition
Published in: Apr 2019 Publisher: Packt ISBN-13: 9781789346466
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}