---
title: "Cash Indices"
description: "Cash Indices dataset from QuantConnect."
canonical: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quantconnect/cash-indices
markdown: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quantconnect/cash-indices.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/03%20Writing%20Algorithms/14%20Datasets/02%20QuantConnect/10%20Cash%20Indices
modified: 2026-10-29
index: https://www.quantconnect.com/llms.txt
---

# Cash Indices

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Writing Algorithms](https://www.quantconnect.com/docs/v2/writing-algorithms.md) > Datasets > [QuantConnect](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quantconnect.md) > Cash Indices

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

## Introduction

The Cash Indices dataset by QuantConnect covers 125 US Indices and 3 International indices. The data starts on various dates from January 1998 and is delivered on any frequency from minute to daily.

For more information about the Cash Indices dataset, including CLI commands and pricing, see the [dataset listing](https://www.quantconnect.com/datasets/quantconnect-cash-indices).

## About the Provider

QuantConnect was founded in 2012 to serve quants everywhere with the best possible algorithmic trading technology. Seeking to disrupt a notoriously closed-source industry, QuantConnect takes a radically open-source approach to algorithmic trading. Through the QuantConnect web platform, more than 50,000 quants are served every month.

## Live Data

The QuantConnect data provider streams live [SPX and VIX](https://www.quantconnect.com/docs/v2/cloud-platform/datasets/quantconnect/us-indices.md) data from CBOE.

## Getting Started

The following snippet demonstrates how to request data from the Cash Indices dataset:

```python
self.vix = self.add_index("VIX", Resolution.DAILY).symbol
```

## Data Summary

The following table describes the dataset properties:

| Property | Value |
| --- | --- |
| Start Date | January 1998 |
| Coverage | 125 US Indices and 3 International indices (HSI, SX5E and N225) |
| Data Density | Dense |
| Resolution | Second (SPX, NDX, and VIX), Minute, Hour, & Daily |
| Timezone | New York for US Indices, refer to `Supported Assets` below for International indices |
| Market Hours | [Regular Only](https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes/index/market-hours.md) |

## Requesting Data

To add Cash Indices data to your algorithm, call the `add_index` method. Save a reference to the Index `Symbol` so you can access the data later in your algorithm.

```python
class CashIndexAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2020, 6, 1)
        self.set_end_date(2021, 6, 1)
        self.set_cash(100000)

        self.vix = self.add_index("VIX").symbol
```

For more information about creating Index subscriptions, see [Requesting Data](https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes/index/requesting-data.md).

## Accessing Data

To get the current Cash Indices data, index the `bars` property of the current [`Slice`](https://www.quantconnect.com/docs/v2/writing-algorithms/key-concepts/time-modeling/timeslices.md) with the Index `Symbol`. Slice objects deliver unique events to your algorithm as they happen, but the `Slice` may not contain data for your security 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 self.vix in slice.bars:
        trade_bar = slice.bars[self.vix]
        self.log(f"{self.vix} close at {slice.time}: {trade_bar.close}")
```

You can also iterate through all of the data objects in the current `Slice`.

```python
def on_data(self, slice: Slice) -> None:
    for symbol, trade_bar in slice.bars.items():
        self.log(f"{symbol} close at {slice.time}: {trade_bar.close}")
```

For more information about accessing Index data, see [Handling Data](https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes/index/handling-data.md).

## Historical Data

To get historical Cash Indices data, call the `history` method with the Index `Symbol`. If there is no data in the period you request, the history result is empty.

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

# TradeBar objects
history_bars = self.history[TradeBar](self.vix, 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 an Index subscription, call the `remove_security` method.

```python
self.remove_security(self.vix)
```

## Supported Indices

### US Cash Indices

The following table shows the US Cash indices with Index Option support:

| Ticker | Index | Expiry | Start Date |
| --- | --- | --- | --- |
| VIX | S&P500 | 30 Days | Jul 2003 |
| SPX | S&P500 | - | Jan 1998 |
| NDX | NASDAQ-100 | - | Jan 1998 |
| RUT | Russell 2000 | - | Jan 2008 |

#### VIX - CBOE Volatility Index

The Cboe Volatility Index (VIX) is a real-time index that represents the market's expectations for the relative strength of near-term price changes of the S&P 500 Index (SPX). Because it's derived from the prices of SPX index Options with near-term expiration dates, it generates a 30-day forward projection of volatility. Volatility, or how fast prices change, is often seen as a way to gauge market sentiment, and in particular, the degree of fear among market participants.

#### SPX - S&P 500 Index

The S&P 500 Index, or the Standard & Poor's 500 Index, is a market-capitalization-weighted index of the 500 largest publicly-traded companies in the U.S. It is not an exact list of the top 500 U.S. companies by market capitalization because there are other criteria included in the index. The index is widely regarded as the best gauge of large-cap U.S. Equities.

#### NDX - Nasdaq 100 Index

The Nasdaq-100 Index is a modified market-capitalization-weighted index composed of securities issued by 100 of the largest non-financial companies listed on the Nasdaq Stock Market (Nasdaq). The index includes companies from various industries except for the financial industry, like commercial and investment banks. These non-financial sectors include retail, biotechnology, industrial, technology, health care, and others.

#### RUT - Russell 2000 Index

The Russell 2000 Index is a small-cap U.S. stock market index that makes up the smallest 2,000 stocks in the Russell Index. It was started by the Frank Russell Company in 1984. The index is maintained by FTSE Russell, a subsidiary of the London Stock Exchange Group (LSEG).

#### All US Cash Indices

The following table shows all US Cash indices:

| Indices Available (125). Note: QuantConnect is working on its modeling: market hours and symbol properties. |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- |
| AEX | ASX | BKX | BRR | BRTI | BXD |
| BXM | BXN | BXR | CEX | CLL | COMP |
| COR1M | COR1Y | COR30D | COR3M | COR6M | COR9M |
| CXU | DAX | DJCIAGC | DJCICC | DJCIEN | DJCIGC |
| DJCIGR | DJCIIK | DJCIKC | DJCISB | DJCISI | DJI |
| DJINET | DJR | DJTTR | DJX | DRG | DUX |
| DVS | DWCF | DWCPF | DWLG | DWLV | DXL |
| DXY | EVZ | FVX | GVZ | HGX | LOVOL |
| MID | MIDG | MIDV | MRUT | NDX | NQX |
| NYA | NYFANG | NYXBT | OEX | OSX | OVX |
| PUT | REIT | RUA | RUI | RUT | RVX |
| RXM | SET | SGX | SKEW | SMILE | SMLG |
| SP500LVOL | SP600 | SPEN | SPGSCI | SPMPG | SPMPV |
| SPRI | SPRO | SPSIBI | SPSPG | SPSPV | SPSV |
| SPTMI | SPX | SPXPG | SPXPV | SVX | TNX |
| TYX | UKX | UTIL | UTY | VIF | VIN |
| VIX | VIX1D | VIX1Y | VIX3M | VIX6M | VIX9D |
| VOLI | VPD | VPN | VVIX | VWA | VWB |
| VXD | VXN | VXO | VXSLV | VXTH | VXTLT |
| W5000 | WPUT | XAU | XAX | XDA | XDB |
| XEO | XMI | XNDX | XSP | XSR |  |

### International Cash Indices

The following table shows the International Cash indices:

| Ticker | Index | Start Date | Time Zone | Currency |
| --- | --- | --- | --- | --- |
| SX5E | EUREX EU STOXX | Jul 2003 | Europe/Berlin | EUR |
| N225 | Nikkei 225 | Jul 2003 | Asia/Tokyo | JPY |

## Example Applications

The Cash Indices enable you to incorporate popular indices into your trading algorithms. Examples include the following use cases:

- Exploring the difference between the Index and the ETF that tracks it
- Using these indices as the underlying asset fo Index Options 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 tells you that traders are getting nervous. When the VIX starts moving lower, it tells you that traders are gaining confidence.

### Classic Algorithm Example

The following example algorithm tracks the 80-day EMA and 200-day EMA of SPX. When the short EMA crosses above the long EMA, the algorithm buys SPY. Otherwise, it holds cash.

```python
from AlgorithmImports import *

class IndexDataAlgorithm(QCAlgorithm):

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

        # Request SPY data as a trading vehicle for SPX
        self.spy = self.add_equity("SPY").symbol

        # Request SPX data for trade signal generation
        spx = self.add_index("SPX").symbol

        # Create short and long-term EMA indicators for trend estimation to trade
        self.ema_fast = self.EMA(spx, 80, Resolution.DAILY)
        self.ema_slow = self.EMA(spx, 200, Resolution.DAILY)
        self.set_warm_up(200, Resolution.DAILY)

        # Historical data
        history = self.history(spx, 60, Resolution.DAILY)
        self.debug(f'We got {len(history.index)} items from our history request')

    def on_data(self, slice: Slice) -> None:
        # Trade signals required indicators to be ready
        if self.is_warming_up or not self.ema_slow.is_ready:
            return

        # If short-term EMA is above long-term, it indicates an up trend, so we buy SPY
        if not self.portfolio.invested and self.ema_fast > self.ema_slow:
            self.set_holdings(self.spy, 1)
        # If it is the reverse, it indicates a downtrend, and we liquidate any position
        elif self.ema_fast < self.ema_slow:
            self.liquidate()
```

### Framework Algorithm Example

The following example algorithm tracks the 80-day EMA and 200-day EMA of SPX. When the short EMA crosses above the long EMA, the algorithm buys SPY. Otherwise, it holds cash.

```python
from AlgorithmImports import *

class IndexDataAlgorithm(QCAlgorithm):

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

        # Universe contains only SPY as a trading vehicle for SPX
        self.set_universe_selection(ManualUniverseSelectionModel
        (
            Symbol.create("SPY", SecurityType.EQUITY, Market.USA)
        ))
        # Custom alpha model that emits insights based on SPX index data
        self.set_alpha(SpxEmaCrossAlphaModel(self))
        # Equally investing can dissipate non-systematic risky event's capital concentration risk evenly
        self.set_portfolio_construction(EqualWeightingPortfolioConstructionModel(Expiry.END_OF_MONTH))

class SpxEmaCrossAlphaModel(AlphaModel):

    def __init__(self, algorithm: QCAlgorithm) -> None:
        # Request SPX data for trade signal generation
        spx = algorithm.add_index("SPX").symbol

        # Create short and long-term EMA indicators for trend estimation to trade
        self.ema_fast = algorithm.EMA(spx, 80, Resolution.DAILY)
        self.ema_slow = algorithm.EMA(spx, 200, Resolution.DAILY)
        algorithm.set_warm_up(200, Resolution.DAILY)

        # Historical data
        history = algorithm.history(spx, 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]:
        # Trade signals required indicators to be ready
        if algorithm.is_warming_up or not self.ema_slow.is_ready:
            return []

        # If short-term EMA is above long-term, it indicates an up trend, so we buy SPY
        if not algorithm.portfolio.invested and self.ema_fast > self.ema_slow:
            return [Insight.price(kvp.key, Expiry.END_OF_MONTH, InsightDirection.UP)
                for kvp in algorithm.active_securities if kvp.value.is_tradable]
        # If it is the reverse, it indicates downtrend, and we liquidate any position
        elif self.ema_fast < self.ema_slow:
            return [Insight.price(kvp.key, Expiry.END_OF_MONTH, InsightDirection.FLAT)
                for kvp in algorithm.active_securities if kvp.value.is_tradable]

        return []
```

## Data Point Attributes

The Cash Indices dataset provides `TradeBar` object.

### TradeBar Attributes

`TradeBar` objects have the following attributes:

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