QuantConnect

Index Options

Introduction

Download the US Index Options dataset to your local machine. You can download the full dataset in bulk to avoid selection bias or download individual tickers to keep the cost low. The dataset contains trade and quote data for every ticker and trading day.

When you download by ticker, each index option type counts as a separate ticker. For example, standard SPX options and weekly SPXW options are separate tickers.

To use the CLI, you must be a member in an organization on a paid tier.

Prerequisites

The US Index Options dataset depends on the US Index Option Universe dataset because the US Index Option Universe dataset contains information on the available contracts, including their daily Greeks and implied volatility values. Before you download US Index Options data, open the Pricing page of your organization and subscribe to the US Index Option Universe History by QuantConnect data package. You need billing permissions to change the organization's subscriptions.

Download in Bulk

After you subscribe to local access (see Prerequisites), open a terminal in your organization workspace and run the following commands to bulk download the data and its prerequisites.

To download the US Index Option Universe data, run:

$ lean data download --dataset "US Index Option Universe" --data-type "Bulk" --start "20250403" --end "20250403"

To download the US Index Options data for a resolution, run the following command, replacing <resolution> with daily, hour, or minute and adjusting the date range:

$ lean data download --dataset "US Index Options" --data-type "Bulk" --resolution "<resolution>" --start "20230101" --end "20230105"

You can also use the CLI Command Generator. For more information, see Using the CLI.

After you bulk download the US Index Options dataset, new daily updates are available at 8 PM Coordinated Universal Time (UTC) two days after each trading day. Instead of directly calling the lean data download command, you can place a Python script in the data directory of your organization workspace and run it to update your data files. The following example script updates all data resolutions:

import os
import pandas as pd
from datetime import datetime, time, timedelta
from pytz import timezone
from os.path import abspath, dirname
os.chdir(dirname(abspath(__file__)))

OVERWRITE = False

# Define a method to download the data
def __download_data(resolution, start=None, end=None):
    print(f"Updating {resolution} data...")
    command = f'lean data download --dataset "US Index Options" --data-type "Bulk"  --resolution "{resolution}"'
    if start:
        end = end if end else start
        command += f" --start {start} --end {end}"
    if OVERWRITE:
        command += " --overwrite"
    print(command)
    os.system(command)

def __get_end_date() -> str:
    now = datetime.now(timezone("US/Eastern"))
    if now.time() > time(7,30):
        return (now - timedelta(1)).strftime("%Y%m%d")
    print('New data is available at 07:30 AM EST')
    return (now - timedelta(2)).strftime("%Y%m%d")

def __download_high_frequency_data(latest_on_cloud):
    for resolution in ["minute"]:
        dir_name = f"indexoption/usa/{resolution}/spx".lower()
        if not os.path.exists(dir_name):
            __download_data(resolution, '19980101')
            continue
        latest_on_disk = sorted(os.listdir(dir_name))[-1].split('_')[0]
        if latest_on_disk >= latest_on_cloud:
            print(f"{resolution} data is already up to date.")
            continue
        __download_data(resolution, latest_on_disk, latest_on_cloud)

def __download_low_frequency_data(latest_on_cloud):
    for resolution in ["daily", "hour"]:
        file_name = f"indexoption/usa/{resolution}/spx.zip".lower()
        if not os.path.exists(file_name):
            __download_data(resolution)
            continue
        latest_on_disk = str(pd.read_csv(file_name, header=None)[0].iloc[-1])[:8]
        if latest_on_disk >= latest_on_cloud:
            print(f"{resolution} data is already up to date.")
            continue
        __download_data(resolution)

if __name__ == "__main__":
    latest_on_cloud = __get_end_date()
    __download_low_frequency_data(latest_on_cloud)
    __download_high_frequency_data(latest_on_cloud)

The preceding script checks the date of the most recent minute resolution data you have for SPX. If there is new minute data available, it downloads the new data files and overwrites your hourly and daily files. If you don't intend to download all resolutions, adjust this script to your needs.

To update your local copy of the US Index Option Universe data, run the following command, or use the universe auto-update script below:

$ lean data download --dataset "US Index Option Universe" --data-type "Bulk" --start "20250403" --end "20250403"
import os
from datetime import datetime, time, timedelta
from pytz import timezone
from os.path import abspath, dirname
os.chdir(dirname(abspath(__file__)))

OVERWRITE = False

def __get_start_date() -> str:
    dir_name = f"indexoption/usa/universes"
    files = [] if not os.path.exists(dir_name) else sorted(os.listdir(dir_name)) 
    return files[-1].split(".")[0] if files else '19980101'

def __get_end_date() -> str:
    now = datetime.now(timezone("US/Eastern"))
    if now.time() > time(7, 0):
        return (now - timedelta(1)).strftime("%Y%m%d")
    print('New data is available at 07:00 AM EST')
    return (now - timedelta(2)).strftime("%Y%m%d")

if __name__ == "__main__":
    start, end = __get_start_date(), __get_end_date()
    if start >= end:
        exit("Your data is already up to date.")
            
    command = f'lean data download --dataset "US Index Option Universe" --data-type "Bulk" --start {start} --end {end}'
    if OVERWRITE:
        command += " --overwrite"
    print(command)
    os.system(command)

