API Reference

lean cloud live deploy

Introduction

Start live trading for a project in the cloud.

$ lean cloud live deploy [OPTIONS] PROJECT

Description

Starts live trading for a cloud project. Before starting live trading, the CLI shows an interactive wizard letting you configure the brokerage, data provider, live node, and notifications. After starting live trading, the CLI displays a URL to the live results. You can use the --open flag to automatically open this URL in the browser once the deployment starts.

If you specify the --brokerage and --data-provider-live options, the interactive wizard is skipped and the command runs in non-interactive mode. In this mode, the command doesn't prompt for input or confirmation and reads all configuration from the provided command-line options. In non-interactive mode, all options specific to the selected brokerage become required, as well as --node, --auto-restart, --notify-order-events, and --notify-insights. In case a required option has not been provided, the command falls back to the property with the same name in your Lean configuration file. The command aborts if this property also hasn't been set.

The following options are required for each brokerage in non-interactive mode:

--brokerageRequired Options
"Paper Trading"N/A
Alpaca--alpaca-environment
--alpaca-api-key
--alpaca-api-secret
Binance--binance-exchange-name
--binance-api-key or --binanceus-api-key
--binance-api-secret or --binanceus-api-secret
--binance-use-testnet
Bitfinex--bitfinex-api-key
--bitfinex-api-secret
Bybit--bybit-api-key
--bybit-api-secret
--bybit-vip-level
"Coinbase Advanced Trade"--coinbase-api-name
--coinbase-api-private-key
"Interactive Brokers"--ib-user-name
--ib-account
--ib-password
Kraken--kraken-api-key
--kraken-api-secret
--kraken-verification-tier
Oanda--oanda-account-id
--oanda-access-token
--oanda-environment
Samco--samco-client-id
--samco-client-password
--samco-year-of-birth
--samco-product-type
--samco-trading-segment
TDAmeritrade--tdameritrade-api-key
--tdameritrade-access-token
--tdameritrade-account-number
"Terminal Link"--terminal-link-server-auth-id
--terminal-link-environment
--terminal-link-server-host
--terminal-link-server-port
--terminal-link-emsx-account
--terminal-link-emsx-broker
--terminal-link-openfigi-api-key
TradeStation--trade-station-environment
--trade-station-account-type
Tradier--tradier-account-id
--tradier-access-token
--tradier-environment
"Trading Technologies"--tt-user-name
--tt-session-password
--tt-account-name
--tt-rest-app-key
--tt-rest-app-secret
--tt-rest-environment
--tt-order-routing-sender-comp-id
Zerodha--zerodha-api-key
--zerodha-access-token
--zerodha-product-type
--zerodha-trading-segment
--zerodha-history-subscription

The --data-provider-live option is required. The following table shows the available live data providers and their required options in non-interactive mode. To select multiple data providers, seperate them with a comma. The order you select them in defines the order of precedence.

--data-provider-liveRequired Options
AlpacaAll options required by --brokerage Alpaca.
Binance--binance-exchange-name
--binance-api-key or --binanceus-api-key
--binance-api-secret or --binanceus-api-secret
BitfinexAll options required by --brokerage Bitfinex.
BybitAll options required by --brokerage Bybit.
CoinApi--coinapi-api-key
--coinapi-product
"Coinbase Advanced Trade"--coinbase-api-name
--coinbase-api-private-key
IEX--iex-cloud-api-key
--iex-price-plan
"Interactive Brokers"All options required by --brokerage "Interactive Brokers".
KrakenAll options required by --brokerage Kraken.
Oanda--oanda-account-id
--oanda-access-token
Polygon--polygon-api-key
QuantConnectN/A
SamcoAll options required by --brokerage Samco.
TDAmeritradeAll options required by --brokerage TDAmeritrade.
"Terminal Link"All options required by --brokerage "Terminal Link".
TradeStationAll options required by --brokerage TradeStation.
Tradier--tradier-account-id
--tradier-access-token
"Trading Technologies"--tt-user-name
--tt-session-password
--tt-account-name
--tt-rest-app-key
--tt-rest-app-secret
--tt-rest-environment
--tt-order-routing-sender-comp-id
ZerodhaAll options required by --brokerage Zerodha.
--zerodha-history-subscription

If you omit some of the required options when running in non-interactive mode, the CLI uses the option values in your LEAN configuration file.

Example non-interactive usage:

$ lean cloud live deploy "My Project" \
    --brokerage "Paper Trading" \
    --data-provider-live QuantConnect \
    --node "My Node" \
    --auto-restart yes
    --notify-order-events no \
    --notify-insights no \
    --push \
    --open

If you have a local copy of the cloud project, you can use the --push option to push local modifications to the cloud before starting live trading.

Arguments

The lean cloud live deploy command expects the following arguments:

ArgumentDescription
<project>The name or Id of the project to start live trading.

Options

The lean cloud live deploy command supports the following options:

OptionDescription
--brokerage <enum: Paper Trading
                   Interactive Brokers
                   Tradier
                   Oanda
                   Bitfinex
                   Coinbase Advanced Trade
                   Binance
                   Zerodha
                   Samco
                   Terminal Link
                   Trading Technologies
                   Kraken
                   TDAmeritrade
                   Bybit
                   TradeStation
                   Alpaca>
The brokerage to use
--data-provider-live <enum: QuantConnect
                            Interactive Brokers
                            Tradier
                            Oanda
                            Bitfinex
                            Coinbase Advanced Trade
                            Binance
                            Zerodha
                            Samco
                            Terminal Link
                            Trading Technologies
                            Kraken
                            TDAmeritrade
                            Polygon
                            IEX
                            CoinApi
                            Bybit
                            TradeStation
                            Alpaca>
The live data provider to use
--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)
--tradier-account-id <string>Your Tradier account id
--tradier-access-token <string>Your Tradier access token
--tradier-environment <enum: live|paper>Whether the developer sandbox should be used
--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
--binance-use-testnet <enum: live|paper>Whether the testnet should be used
--zerodha-api-key <string>Your Kite Connect API key
--zerodha-access-token <string>Your Kite Connect access token
--zerodha-product-type <enum: mis|cnc|nrml>MIS if you are targeting intraday products, CNC if you are targeting delivery products, NRML if you are targeting carry forward products
--zerodha-trading-segment <enum: equity|commodity>EQUITY if you are trading equities on NSE or BSE, COMMODITY if you are trading commodities on MCX
--zerodha-history-subscription <enum: true|false>Whether you have a history API subscription for Zerodha
--samco-client-id <string>Your Samco account Client ID
--samco-client-password <string>Your Samco account password
--samco-year-of-birth <string>Your year of birth (YYYY) registered with Samco
--samco-product-type <enum: mis|cnc|nrml>MIS if you are targeting intraday products, CNC if you are targeting delivery products, NRML if you are targeting carry forward products
--samco-trading-segment <enum: equity|commodity>EQUITY if you are trading equities on NSE or BSE, COMMODITY if you are trading commodities on MCX
--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 SAPI server
--terminal-link-server-port <integer>The port of the SAPI server
--terminal-link-emsx-broker <string>The EMSX broker to use (Optional)
--terminal-link-emsx-account <string>The EMSX account to use (Optional)
--terminal-link-emsx-team <string>The EMSX team to receive order events from (Optional)
--terminal-link-openfigi-api-key <string>The Open FIGI API key to use for mapping options
--tt-user-name <string>Your Trading Technologies username
--tt-session-password <string>Your Trading Technologies session password
--tt-account-name <string>Your Trading Technologies account name
--tt-rest-app-key <string>Your Trading Technologies REST app key
--tt-rest-app-secret <string>Your Trading Technologies REST app secret
--tt-rest-environment <string>The REST environment to run in
--tt-order-routing-sender-comp-id <string>The order routing sender comp id to use
--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
--tdameritrade-api-key <string>Your TDAmeritrade API key
--tdameritrade-access-token <string>Your TDAmeritrade OAuth Access Token
--tdameritrade-account-number <string>Your TDAmeritrade account number
--bybit-api-key <string>Your Bybit API key
--bybit-api-secret <string>Your Bybit API secret
--bybit-vip-level <enum: VIP0
                         VIP1
                         VIP2
                         VIP3
                         VIP4
                         VIP5
                         SupremeVIP
                         Pro1
                         Pro2
                         Pro3
                         Pro4
                         Pro5>
Your Bybit VIP Level
--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
--polygon-api-key <string>Your Polygon.io API Key
--iex-cloud-api-key <string>Your iexcloud.io API token publishable key
--iex-price-plan <enum: Launch|Grow|Enterprise>Your IEX Cloud Price 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)
--alpaca-api-key <string>Your Alpaca Api Key
--alpaca-api-secret <string>Your Alpaca Api Secret
--node <string>The name or id of the live node to run on
--auto-restart <boolean>Whether automatic algorithm restarting must be enabled
--notify-order-events <boolean>Whether notifications must be sent for order events
--notify-insights <boolean>Whether notifications must be sent for emitted insights
--notify-emails <string>A comma-separated list of 'email:subject' pairs configuring email-notifications
--notify-webhooks <string>A comma-separated list of 'url:HEADER_1=VALUE_1:HEADER_2=VALUE_2:etc' pairs configuring webhook-notifications
--notify-sms <string>A comma-separated list of phone numbers configuring SMS-notifications
--notify-telegram <string>A comma-separated list of 'user/group Id:token(optional)' pairs configuring telegram- notifications
--live-cash-balance <string>A comma-separated list of currency:amount pairs of initial cash balance
--live-holdings <string>A comma-separated list of symbol:symbolId:quantity:averagePrice of initial portfolio holdings
--pushPush local modifications to the cloud before starting live trading
--openAutomatically open the live results in the browser once the deployment starts
--show-secretsShow secrets as they are input
--verboseEnable debug logging
--helpDisplay the help text of the lean cloud live deploy 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: