API Reference
lean data generate
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 Type | Supported Resolutions | ||||
---|---|---|---|---|---|
Tick | Second | Minute | Hour | Daily | |
Equity | ![]() | ![]() | ![]() | ![]() | ![]() |
Forex | ![]() | ![]() | ![]() | ![]() | ![]() |
CFD | ![]() | ![]() | ![]() | ![]() | ![]() |
Future | ![]() | ![]() | ![]() | ![]() | ![]() |
Crypto | ![]() | ![]() | ![]() | ![]() | ![]() |
Option | ![]() |
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:
Option | Description |
---|---|
--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 Minute ). Must be Tick , Second , Minute , Hour or Daily . 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. |
--image <value> | The LEAN engine image to use (defaults to quantconnect/lean:latest ). |
--update | Pull 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). |
--verbose | Enable debug logging. |
--help | Display the help text of the lean data generate command and exit. |