Download by Ticker

To download data for selected tickers instead of the full dataset, run a non-interactive lean data download command. First, download the US Index Option Universe data for the ticker to get the available contracts:

$ lean data download --dataset "US Index Option Universe" --data-type "Trade" --ticker "SPXW" --start "20250630" --end "20260630"

Then download the US Index Options data for the tickers, resolution, and date range you need. The dataset provides trade, quote, and open interest data, so run a command for each data type you need. For example, to download minute-resolution data for SPXW:

$ lean data download --dataset "US Index Options" --data-type "Trade" --ticker "SPXW" --resolution "Minute" --start "20230101" --end "20230105"
$ lean data download --dataset "US Index Options" --data-type "Quote" --ticker "SPXW" --resolution "Minute" --start "20230101" --end "20230105"
$ lean data download --dataset "US Index Options" --data-type "Open Interest" --ticker "SPXW" --resolution "Minute" --start "20230101" --end "20230105"

To download data interactively or to use the CLI Command Generator, see Using the CLI.

Size and Format

The following table shows the size of the US Index Options dataset for each resolution:

ResolutionSizeFormat
Daily5 GB3 files per contract
Hour40 GB3 files per contract
Minute500 GB3 files per contract per day

For examples, see the Data / indexoption / usa / daily directory in the LEAN repository.

Price

Download in Bulk

To download the US Index Options dataset in bulk, subscribe to it on the Pricing page of your organization. The price depends on your organization tier and the resolution you need. The bulk download also requires the US Index Option Universe subscription. The following table shows the price ($/year) to download the historical data of each resolution for each organization tier:

ResolutionQuant ResearcherTeamTrading FirmInstitution
Minute30,00033,60040,80064,800
Hour14,40021,00026,40034,800
Daily12,00015,60018,00021,000

After the first bulk subscription ends, subscribe to the updates to keep your local data current. The following table shows the price ($/year) of the updates of each resolution for each organization tier:

ResolutionQuant ResearcherTeamTrading FirmInstitution
Minute1,2001,6802,1602,880
Hour1,4401,4401,9202,640
Daily7209601,4401,920

The following table shows the annual price ($/year) of the US Index Option Universe historical and updates subscriptions for each organization tier:

TierHistoricalUpdates
Quant Researcher1,200960
Team1,9201,200
Trading Firm2,8801,440
Institution3,9601,680

The following table shows the total cost of downloading the required datasets in bulk at minute resolution on the Quant Researcher tier. Other organization tiers apply their own rates, shown in the preceding tables.

DatasetPackageHistoricalUpdates
US Index Option UniverseSubscription$1,200$960/year
US Index OptionsMinute$30,000$1,200/year
Total$31,200$2,160/year

Download by Ticker

The file format of the US Index Option Universe data is one file per underlying Index and each file costs 100 QCC = $1 USD. The US Index Options dataset is available in several resolutions. The resolution you need depends on the US Index Option subscriptions you create in your algorithm and the resolution of data you get in history requests. The following table describes the file format and costs of each resolution:

ResolutionFile FormatCost per file
MinuteOne file per ticker per trading day per data format. Trade, quote, and open interest data are separate files.15 QCC = $0.15 USD
HourOne file per ticker per data format. Trade, quote, and open interest data are separate files.900 QCC = $9 USD
DailyOne file per ticker per data format. Trade, quote, and open interest data are separate files.300 QCC = $3 USD

For example, the following algorithm subscribes to minute resolution data for a universe of SPXW Index Option contracts:

public class USIndexOptionsDataAlgorithm : QCAlgorithm
{
    public override void Initialize()
    {
        SetStartDate(2020, 1, 1);
        SetEndDate(2021, 1, 1);
        AddIndexOption("SPX", "SPXW");
    }
}
class USIndexOptionsDataAlgorithm(QCAlgorithm):
    def initialize(self):
        self.set_start_date(2020, 1, 1)
        self.set_end_date(2021, 1, 1)
        self.add_index_option("SPX", "SPXW")

The following table shows the data cost of the preceding algorithm:

DatasetPackageInitial CostOngoing Cost
US Index Option UniverseDownload On Premise 1 underlying Index over 252 trading days
=> 1 * 252 files
= 252 files

252 files @ 100 QCC/file
=> 252 * 100 QCC
= 25,200 QCC
= $252 USD
1 underlying Index
=> 1 file/day

1 file/day @ 100 QCC/file
=> 100 QCC/day
= $1 USD/day
US Index OptionsMinute Download 1 ticker over 252 trading days with 3 data formats
=> 1 * 252 * 3 files
= 756 files

756 files @ 15 QCC/file
=> 756 * 15 QCC
= 11,340 QCC
= $113.40 USD
1 ticker with 3 data formats
=> 3 files/day

3 files/day @ 15 QCC/file
=> 45 QCC/day
= $0.45 USD/day

The preceding table assumes you download trade, quote, and open interest data. However, you can run backtests with only trade data.

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: