---
title: "VIX Central Contango"
description: "VIX Central Contango dataset from VIX Central."
canonical: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/vix-central/vix-central-contango
markdown: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/vix-central/vix-central-contango.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/03%20Writing%20Algorithms/14%20Datasets/32%20VIX%20Central/01%20VIX%20Central%20Contango
modified: 2026-10-29
index: https://www.quantconnect.com/llms.txt
---

# VIX Central Contango

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Writing Algorithms](https://www.quantconnect.com/docs/v2/writing-algorithms.md) > Datasets > [VIX Central](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/vix-central.md) > VIX Central Contango

> Code examples are shown in Python. Append `?lang=csharp` to this URL for the C# version of this page.

## Introduction

The VIX Central Contango dataset by VIX Central tracks VIX Futures (VX) contango data. The data covers 12 Futures contracts closest to expiry/maturity, starts in June 2010, and is delivered on a daily frequency. The dataset is created by QuantConnect downloading data from VIX Central website, which collects and analyses VIX and VX (VIX Futures) data.

Contango and Backwardation are terms used to describe if participants in the Futures market are overpaying or underpaying relative to the "spot" price of the underlying commodity when trading a Futures contract ("spot" price is the price of the actual commodity/asset at a given moment in time). Contango and backwardation can be used to determine forward-looking expectations of the commodity's spot price by the time the Future has expired/matured and is set to be delivered by participants of the Futures market. As Futures near their expiration/maturity date, contango and backwardation curves tend to converge on the spot price of the commodity at the time of expiration.

For more information about the VIX Central Contango dataset, including CLI commands and pricing, see the [dataset listing](https://www.quantconnect.com/datasets/quantconnect-vixcentral-contango).

## About the Provider

[VIX Central](http://vixcentral.com/) was founded by Eli Mintz in 2012 with goal of displaying historical VIX term structures in a simple and intuitive interface. VIX Central provides access to real-time and historical VIX data for individual investors.

## Getting Started

The following snippet demonstrates how to request data from the VIX Central Contango dataset:

```python
self.dataset_symbol = self.add_data(VIXCentralContango, "VIX", Resolution.DAILY).symbol
```

## Data Summary

The following table describes the dataset properties:

| Property | Value |
| --- | --- |
| Start Date | June 2010 |
| Asset Coverage | 1 Futures Chain with 12 contracts |
| Data Density | Regular |
| Resolution | Daily |
| Timezone | New York |

## Requesting Data

To add VIX Central Contango data to your algorithm, call the `add_data` method. Save a reference to the dataset `Symbol` so you can access the data later in your algorithm.

```python
class VixCentralContangoAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2014, 1, 1)
        self.set_end_date(2018, 1, 1)
        self.set_cash(25000)

        self.dataset_symbol = self.add_data(VIXCentralContango, "VX", Resolution.DAILY).symbol
```

## Accessing Data

To get the current VIX Central Contango data, index the current [`Slice`](https://www.quantconnect.com/docs/v2/writing-algorithms/key-concepts/time-modeling/timeslices.md) 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.

```python
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} front month at {slice.time}: {data_point.front_month}")
```

## Historical Data

To get historical VIX Central Contango data, call the `history` method with the dataset `Symbol`. If there is no data in the period you request, the history result is empty.

```python
# DataFrame
history_df = self.history(self.dataset_symbol, 100, Resolution.DAILY)

# Dataset objects
history_bars = self.history[VIXCentralContango](self.dataset_symbol, 100, Resolution.DAILY)
```

For more information about historical data, see [History Requests](https://www.quantconnect.com/docs/v2/writing-algorithms/historical-data/history-requests.md).

## Remove Subscriptions

To remove your subscription to VIX Central Contango data, call the `remove_security` method.

```python
self.remove_security(self.dataset_symbol)
```

## Example Applications

The VIX Central Contango dataset enables you to explore VIX Future contracts pricing data. Examples include the following strategies:

- Determining forward-looking expectations by Futures market participants of the underlying commodity's spot price by the time of expiration/maturity
- Creating cash-and-carry arbitrage strategies by trading the spread/convergence of the contango/backwardation curves as a Future nears expiration/maturity

### Classic Algorithm Design

The following example algorithm buys SPY when the percentage change between contract F2 and F1 (`Contango_F2_Minus_F1`) is positive. Otherwise, it remains in cash.

```python
from AlgorithmImports import *

class VixCentralContangoAlgorithm (QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        self.set_cash(25000)
        # SPY as market representative for macroeconomy indicator trading
        self.spy = self.add_equity("SPY", Resolution.DAILY).symbol
        # Request VIX Contango data for trade signal generation
        self.contango = self.add_data(VIXCentralContango, "VX", Resolution.DAILY).symbol

    def on_data(self, slice: Slice) -> None:
        # Trade base on the updated VIX contango data
        if self.contango not in slice:
            return
        contango_data = slice.get(VIXCentralContango, self.contango)
        ratio = contango_data.contango_f_2_minus_f_1 if contango_data else 0

        # Bet the market will go up if F2 - F1 price percentage change is positive, meaning the near-term market volatility is expected to be low
        if not self.portfolio.invested and ratio > 0:
            self.set_holdings(self.spy, 1)
        # Liqudiate otherwise to avoid excessive market volatility
        elif ratio < 0:
            self.liquidate()
```

### Framework Algorithm Design

The following example algorithm buys SPY when the percentage change between contract F2 and F1 (`Contango_F2_Minus_F1`) is positive. Otherwise, it remains in cash.

```python
from AlgorithmImports import *

class VixCentralContangoAlgorithm (QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        self.set_cash(25000)

        self.universe_settings.resolution = Resolution.DAILY
        # Include SPY as market representative for macroeconomy indicator trading
        symbols = [Symbol.create("SPY", SecurityType.EQUITY, Market.USA)]
        self.add_universe_selection(ManualUniverseSelectionModel(symbols))
        # Custom alpha model that emit insights base on VIX contango data
        self.add_alpha(ContangoAlphaModel(self))
        # Equal weighting investment to evenly dissipate the capital concentration risk on non-systematic risky event
        self.set_portfolio_construction(EqualWeightingPortfolioConstructionModel())

class ContangoAlphaModel(AlphaModel):

    def __init__(self, algorithm: QCAlgorithm) -> None:
        self.symbols = []
        # Request VIX Contango data for trade signal generation
        self.contango = algorithm.add_data(VIXCentralContango, "VX", Resolution.DAILY).symbol

        # Historical data
        history = algorithm.history(VIXCentralContango, self.contango, 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 = []

        # Trade base on the updated VIX contango data
        if self.contango not in slice:
            return []
        contango_data = slice.get(VIXCentralContango, self.contango)
        ratio = contango_data.contango_f_2_minus_f_1 if contango_data else 0

        # Bet the market will go up if F2 - F1 price percentage change is positive, meaning the near-term market volatility is expected to be low
        if not algorithm.portfolio.invested and ratio > 0:
            for symbol in self.symbols:
                insights += [Insight.price(symbol, Expiry.ONE_MONTH, InsightDirection.UP)]
        # Liqudiate otherwise to avoid excessive market volatility
        elif ratio < 0:
            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]
```

## Data Point Attributes

The VIX Central Contango dataset provides `VIXCentralContango` objects, which have the following attributes:

*Members of `QuantConnect.DataSource.VIXCentralContango` (JSON): https://www.quantconnect.com/services/inspector?type=T:QuantConnect.DataSource.VIXCentralContango&language=python*
