CBOE
VIX Daily Price
Introduction
The VIX Daily Price dataset by CBOE covers 18 US volatility indices. The data starts in January 1990 and is delivered on a daily frequency. The dataset is cached daily from the CBOE website. The volatility index measures the stock market's expectation of volatility on the market index (e.g.: S&P500) using implied volatility from its Options for a fixed time horizon.
For more information about the VIX Daily Price dataset, including CLI commands and pricing, see the dataset listing.
About the Provider
The Chicago Board Options Exchange (CBOE) is the largest U.S. options exchange with annual trading volume that hovered around 1.27 billion contracts at the end of 2014. CBOE offers Options on over 2,200 companies, 22 Equity indices, and 140 exchange-traded funds (ETFs).
Requesting Data
To add VIX Daily Price data to your algorithm, call the AddData
add_data
method. Save a reference to the dataset Symbol
so you can access the data later in your algorithm.
class CboeDataAlgorithm(QCAlgorithm): def initialize(self) -> None: self.set_start_date(2003, 1, 1) self.set_end_date(2019, 10, 11) self.set_cash(100000) self.dataset_symbol = self.add_data(CBOE, "VIX", Resolution.DAILY).symbol
public class CboeDataAlgorithm : QCAlgorithm { private Symbol _datasetSymbol; public override void Initialize() { SetStartDate(2003, 1, 1); SetEndDate(2019, 10, 11); SetCash(100000); _datasetSymbol = AddData<CBOE>("VIX", Resolution.Daily).Symbol; } }
Accessing Data
To get the current VIX Daily Price data, index the current Slice
with the dataset Symbol
. Slice objects deliver unique events to your algorithm as they happen, but the Slice
may not contain data for your dataset at every time step. To avoid issues, check if the Slice
contains the data you want before you index it.
def on_data(self, slice: Slice) -> None: if slice.contains_key(self.dataset_symbol): data_point = slice[self.dataset_symbol] self.log(f"{self.dataset_symbol} close at {slice.time}: {data_point.close}")
public override void OnData(Slice slice) { if (slice.ContainsKey(_datasetSymbol)) { var dataPoint = slice[_datasetSymbol]; Log($"{_datasetSymbol} close at {slice.Time}: {dataPoint.Close}"); } }
Historical Data
To get historical VIX Daily Price data, call the History
history
method with the dataset Symbol
. If there is no data in the period you request, the history result is empty.
# DataFrame history_df = self.history(self.dataset_symbol, 100, Resolution.DAILY) # Dataset objects history_bars = self.history[CBOE](self.dataset_symbol, 100, Resolution.DAILY)
var history = History<CBOE>(_datasetSymbol, 100, Resolution.Daily);
For more information about historical data, see History Requests.
Supported Indicies
The following table shows the volatility indices in the VIX Daily Price dataset:
Ticker | Index | Expiry | Start Date | Data Points |
VIX | S&P500 | 30 Days | May 2022 | OHLC |
VIX1D | S&P500 | 1 Day | Apr 2011 | OHLC |
VIX9D | S&P500 | 9 Days | Apr 2011 | OHLC |
VIX3M | S&P500 | 3 Months | Sep 2009 | OHLC |
VIX6M | S&P500 | 6 Months | Jan 2008 | OHLC |
VIX1Y | S&P500 | 1 Year | Jan 2007 | OHLC |
VXO | S&P100 | 30 Days | Feb 1993 | OHLC |
VXN | Nasdaq 100 | 30 Days | Sep 2009 | OHLC |
RVX | Russell 2000 | 30 Days | Sep 2009 | OHLC |
VVIX | VIX | 30 Days | Mar 2006 | Close |
TYVIX | 10-year US Treasury Note | 30 Days | Jan 2003 | OHLC |
VXTLT | 20-year US Treasury Bond | 30 Days | Jan 2004 | Close |
VXEEM | MSCI Emerging Markets | 30 Days | Mar 2011 | OHLC |
OVX | United States Oil Fund (USO) | 30 Days | Sep 2009 | Close |
GVZ | SPDR Gold Shares ETF (GLD) | 30 Days | Sep 2009 | Close |
FVX | 5 Year Treasury Yield Index | 30 Days | Dec 1993 | Close |
VXEFA | EFA VIX Index | 30 Days | Jan 2008 | OHLC |
VXAPL | Apple VIX Index | 30 Days | Jan 2011 | OHLC |
VXAZN | Amazon VIX Index | 30 Days | Jan 2011 | OHLC |
VXGOG | Google VIX Index | 30 Days | Jan 2011 | OHLC |
VXGS | Goldman Sachs VIX Index | 30 Days | Jan 2011 | OHLC |
VXIBM | IBM VIX Index | 30 Days | Jan 2011 | OHLC |
VXD | DJIA VIX Index | 30 Days | Sep 2009 | OHLC |
Example Applications
The VIX Daily Price enables you to incorporate popular US volatility indices in your strategies. Examples include the following strategies:
- Understanding the stock market's level of expected forward-looking volatility, also known as the "fear index". When the VIX starts moving higher, it is telling you that traders are getting nervous. When the VIX starts moving lower, it is telling you that traders are gaining confidence.
- Determining forward-looking volatility by comparing the VIX against volatility indices with other volatility. By comparing the value of the VIX to the value of the VIX3M, you can identify periods when trader sentiment has turned extremely bearish and when it has normalized.
Classic Algorithm Design
The following example algorithm buys SPY when the ratio between VIX and VIX3M is positive. Otherwise, it holds cash.
from AlgorithmImports import * from QuantConnect.DataSource import * class CBOEDataAlgorithmAlgorithm(QCAlgorithm): def initialize(self) -> None: self.set_start_date(2014,1,1) self.set_end_date(2018,1,1) self.set_cash(25000) # Request SPY data for trading, since it is the underlying of VIX indices self.spy = self.add_equity("SPY", Resolution.DAILY).symbol # Request 1-mo and 3-mo CBOE VIX data for trade signal generation self.vix = self.add_data(CBOE, 'VIX', Resolution.DAILY).symbol self.vxv = self.add_data(CBOE, 'VIX3M', Resolution.DAILY).symbol # Create a 3mo-over-1mo VIX price indicator to estimate the relative short-term volatility # Normally 3-mo volatility should be higher due to higher time uncertainty, but if the market preceive a shock within short time, it will invert self.vix_price = self.identity(self.vix, 1, Resolution.DAILY) self.vxv_price = self.identity(self.vxv, 1, Resolution.DAILY) self.ratio = IndicatorExtensions.over(self.vxv_sma, self.vix_sma) # Plot indicators each time they update using the PlotIndicator function for data visualization self.plot_indicator("Ratio", self.ratio) self.plot_indicator("Data", self.vix_sma, self.vxv_sma) # Historical data history = self.history(CBOE, self.vix, 60, Resolution.DAILY) self.debug(f"We got {len(history.index)} items from our history request"); def on_data(self, slice: Slice) -> None: # Wait for all indicators to fully initialize if not (self.vix_sma.is_ready and self.vxv_sma.is_ready and self.ratio.is_ready): return # Invest in SPY if the market is not in panic, assuming the market is always uptrending if not self.portfolio.invested and self.ratio.current.value > 1: self.market_order(self.spy, 100) # If the short term volatility is high, exit all positions to avoid excessive risk elif self.ratio.current.value < 1: self.liquidate()
public class CBOEDataAlgorithmAlgorithm : QCAlgorithm { private Symbol _spy; private Symbol _vix; private Symbol _vxv; private SimpleMovingAverage _smaVIX; private SimpleMovingAverage _smaVXV; private IndicatorBase _ratio; public override void Initialize() { SetStartDate(2014, 1, 1); SetEndDate(2018, 1, 1); SetCash(25000); // Request SPY data for trading, since it is the underlying of VIX indices _spy = AddEquity("SPY", Resolution.Daily).Symbol; // Request 1-mo and 3-mo CBOE VIX data for trade signal generation _vix = AddData<CBOE>("VIX", Resolution.Daily).Symbol; _vxv = AddData<CBOE>("VIX3M", Resolution.Daily).Symbol; // Create a 3mo-over-1mo VIX price indicator to estimate the relative short-term volatility // Normally 3-mo volatility should be higher due to higher time uncertainty, but if the market preceive a shock within short time, it will invert _smaVIX = SMA(_vix, 1); _smaVXV = SMA(_vxv, 1); _ratio = _smaVXV.Over(_smaVIX); // Historical data var history = History<CBOE>(_vix, 60, Resolution.Daily); Debug($"We got {history.Count()} items from our history request"); } public override void OnData(Slice slice) { // Wait for all indicators to fully initialize if (_smaVIX.IsReady && _smaVXV.IsReady && _ratio.IsReady) { // Invest in SPY if the market is not in panic, assuming the market is always uptrending if (!Portfolio.Invested && _ratio > 1) { MarketOrder(_spy, 100); } // If the short term volatility is high, exit all positions to avoid excessive risk else if (_ratio < 1) { Liquidate(); } // Plot indicators each time they update for data visualization Plot("SMA", "VIX", _smaVIX); Plot("SMA", "VXV", _smaVXV); Plot("Ratio", "Value", _ratio.Current.Value); } } }
Framework Algorithm Design
The following example algorithm buys SPY when the ratio between VIX and VIX3M is positive. Otherwise, it holds cash.
from AlgorithmImports import * from QuantConnect.DataSource import * class CBOEDataAlgorithmAlgorithm(QCAlgorithm): def initialize(self) -> None: self.set_start_date(2014,1,1) self.set_end_date(2018,1,1) self.set_cash(25000) self.universe_settings.resolution = Resolution.DAILY # Universe contains only SPY data for trading, since it is the underlying of VIX indices symbols = [Symbol.create("SPY", SecurityType.EQUITY, Market.USA)] self.add_universe_selection(ManualUniverseSelectionModel(symbols)) # A custom alpha model that emit insights based on VIX data self.add_alpha(VixRatioAlphaModel(self)) # Equal investing can evenly dissipate non-systematic capital concentration risk self.set_portfolio_construction(EqualWeightingPortfolioConstructionModel()) class VixRatioAlphaModel(AlphaModel): def __init__(self, algorithm: QCAlgorithm) -> None: # Request 1-mo and 3-mo CBOE VIX data for trade signal generation self.vix = algorithm.add_data(CBOE, 'VIX', Resolution.DAILY).symbol self.vxv = algorithm.add_data(CBOE, 'VIX3M', Resolution.DAILY).symbol # Create a 3mo-over-1mo VIX price indicator to estimate the relative short-term volatility # Normally 3-mo volatility should be higher due to higher time uncertainty, but if the market preceive a shock within short time, it will invert self.vix_sma = algorithm.SMA(self.vix, 1, Resolution.DAILY) self.vxv_sma = algorithm.SMA(self.vxv, 1, Resolution.DAILY) self.ratio = IndicatorExtensions.over(self.vxv_sma, self.vix_sma) self.symbols = [] # Plot indicators each time they update using the PlotIndicator function for data visualization algorithm.plot_indicator("Ratio", self.ratio) algorithm.plot_indicator("Data", self.vix_sma, self.vxv_sma) # Historical data history = algorithm.history(CBOE, self.vix, 60, Resolution.DAILY) algorithm.debug(f"We got {len(history.index)} items from our history request") def update(self, algorithm: QCAlgorithm, slice: Slice) -> List[Insight]: insights = [] # Wait for all indicators to fully initialize if not (self.vix_sma.is_ready and self.vxv_sma.is_ready and self.ratio.is_ready): return insights # Invest in SPY if the market is not in panic, assuming the market is always uptrending if not algorithm.portfolio.invested and self.ratio.current.value > 1: for symbol in self.symbols: insights += [Insight.price(symbol, Expiry.ONE_MONTH, InsightDirection.UP)] # If the short term volatility is high, exit all positions to avoid excessive risk elif self.ratio.current.value < 1: for symbol in self.symbols: insights += [Insight.price(symbol, Expiry.ONE_MONTH, InsightDirection.FLAT)] return insights def on_securities_changed(self, algorithm: QCAlgorithm, changes: SecurityChanges) -> None: for symbol in [x.symbol for x in changes.removed_securities]: if symbol in self.symbols: self.symbols.pop(symbol) self.symbols += [x.symbol for x in changes.added_securities]
public class CBOEDataAlgorithmAlgorithm : QCAlgorithm { public override void Initialize() { SetStartDate(2014, 1, 1); SetEndDate(2018, 1, 1); SetCash(25000); UniverseSettings.Resolution = Resolution.Daily; // Universe contains only SPY data for trading, since it is the underlying of VIX indices var symbols = new[] {QuantConnect.Symbol.Create("SPY", SecurityType.Equity, Market.USA)}; AddUniverseSelection(new ManualUniverseSelectionModel(symbols)); // A custom alpha model that emit insights based on VIX data AddAlpha(new VixRatioAlphaModel(this)); // Equal investing can evenly dissipate non-systematic capital concentration risk SetPortfolioConstruction(new EqualWeightingPortfolioConstructionModel()); } } public class VixRatioAlphaModel : AlphaModel { private Symbol _vix; private Symbol _vxv; private SimpleMovingAverage _smaVIX; private SimpleMovingAverage _smaVXV; private IndicatorBase _ratio; private List<Symbol> _symbols; public VixRatioAlphaModel(QCAlgorithm algorithm) { // Request 1-mo and 3-mo CBOE VIX data for trade signal generation _vix = algorithm.AddData<CBOE>("VIX", Resolution.Daily).Symbol; _vxv = algorithm.AddData<CBOE>("VIX3M", Resolution.Daily).Symbol; // Create a 3mo-over-1mo VIX price indicator to estimate the relative short-term volatility // Normally 3-mo volatility should be higher due to higher time uncertainty, but if the market preceive a shock within short time, it will invert _smaVIX = algorithm.SMA(_vix, 1); _smaVXV = algorithm.SMA(_vxv, 1); _ratio = _smaVXV.Over(_smaVIX); _symbols = new List<Symbol>(); // Historical data var history = algorithm.History<CBOE>(_vix, 60, Resolution.Daily); algorithm.Debug($"We got {history.Count()} items from our history request"); } public override IEnumerable<Insight> Update(QCAlgorithm algorithm, Slice slice) { var insights = new List<Insight>(); // Wait for all indicators to fully initialize if (_smaVIX.IsReady && _smaVXV.IsReady && _ratio.IsReady) { // Invest in SPY if the market is not in panic, assuming the market is always uptrending if (!algorithm.Portfolio.Invested && _ratio > 1) { foreach (var symbol in _symbols) { insights.Add(Insight.Price(symbol, Expiry.OneMonth, InsightDirection.Up)); } } // If the short term volatility is high, exit all positions to avoid excessive risk else if (_ratio < 1) { foreach (var symbol in _symbols) { insights.Add(Insight.Price(symbol, Expiry.OneMonth, InsightDirection.Flat)); } } // Plot indicators each time they update for data visualization algorithm.Plot("SMA", "VIX", _smaVIX); algorithm.Plot("SMA", "VXV", _smaVXV); algorithm.Plot("Ratio", "Value", _ratio.Current.Value); } return insights; } public override void OnSecuritiesChanged(QCAlgorithm algorithm, SecurityChanges changes) { foreach (var symbol in changes.RemovedSecurities.Select(x=>x.Symbol)) { _symbols.Remove(symbol); } _symbols.AddRange(changes.AddedSecurities.Select(x=> x.Symbol)); } }