API Reference

lean research


Run a Jupyter Lab environment locally using Docker.

$ lean research [OPTIONS] PROJECT


Runs a local Jupyter Lab environment in a Docker container using the quantconnect/research Docker image. The project directory is mounted in the Docker container and the Jupyter Lab instance is exposed on a local port. After the Jupyter Lab instance has started, the browser automatically opens.

By default, Jupyter Lab is exposed on port 8888. To use a custom port, you can use the --port option, which is required to run two Jupyter Lab instances side-by-side.

You can use the --data-provider-historical option to change where data is retrieved. This option updates the Lean configuration file, so you don't need to use this option multiple times for the same data provider if you are not switching between them. If you use the The following table shows the available data providers and their required options in non-interactive mode:

--data-provider-historicalRequired Options
"Terminal Link"--terminal-link-connection-type
--terminal-link-server-auth-id if you use --terminal-link-connection-type SAPI

You can use the --download-data flag as an alias for --data-provider-historical QuantConnect and the --data-purchase-limit option to set the maximum amount of QuantConnect Credit (QCC) to spend during the research session when using QuantConnect as data provider. The --data-purchase-limit option is not persistent.

If you have previously logged in using lean login, the CLI automatically makes your credentials available in the Jupyter Lab instance. If this happens, the api variable is automatically assigned an instance of Api in your research notebooks, which you can use to make authenticated requests to the QuantConnect API.

The default Research Environment configuration is the latest master branch of LEAN. If you set a different research image, the image you set is your current configuration. To start the Research Environment with a different configuration than your current configuration, use the --image <value> option. If the image doesn't exist on your local machine or you pass the --update flag, the image is pulled before starting the Research Environment. To avoid updating the image, pass the --no-update flag.


The lean research command expects the following arguments:

<project>The path to the project directory for which to run a research environment.


The lean research command supports the following options:

--port <integer>The port to run Jupyter Lab on (defaults to 8888)
--data-provider-historical <enum: Interactive Brokers
                                  Coinbase Advanced Trade
                                  Terminal Link
Update the Lean configuration file to retrieve data from the given historical 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-key <string>Your Coinbase Advanced Trade API key
--coinbase-api-secret <string>Your Coinbase Advanced Trade API secret
--binance-exchange-name <enum: Binance
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
--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
Your Alpha Vantage Premium API Key plan
--coinapi-api-key <string>Your coinapi.io Api Key
--coinapi-product <enum: Free
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
Your ThetaData subscription price plan
--terminal-link-connection-type <enum: DAPI|SAPI>Terminal Link Connection Type [DAPI, SAPI]
--terminal-link-server-auth-id <string>The Auth ID of the TerminalLink server
--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
--bybit-api-key <string>Your Bybit API key
--bybit-api-secret <string>Your Bybit API secret
--bybit-vip-level <enum: VIP0
Your Bybit VIP Level
--download-dataUpdate the Lean configuration file to download data from the QuantConnect API, alias for --data-provider-historical QuantConnect
--data-purchase-limit <integer>The maximum amount of QCC to spend on downloading data during the research session when using QuantConnect as historical data provider
-d, --detachRun Jupyter Lab in a detached Docker container and return immediately
--no-openDon't open the Jupyter Lab environment in the browser after starting it
--image <string>The LEAN research image to use (defaults to quantconnect/research:latest)
--updatePull the LEAN research image before starting the research environment
--extra-docker-config <string>Extra docker configuration as a JSON string. For more information https://docker- py.readthedocs.io/en/stable/containers.html
--no-updateUse the local LEAN research 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 research 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: