Securities

Requesting Data

Introduction

If you create a data subscription, your algorithm receives data updates for that security or custom data source.

Characteristics

We thoroughly vet datasets before we add them to the Data Market. The datasets in the Data Market are well-defined with robust ticker and Symbol links to ensure tickers are properly tracked through time. The datasets are consistently delivered on time and most of them are ready for live trading. All the datasets have at least one year of historical data and are free of survivorship bias.

Resolutions

Resolution is the duration of time that's used to sample a data source. The Resolution enumeration has the following members:

The default resolution for market data is Minute. To set the resolution for a security, pass the resolution argument when you create the security subscription.

AddEquity("SPY", Resolution.Daily);
self.AddEquity("SPY", Resolution.Daily)

To set the resolution for all securities, set the Resolution universe setting before you create security subscriptions.

UniverseSettings.Resolution = Resolution.Daily;
self.UniverseSettings.Resolution = Resolution.Daily

To see which resolutions of data are available for a dataset, see the dataset listing in the Data Market. To create custom resolution periods, see Consolidating Data.

Data density describes the frequency of entries in a dataset. Datasets at the tick resolution have dense data density. All other resolutions usually have regular data density. If a non-tick resolution dataset doesn’t have an entry at each sampling, it has sparse density.

Markets

The datasets integrated into the Dataset Market cover many markets. The Market enumeration has the following members:

LEAN can usually determine the correct market based on the ticker you provide when you create the security subscription. To manually set the market for a security, pass a market argument when you create the security subscription.

AddEquity("SPY", market: Market.USA);
self.AddEquity("SPY", market=Market.USA)

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 fillDataForward argument to false when you create the security subscription.

AddEquity("SPY", fillDataForward: false);
self.AddEquity("SPY", fillDataForward=False)

Extended Market Hours

By default, your security subscriptions only cover regular trading hours. To subscribe to pre- and post-market trading hours for a specific asset, enable the extendedMarketHours argument when you create the security subscription.

AddEquity("SPY", extendedMarketHours: true);
self.AddEquity("SPY", extendedMarketHours=True)

You only receive extended market hours data if you create the subscription with an intraday resolution. If you create the subscription with daily resolution, the daily bars only reflect the regular trading hours.

Remove Subscriptions

To remove a security subscription, call the RemoveSecurity method.

RemoveSecurity(_symbol);
self.RemoveSecurity(self.symbol)

The RemoveSecurity method cancels your open orders for the security and liquidates your holdings.

Quotas

There is no limit to the number of security subscriptions you can create, but some live data providers impose data subscription limits. To set a limit, in the Initialize method, set the DataSubscriptionLimit algorithm setting.

Settings.DataSubscriptionLimit = 500;
self.Settings.DataSubscriptionLimit = 500

All securities that you add to the algorithm count as one subscription, except Options and Futures. Every Option and Future contract counts as one subscription.

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: