Skip to content

You can now use Theta Data in your local QuantConnect project. To view QuantConnect's Theta Data integration, see the Lean.DataSource.ThetaData repository.

REQUIRED

The Theta Terminal must be running to access data.

Supported Datasets

The QuantConnect integration supports securities from the following asset classes:

  • Equity
  • Equity Options
  • Index
  • Index Options

Alternative Data

If you have licensed alternative data with QuantConnect, it works as expected with the Theta Data data provider for research, backtesting, and live trading.

Download

To download Theta Data data, open a terminal in your organization workspace and then run

shell
lean data download --data-provider-historical ThetaData --data-type [data-type] --resolution [resolution] --security-type [security-type] --ticker [tickers] --start [YYYYMMDD] --end [YYYYMMDD] --thetadata-subscription-plan [plan]

For example:

shell
lean data download --data-provider-historical ThetaData --data-type Trade --resolution Daily --security-type Option --ticker NVDA,AMD --start 20240303 --end 20240404 --thetadata-subscription-plan Standard

The --thetadata-subscription-plan option must be Free, Value, Standard, or Pro. If you provide your credentials, your Lean configuration file saves them.

Research

To access Theta Data data from the local Research Environment, open a terminal in your organization workspace and then run

shell
lean research [projectName] --data-provider-historical ThetaData --thetadata-subscription-plan [plan]

For example:

shell
$ lean research "My Project" --data-provider-historical ThetaData --thetadata-subscription-plan Standard

The --thetadata-subscription-plan option must be Free, Value, Standard, or Pro. If you provide any of the preceding options, your Lean configuration file saves them so that you only need to run lean research [projectName] to open the Research Environment with the same options.

Backtesting

To run a local backtest with data from Theta Data, open a terminal in your organization workspace and then run

shell
lean backtest [projectName] --data-provider-historical ThetaData --thetadata-subscription-plan [plan]

For example:

shell
$ lean backtest "My Project" --data-provider-historical ThetaData --thetadata-subscription-plan Standard

The --thetadata-subscription-plan option must be Free, Value, Standard, or Pro. If you provide any of the preceding options, your Lean configuration file saves them so that you only need to run lean backtest [projectName] to run another backtest with the same options.

Optimization

Follow these steps to run a local optimization job with data from Theta Data:

  1. Add some parameters to your project.

  2. Open a terminal in your organization workspace.

  3. Run lean optimize [projectName] --data-provider-historical ThetaData --thetadata-subscription-plan [plan]

shell
$ lean optimize "My Project" --data-provider-historical ThetaData --thetadata-subscription-plan Standard

The --thetadata-subscription-plan option must be Free, Value, Standard, or Pro.

  1. Follow the steps in the interactive wizard to configure your optimization job settings.

The lean optimize command also accepts additional options so that you can select Theta Data and run the command in non-interactive mode. If you provide any of the preceding options, your Lean configuration file saves them so that you only need to run lean optimize [projectName] to run another optimization job with the same options.

Live Trading

To deploy a local live algorithm that uses Theta Data as the data provider, open a terminal in your organization workspace and then run:

shell
lean live deploy [projectName] --data-provider-live ThetaData --thetadata-subscription-plan [plan] --brokerage [brokerageName] [requiredBrokerageOptions]
shell
$ lean live deploy "My Project" --data-provider-live ThetaData --thetadata-subscription-plan Standard --brokerage "Paper Trading"

The --thetadata-subscription-plan option must be Free, Value, Standard, or Pro. Depending on the brokerage you select, you may need to provide some required brokerage options. To use a different provider for historical data, include the --data-provider-historical option. If you provide any of the preceding options, your Lean configuration file saves them so that you only need to run:

shell
lean live deploy [projectName] --brokerage [brokerageName]

to deploy another live algorithm with the same options.