---
title: "Requesting Data"
description: "Request Index data in your algorithm to receive a feed of Index prices in the OnData method."
canonical: https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes/index/requesting-data
markdown: https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes/index/requesting-data.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/03%20Writing%20Algorithms/03%20Securities/99%20Asset%20Classes/08%20Index/01%20Requesting%20Data
modified: 2026-10-30
index: https://www.quantconnect.com/llms.txt
---

# Requesting Data

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Writing Algorithms](https://www.quantconnect.com/docs/v2/writing-algorithms.md) > Securities > [Asset Classes](https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes.md) > [Index](https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes/index.md) > Requesting Data

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

## Introduction

Request Index data in your algorithm to receive a feed of Index prices in the `on_data` method. For more information about the specific dataset we use for backtests, see the [US Cash Indices dataset listing](https://www.quantconnect.com/datasets/tickdata-us-cash-indices). To trade live with Index data, you can use one of the [brokerage data providers](https://www.quantconnect.com/docs/v2/cloud-platform/datasets.md).

## Create Subscriptions

To create an Index subscription, in the `initialize` method, call the `add_index` method. The `add_index` method returns an `Index` object, which contains a `symbol` property. Save a reference to the `symbol` so you can use it in `on_data` to access the security data in the `Slice`.

```python
self._symbol = self.add_index("VIX").symbol
```

To view the supported assets in the US Cash Indices dataset, see the [Supported Indices](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quantconnect/cash-indices.md#10-Supported-Indices).

## Resolutions

The following table shows the available resolutions and data formats for Index subscriptions:

| Resolution | TradeBar | QuoteBar | Trade Tick | Quote Tick |
| --- | --- | --- | --- | --- |
| `TICK` | Not supported | Not supported | Not supported | Not supported |
| `SECOND` | Supported for SPX, NDX, and VIX only⚠︎ | Not supported | Not supported | Not supported |
| `MINUTE` | Supported✓ | Not supported | Not supported | Not supported |
| `HOUR` | Supported✓ | Not supported | Not supported | Not supported |
| `DAILY` | Supported✓ | Not supported | Not supported | Not supported |

⚠︎ Supported for SPX, NDX, and VIX only.

The default resolution for Index subscriptions is `Resolution.MINUTE`. To change the resolution, pass a `resolution` argument to the `add_index` method.

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

To create custom resolution periods, see [Consolidating Data](https://www.quantconnect.com/docs/v2/writing-algorithms/consolidating-data/getting-started.md).

## Supported Markets

The only market available for Indices is `Market.USA`, so you don't need to pass a `market` argument to the `add_index` method.

```python
self._symbol = self.add_index("VIX", market=Market.USA).symbol
```

The [brokerage models](https://www.quantconnect.com/docs/v2/writing-algorithms/reality-modeling/brokerages/key-concepts.md) have a default market for each asset class. If you set a brokerage model, you may not need to specify the market to use.

## Fill Forward

Fill forward means if there is no data point for the current [slice](https://www.quantconnect.com/docs/v2/writing-algorithms/key-concepts/time-modeling/timeslices.md), LEAN uses the previous data point. Fill forward is the default data setting. If you disable fill forward, you may get [stale fills](https://www.quantconnect.com/docs/v2/writing-algorithms/reality-modeling/trade-fills/key-concepts.md#06-Stale-Fills) or you may see trade volume as zero.

To disable fill forward for a security, set the `fill_forward` argument to false when you create the security subscription.

```python
self._symbol = self.add_index("VIX", fill_forward=False).symbol
```

## Data Normalization

The data normalization mode doesn't affect the data that LEAN passes to `on_data` or the data from [history request](https://www.quantconnect.com/docs/v2/writing-algorithms/historical-data/history-requests.md). If you change the data normalization mode, it won't change the outcome.

## Properties

The `add_index` method returns an `Index` object, which have the following properties:

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

## Examples

The following examples demonstrate some common practices for requesting Index data.

### Example 1: VIX EMA Cross

The following algorithm adds daily VIX Index data and uses the [Exponential Moving Average (EMA)](https://www.quantconnect.com/docs/v2/writing-algorithms/indicators/supported-indicators/exponential-moving-average.md) indicator to create trading signals. The algorithm uses a 30-day slow EMA and a 15-day fast EMA. It enters a long SPY position when the fast EMA crosses above the slow EMA and liquidates the position when the fast EMA crosses below the slow EMA.

```python
class IndexDemoAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        # Add the daily VIX and SPY data.
        self._vix = self.add_index("VIX", Resolution.DAILY).symbol
        self._spy = self.add_equity("SPY", Resolution.DAILY).symbol
        # Create the fast and slow EMA indicators.
        self._ema_fast = self.ema(self._vix, 15)
        self._ema_slow = self.ema(self._vix, 30)
        # Define a small tolerance to reduce trading churn.
        self._tolerance = 0.00015

    def on_data(self, slice: Slice) -> None:
        # Check if the indicators are ready.
        if not self._ema_slow.is_ready:
            return
        # When the fast VIX EMA crosses above the slow EMA, buy SPY.
        if (not self.portfolio.invested and
            self._ema_fast.current.value > self._ema_slow.current.value * (1 + self._tolerance)):
            self.set_holdings(self._spy, 0.8)
        # When the fast VIX EMA crosses below the slow EMA, liquidate the position.
        elif (self.portfolio.invested and
            self._ema_fast.current.value < self._ema_slow.current.value * (1 - self._tolerance)):
            self.liquidate(self._spy)
```
