Datasets

Polygon

Introduction

Instead of using the data from QuantConnect or your brokerage, you can use data from Polygon if you're deploying a local project and have an API key. To get an API key, see the API Keys page on the Polygon website

To view the implementation of the Polygon integration, see the Lean.DataSource.Polygon repository.

Backtesting

To run a local backtest with Polygon data, open a terminal in your organization workspace and then run lean backtest <projectName> --data-provider-historical Polygon --polygon-api-key <apiKey>.

$ lean backtest "My Project" --data-provider-historical Polygon --polygon-api-key apiKey

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.

Research

To access Polygon data from the local Research Environment, open a terminal in your organization workspace and then run lean research <projectName> --data-provider-historical Polygon --polygon-api-key <apiKey>.

$ lean research "My Project" --data-provider-historical Polygon --polygon-api-key apiKey

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.

Optimization

Follow these steps to run a local optimization job with Polygon data:

  1. Add some parameters to your project.
  2. Open a terminal in your organization workspace.
  3. Run lean optimize <projectName> --data-provider-historical Polygon --polygon-api-key <apiKey>.
  4. $ lean optimize "My Project" --data-provider-historical Polygon --polygon-api-key apiKey
  5. 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 Polgyon 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 Polygon as the data provider, open a terminal in your organization workspace and then run lean live deploy <projectName> --data-provider-live Polygon --polygon-api-key <apiKey> --brokerage <brokerageName> <requiredBrokerageOptions>.

$ lean live deploy "My Project" --data-provider-live Polygon --polygon-api-key apiKey --brokerage "Paper Trading"

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.

Supported Assets

Our Polygon integration supports securities from the following asset classes:

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: