API Reference

lean data download

Introduction

Purchase and download data directly from QuantConnect or download from Support Data Providers

$ lean data download [OPTIONS]

Description

Lets you purchase and download historical data from the QuantConnect Dataset Market, a brokerage, or a third-party data provider.

Download from QuantConnect

When you download data from the QuantConnect Dataset Market, this command performs the following actions:

  1. An interactive wizard is shown allowing you to configure exactly which data you want to download.
  2. You are asked to accept the CLI API Access and Data Agreement in your web browser.
  3. You are asked to confirm the purchase one last time.
  4. The CLI downloads the requested files while charging the organization that's linked to your current organization workspace.

Data from the Dataset Market is priced on a per-file per-download basis, meaning you pay a certain number of QuantConnect Credits (QCC) for each file you download. The required QCC is deducted from your organization's QCC balance when a file is downloaded. If you force-quit the command before it downloaded all requested files, you are not charged for the files you didn't download.

When --dataset is given, the command runs in non-interactive mode and several steps in the preceding list are skipped. Instead, the command reads the downloading configuration from the given command-line options. In this mode, the --dataset option is required, as well as all options specific to the selected dataset.

Example non-interactive usage:

$ lean data download \
    --dataset "Bitfinex Crypto Price Data" \
    --data-type "Trade" \
    --ticker "BTCUSDT" \
    --resolution "Daily" \
    --start "20201208" \
    --end "20221208" 

In case the local data already exists, a warning is logged and you are given the choice of whether you want to enable overwriting existing data or not. Use the --overwrite flag to override this behavior and enable overwriting existing data in all such cases.

To automatically confirm payment confirmation prompts, use the --yes flag.

Download from Brokerages and Third-Party Providers

To download data from a brokerage or third-party data provider, run this command and follow the prompts to select the data you need. To view all the available data providers, see the --data-provider-historical option description. After you know what options you need to provide to download data from your specific brokerage or third-party data provider, you can run the command in a script to automate the process of downloading new data.

Options

The lean data download command supports the following options:

OptionDescription
--data-provider-historical <enum: Interactive Brokers
                                  Oanda
                                  Bitfinex
                                  Coinbase Advanced Trade
                                  Binance
                                  Kraken
                                  IQFeed
                                  Polygon
                                  FactSet
                                  IEX
                                  AlphaVantage
                                  CoinApi
                                  ThetaData
                                  QuantConnect
                                  Local
                                  Terminal Link
                                  Bybit
                                  TradeStation
                                  Alpaca>
The name of the downloader data provider
--ib-user-name <string>Your Interactive Brokers username
--ib-account <string>Your Interactive Brokers account id
--ib-password <string>Your Interactive Brokers password
--ib-weekly-restart-utc-time <string>Weekly restart UTC time (hh:mm:ss). Each week on Sunday your algorithm is restarted at this time, and will require 2FA verification. This is required by Interactive Brokers. Use this option explicitly to override the default value. (Optional)
--oanda-account-id <string>Your OANDA account id
--oanda-access-token <string>Your OANDA API token
--oanda-environment <enum: Practice|Trade>The environment to run in, Practice for fxTrade Practice, Trade for fxTrade
--bitfinex-api-key <string>Your Bitfinex API key
--bitfinex-api-secret <string>Your Bitfinex API secret
--coinbase-api-name <string>Your Coinbase Advanced Trade API name from file
--coinbase-api-private-key <string>Your Coinbase Advanced Trade API private key from file
--binance-exchange-name <enum: Binance
                               BinanceUS
                               Binance-USDM-Futures
                               Binance-COIN-Futures>
Binance exchange name [Binance, BinanceUS, Binance-USDM-Futures, Binance-COIN-Futures]
--binance-api-key <string>Your Binance API key
--binanceus-api-key <string>Your Binance API key
--binance-api-secret <string>Your Binance API secret
--binanceus-api-secret <string>Your Binance API secret
--kraken-api-key <string>Your Kraken API key
--kraken-api-secret <string>Your Kraken API secret
--kraken-verification-tier <enum: Starter|Intermediate|Pro>Your Kraken Verification Tier
--iqfeed-iqconnect <string>The path to the IQConnect binary
--iqfeed-username <string>Your IQFeed username
--iqfeed-password <string>Your IQFeed password
--iqfeed-version <string>The product version of your IQFeed developer account
--iqfeed-host <string>The IQFeed host address (Optional)
--polygon-api-key <string>Your Polygon.io API Key
--factset-auth-config-file <file>The path to the FactSet authentication configuration file
--iex-cloud-api-key <string>Your iexcloud.io API token publishable key
--iex-price-plan <enum: Launch|Grow|Enterprise>Your IEX Cloud Price plan
--alpha-vantage-api-key <string>Your Alpha Vantage Api Key
--alpha-vantage-price-plan <enum: Free
                                  Plan30
                                  Plan75
                                  Plan150
                                  Plan300
                                  Plan600
                                  Plan1200>
Your Alpha Vantage Premium API Key plan
--coinapi-api-key <string>Your coinapi.io Api Key
--coinapi-product <enum: Free
                         Startup
                         Streamer
                         Professional
                         Enterprise>
CoinApi pricing plan (https://www.coinapi.io/market-data-api/pricing)
--thetadata-ws-url <string>The ThetaData host address (Optional)
--thetadata-rest-url <string>The ThetaData host address (Optional)
--thetadata-subscription-plan <enum: Free
                                     Value
                                     Standard
                                     Pro>
Your ThetaData subscription price plan
--terminal-link-connection-type <enum: DAPI|SAPI>Terminal Link Connection Type [DAPI, SAPI]
--terminal-link-environment <enum: Production|Beta>The environment to run in
--terminal-link-server-host <string>The host of the TerminalLink server
--terminal-link-server-port <integer>The port of the TerminalLink server
--terminal-link-openfigi-api-key <string>The Open FIGI API key to use for mapping options
--terminal-link-server-auth-id <string>The Auth ID of the TerminalLink server
--bybit-api-key <string>Your Bybit API key
--bybit-api-secret <string>Your Bybit API secret
--trade-station-environment <enum: live|paper>Whether Live or Paper environment should be used
--trade-station-account-id <string>The TradeStation account Id
--alpaca-environment <enum: live|paper>Whether Live or Paper environment should be used
--dataset <string>The name of the dataset to download non-interactively
--overwriteOverwrite existing local data
-y, --yesAutomatically confirm payment confirmation prompts
--data-type <enum: Trade
                   Quote
                   Bulk
                   OpenInterest>
Specify the type of historical data
--resolution <enum: Tick
                    Second
                    Minute
                    Hour
                    Daily>
Specify the resolution of the historical data
--security-type <enum: Equity
                       Index
                       Forex
                       Cfd
                       Future
                       Crypto
                       CryptoFuture
                       Option
                       IndexOption
                       Commodity
                       FutureOption>
Specify the security type of the historical data
--market <string>Specify the market name for tickers (e.g., 'USA', 'NYMEX', 'Binance') (if not provided or empty the default market for the requested security type will be used)
--ticker <string>Specify comma separated list of tickers to use for historical data request
--start <string>Specify the start date for the historical data request in the format yyyyMMdd
--end <string>Specify the end date for the historical data request in the format yyyyMMdd. (defaults to today)
--image <string>The LEAN engine image to use (defaults to quantconnect/lean:latest)
--updatePull the LEAN engine image before running the Downloader Data Provider
--no-updateUse the local LEAN engine image instead of pulling the latest version
--lean-config <file>The Lean configuration file that should be used (defaults to the nearest lean.json)
--verboseEnable debug logging
--helpDisplay the help text of the lean data download command and exit

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: