API Reference

lean data generate

Introduction

Generate realistic market data.

$ lean data generate [options]

Description

Runs the random data generator in the LEAN ToolBox to generate realistic market data using a Brownian motion model. Requires --start <yyyyMMdd> and --symbol-count <amount> to be set. The rest of the options have default values.

If --end <yyyyMMdd> isn't set, data is generated from the start date until the current date. If the --end option is set, data is generated between the given --start and --end values (inclusive).

By default, dense data is generated, which means the generated data contains at least one data point per resolution step. You can use --data-density Sparse to change this to at least one data point per 5 resolution steps, or --data-density VerySparse to change it to at least one data point per 50 resolution steps.

If the security type is set to Equity, this command will automatically generate map files, factor files, and coarse universe data. To not generate coarse universe data, set the --include-coarse option to false.

The following combinations of security types and resolutions are supported:

Security TypeSupported Resolutions
TickSecondMinuteHourDaily
Equitygreen checkgreen checkgreen checkgreen checkgreen check
Forexgreen checkgreen checkgreen checkgreen checkgreen check
CFDgreen checkgreen checkgreen checkgreen checkgreen check
Futuregreen checkgreen checkgreen checkgreen checkgreen check
Cryptogreen checkgreen checkgreen checkgreen checkgreen check
Optiongreen check

By default, the official LEAN engine image is used. You can override this using the --image <value> option. Alternatively, you can set the default engine image for all commands using lean config set engine-image <value>. The image is pulled before running the random data generator if it doesn't exist locally yet or if you pass the --update flag.

Options

The lean data generate command supports the following options:

OptionDescription
--start <yyyyMMdd>The inclusive start date for the data to generate in yyyyMMdd format. Must be at least 19980101.
--end <yyyyMMdd>The inclusive end date for the data to generate in yyyyMMdd format (defaults to today).
--symbol-count <value>The number of symbols for which to generate data. This value is ignored if you provide the --tickers option.
--tickers <value>Comma-separated list of tickers to use for generating data.
--security-type <value>The security type for which to generate data (defaults to Equity). Must be Equity, Forex, Cfd, Future, Crypto or Option.
--resolution <value>The resolution of the generated data (defaults to MinuteMINUTE). Must be TickTICK, SecondSECOND, MinuteMINUTE, HourHOUR or DailyDAILY. See the description for the supported combinations of security types and resolutions.
--data-density <value>The density of the generated data (defaults to Dense). Must be Dense (at least one data point per resolution step), Sparse (at least one data point per 5 resolution steps), or VerySparse (at least one data point per 50 resolution steps).
--include-coarse <true/false>Whether coarse universe data must be generated for Equity data (defaults to true).
--market <market>The market for which to generate data. This option defaults to LEAN's default market for the requested security type.
--quote-trade-ratio <value>The ratio of generated quotes to generated trades (defaults to 1). Values larger than 1 mean more quotes than trades. This option is only used for Option, Future and Crypto.
--random-seed <value>The random number generator seed. If you set a value, it must be a non-negative integer. If you don't set a value, the genrator won't use a random seed.
--ipo-percentage <value>The probability each generated Equity will have an IPO event (defaults to 5.0). Note this is not the total probability for all generated symbols. This option is only used for Equity.
--rename-percentage <value>The probability each generated Equity will have a rename event (defaults to 30.0). Note that this is not the total probability for all generated symbols. This option is only used for Equity.
--splits-percentage <value>The probability each generated Equity will have a stock split event (defaults to 15.0). Note that this is not the total probability for all generated symbols. This option is only used for Equity.
--dividends-percentage <value>The probability each generated Equity will have dividends (defaults to 60.0). Note that this is not the total probability for all generated symbols. This option is only used for Equity.
--dividend-every-quarter-percentage <value>The probability each generated Equity will have a dividend event every quarter (defaults to 30.0). Note that this is not the total probability for all generated symbols. This option is only used for Equity.
--option-price-engine <value>The pricing engine to run calculations for Options (defaults to BaroneAdesiWhaleyApproximationEngine).
--volatility-model-resolution <value>The volatility model period span (defaults to DailyDAILY). Must be TickTICK, SecondSECOND, MinuteMINUTE, HourHOUR, or DailyDAILY
--chain-symbol-count <value>The size of the Option chain (defaults to 10). This value must be a non-negative integer.
--image <value>The LEAN engine image to use (defaults to quantconnect/lean:latest).
--updatePull the LEAN engine image before running the generator.
--lean-config <path>The Lean configuration file that should be used (defaults to the nearest lean.json file).
--verboseEnable debug logging.
--helpDisplay the help text of the lean data generate 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: