Index

Requesting Data

Introduction

Request Index data in your algorithm to receive a feed of Index prices in the OnData method. For more information about the specific dataset we use for backtests, see the US Cash Indices dataset listing. To trade live with Index data, you can use one of the brokerage data providers.

Create Subscriptions

To create an Index subscription, in the Initialize method, call the AddIndex method. The AddIndex method returns an Index object, which contains a Symbol. Save a reference to the Symbol so you can use it in OnData to access the Index data in the Slice.

_symbol = AddIndex("VIX").Symbol;
self.symbol = self.AddIndex("VIX").Symbol

To view the supported assets in the US Cash Indices dataset, see the Supported Indices.

Resolutions

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

ResolutionTradeBarQuoteBarTrade TickQuote Tick
Tickgreen check
Secondgreen check
Minutegreen check
Hourgreen check
Dailygreen check

The default resolution for Index subscriptions is Resolution.Minute. To change the resolution, pass a resolution argument to the AddIndex method.

_symbol = AddIndex("VIX", Resolution.Daily).Symbol;
self.symbol = self.AddIndex("VIX", Resolution.Daily).Symbol

To create custom resolution periods, see Consolidating Data.

Supported Markets

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

_symbol = AddIndex("VIX", market: Market.USA).Symbol;
self.symbol = self.AddIndex("VIX", market=Market.USA).Symbol

The brokerage models 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, LEAN uses the previous data point. Fill forward is the default data setting. If you disable fill forward, you may get stale fills or you may see trade volume as zero.

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

_symbol = AddIndex("VIX", fillForward: false).Symbol;
self.symbol = self.AddIndex("VIX", fillForward=False).Symbol

Data Normalization

The data normalization mode doesn't affect the data that LEAN passes to OnData or the data from history request. If you change the data normalization mode, it won't change the outcome.

Properties

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

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: