API Reference

lean data generate

Introduction

Generate random 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>[required]
--end <yyyyMMdd>End date for the data to generate in yyyyMMdd format (defaults to today)
--symbol-count <integer> <range>[x>=0]
--tickers <string>Comma separated list of tickers to use for generated data
--security-type <enum: Equity
                       Forex
                       Cfd
                       Future
                       Crypto
                       Option>
The security type to generate data for (defaults to Equity)
--resolution <enum: Tick
                    Second
                    Minute
                    Hour
                    Daily>
The resolution of the generated data (defaults to Minute)
--data-density <enum: Dense|Sparse|VerySparse>The density of the generated data (defaults to Dense)
--include-coarse <boolean>Whether coarse universe data should be generated for Equity data (defaults to True)
--market <string>The market to generate data for (defaults to standard market for the security type)
--quote-trade-ratio <float>The ratio of generated quotes to generated trades. Values larger than 1 mean more quotes than trades. Only used for Option, Future and Crypto (defaults to 1)
--random-seed <integer> <range>The random number generator seed. Defaults to None, which means no seed will be used [x>=0]
--ipo-percentage <float>The probability each equity generated will have an IPO event. Note that this is not the total probability for all symbols generated. Only used for Equity (defaults to 5.0)
--rename-percentage <float>The probability each equity generated will have a rename event. Note that this is not the total probability for all symbols generated. Only used for Equity (defaults to 30.0)
--splits-percentage <float>The probability each equity generated will have a stock split event. Note that this is not the total probability for all symbols generated. Only used for Equity (defaults to 15.0)
--dividends-percentage <float>The probability each equity generated will have dividends. Note that this is not the probability for all symbols genearted. Only used for Equity (defaults to 60.0)
--dividend-every-quarter-percentage <float>The probability each equity generated will have a dividend event every quarter. Note that this is not the total probability for all symbols generated. Only used for Equity (defaults to 30.0)
--option-price-engine <string>The stochastic process, and returns new pricing engine to run calculations for that option (defaults to BaroneAdesiWhaleyApproximationEngine)
--volatility-model-resolution <enum: Tick
                                     Second
                                     Minute
                                     Hour
                                     Daily>
The volatility model period span (defaults to Daily)
--chain-symbol-count <integer> <range>[x>=0]
--image <string>The LEAN engine image to use (defaults to quantconnect/lean:latest)
--updatePull the LEAN engine image before running the generator
--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 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: