Datasets
Theta Data
Introduction
Instead of using the data from QuantConnect or your brokerage, you can use Theta Data if you're deploying a local project. To use Theta Data, you need to install and launch the Theta Terminal.
To view the implementation of the Theta Data integration, see the Lean.DataSource.ThetaData repository.
Download
To download Theta Data data, open a terminal in your organization workspace and then run 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>
.
$ 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 lean research <projectName> --data-provider-historical ThetaData --thetadata-subscription-plan <plan>
.
$ 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 lean backtest <projectName> --data-provider-historical ThetaData --thetadata-subscription-plan <plan>
.
$ 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:
- Add some parameters to your project.
- Open a terminal in your organization workspace.
- Run
lean optimize <projectName> --data-provider-historical ThetaData --thetadata-subscription-plan <plan>
. - Follow the steps in the interactive wizard to configure your optimization job settings.
$ lean optimize "My Project" --data-provider-historical ThetaData --thetadata-subscription-plan Standard
The --thetadata-subscription-plan
option must be Free
, Value
, Standard
, or Pro
.
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 lean live deploy <projectName> --data-provider-live ThetaData --thetadata-subscription-plan <plan> --brokerage <brokerageName> <requiredBrokerageOptions>
.
$ 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 lean live deploy <projectName> --brokerage <brokerageName>
to deploy another live algorithm with the same options.
Pricing
To view the prices of the Theta Data API packages, see the Pricing page on the Theta Data website.