Datasets

Brokerages

Introduction

Instead of using the data from QuantConnect, you can use data from your brokerage.

Supported Datasets

To view the asset classes that are available for your brokerage, follow these steps:

  1. Open the Brokerages page.
  2. Click the name of your brokerage.
  3. In the table of contents, click Asset Classes.

Universe Selection

Universe Selection is available with the brokerage data provider if you download the data from the Dataset Market. The dataset listings show how to download the universe selection data with the CLI. For live trading, you'll need to periodically download the new data from QuantConnect Cloud, which you can automate with Python scripts. For example, the following tutorials explain how to download historical data and download daily updates:

Alternative Data

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

Download

To download brokerage data, open a terminal in your organization workspace and then run lean data download --data-provider-historical <brokerageName> --data-type <data-type> --resolution <resolution> --security-type <security-type> --tickers <tickers> --market <market> --start-date <YYYYMMDD> --end-date <YYYYMMDD> --data-provider-historical <brokerageName> <requiredBrokerageOptions>.

$ lean data download --data-provider-historical "Interactive Brokers" --data-type Quote --resolution Daily --security-type Equity --tickers NVDA,AMD --start-date 20240303 --end-date 20240404 --ib-user-name userName --ib-account account --ib-password password

$ lean data download --data-provider-historical Binance --data-type Trade --resolution Daily --security-type Crypto --tickers BTCUSDT,ETHUSDT --start-date 20240303 --end-date 20240404 --binance-exchange-name Binance binance-api-key apiKey --binance-api-secret apiSecret

To download Coinbase data, include the --market Coinbase option.

$ lean data download --data-provider-historical "Coinbase Advanced Trade" --data-type Trade --resolution hour --security-type Crypto --tickers BTCUSD --market Coinbase --start-date 20230101 --end-date 20240404 --coinbase-api-key apiKey --coinbase-api-secret apiSecret

If you provide your credentials, your Lean configuration file saves them.

Research

To access brokerage data from the local Research Environment, open a terminal in your organization workspace and then run lean research <projectName> --data-provider-historical <brokerageName> <requiredBrokerageOptions>.

$ lean research "My Project" --data-provider-historical "Interactive Brokers" --ib-user-name userName --ib-account account --ib-password password

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 your brokerage, open a terminal in your organization workspace and then run lean backtest <projectName> --data-provider-historical <brokerageName> <requiredBrokerageOptions>.

$ lean backtest "My Project" --data-provider-historical "Interactive Brokers" --ib-user-name userName --ib-account account --ib-password password

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 your brokerage data:

  1. Add some parameters to your project.
  2. Open a terminal in your organization workspace.
  3. Run lean optimize <projectName> --data-provider-historical <brokerageName> <requiredBrokerageOptions>.
  4. $ lean optimize "My Project" --data-provider-historical "Interactive Brokers" --ib-user-name userName --ib-account account --ib-password password
  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 your brokerage 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 your brokerage as the data provider, open a terminal in your organization workspace and then run lean live deploy <projectName> --data-provider-live <dataBrokerageName> <requiredDataBrokerageOptions> --brokerage <brokerageName> <requiredBrokerageOptions>.

$ lean live deploy "My Project" --data-provider-live "Interactive Brokers" --ib-user-name userName --ib-account account --ib-password password --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.

Pricing

To view the prices of your brokerage data, visit their website.

Supported Brokerages

The following table shows the brokerages that provide live (--data-provider-live) and historical (--data-provider-historical) data for research, backtesting, and optimization:

Brokerage NameRequired Options
Interactive Brokers--ib-user-name
--ib-account
--ib-password
Oanda--oanda-account-id
--oanda-access-token
--oanda-environment
Bitfinex--bitfinex-api-key
--bitfinex-api-secret
Coinbase Advanced Trade--coinbase-api-key
--coinbase-api-secret
Binance--binance-exchange-name
--binance-api-key or --binanceus-api-key
--binance-api-secret or --binanceus-api-secret
--binance-use-testnet
Kraken--kraken-api-key
--kraken-api-secret
--kraken-verification-tier
Bybit--bybit-api-key
--bybit-api-secret
--bybit-vip-level

For brokerages that exclusively provide a live data feed, see the lean live deploy reference.

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: