Strategy Library

VIX Predicts Stock Index Returns

Introduction

VIX index is the weighted average of the implied volatilities computed from a total of eight near-the-money, nearby and second nearby American option contracts on the underlying S&P100 index. The index is calculated on an intraday basis by the CBOE. The extreme levels of the VIX index are a strong indicator of equity index returns. One could anticipate that the higher the fear in the markets, indicated by the VIX index, the higher the subsequent returns on the broad equity index. In this algorithm, we will explore if VIX index is the forward-looking indicator of future stock index returns.

Method

To assess if the implied volatility turns out to be relevant trading signals for long and short positions, we must first define what we mean by large or small implied volatility levels. At any given time, we create 20 equally spaced percentiles for the history close price of VIX in the last two years. By 20 equally spaced percentiles, it means the 5%, 10%, . . . , 95% percentiles. Then the current VIX index price is compared to these percentiles and ranked accordingly.

We import the daily VIX data from Quandl. The correspondent stock index is S&P100 index. We use the iShares S&P 100 ETF OEF In the first step, we create a rolling window to save the history VIX price. The history request is used to initialize the rolling window.

def Initialize(self):
    self.SetStartDate(2006, 1, 1)
    self.SetEndDate(2018, 8, 1)
    self.SetCash(100000)
    self.AddEquity("OEF", Resolution.Daily)
    self.vix = 'CBOE/VIX'
    self.AddData(QuandlVix, self.vix, Resolution.Daily)
    self.window = RollingWindow[float](252*2)
    hist = self.History([self.vix], 1000, Resolution.Daily)
    for close in hist.loc[self.vix]['vix close']:
        self.window.Add(close)

class QuandlVix(PythonQuandl):
    def __init__(self):
        self.ValueColumnName = "VIX Close"

The rolling past 2-year history of the VIX index is then split to create 20 equally spaced percentiles. The algorithm goes long on the equity index if the VIX index on the current day is higher than on any other day during the rolling 2-year window or if the VIX index value is in the highest 2 percentile boxes. If the VIX index on the current day is lower than on any other day during the rolling 2-year window or if the VIX index value is in the lowest two percentile boxes. The algorithm goes short on the equity index.

def OnData(self, data):
    if not data.ContainsKey(self.vix): return
    self.window.Add(self.Securities[self.vix].Price)
    if not self.window.IsReady: return
    history_close = [i for i in self.window]

    if self.Securities[self.vix].Price > np.percentile(history_close, 90):
        self.SetHoldings("OEF", 1)
    elif self.Securities[self.vix].Price < np.percentile(history_close, 10):
        self.SetHoldings("OEF", -1)

Algorithm

You can also see our Documentation and Videos. You can also get in touch with us via Chat.

Did you find this page Helpful ?