Open Source

Generating Random Backtest Data

Generating Random Backtest Data


Real market data is often expensive and governed by difficult redistribution licenses. QuantConnect wanted to give the LEAN users a way to design and test their algorithms, without needing to download and buy real financial data. The RandomDataGenerator seeks to address that by randomly generating data in the LEAN format, for the various asset types we support.

Using the Random Data Generator

The LEAN Random Data Generator is located in the LEAN ToolBox and can be accessed by executing the QuantConnect.ToolBox.exe CLI program.

We recommend cloning LEAN and building from the source code directly from Github. However, if this is not possible for you we have made a snapshot of the build available for your convenience here:

To run the ToolBox open a command window and execute it from the command line. To execute it you will need C# or Mono installed:


 .\QuantConnect.ToolBox.exe --app=randomdatagenerator

Linux and Mac:

mono QuantConnect.ToolBox.exe --app=randomdatagenerator

Complete Example:


The Random Data Generator has many parameters you can configure to generate the various datasets LEAN supports. Please see the next section for documentation on these parameters.

Command Parameters

Random Data Generator Parameters

Security type to generate.
Possible Values: Equity, Crypto, Forex, Cfd, Option, Future
Default: Equity

Example: --security-type=Equity

Resolution of data to store.
Possible Values: Tick, Second, Minute, Hour, Daily
Default: Minute

Example: --resolution=Minute

Start date for the data to generate: format yyyy-mm-dd.

Example: --from-date=2018-01-01

Final date of the generated data: format yyyy-mm-dd.

Example: --to-date=2019-01-01
Symbol Count

Number of tickers to generate

Example: --symbol-count=100

Tick density of the data generated to model low volume data.
Possible Values: Dense, Sparse, VerySparse
Default: Dense

Example: --density=Dense

Generate the coarse universe data when generating Equity data.
Default: true

Example: --include-coarse=true

Supported Assets and Resolutions

The Random Data Generator currently supports the following asset types and resolutions:

Supported Data Types and Resolutions
Trade Only
Resolutions Tick, Second, Minute, Hour and Daily

All Equity data resolutions are supported.

Forex, CFD
Quotes Only
Resolutions Tick, Second, Minute, Hour and Daily

Forex and CFD generator supports quote (spread) data in all resolutions.

Futures, Crypto
Trades and Quotes
Resolutions Tick, Second, Minute, Hour and Daily

All Futures and crypto data types and resolutions are supported

Trades and Quotes
Resolution Minute

Options are partially supported. Currently option random data is generated independent of a random underlying asset making its usefulness limited. This will be fixed by Github Issue #2839.

Final Notes

The Random Data Generator uses Brownian motion to generate the data prices. You can see how these prices and ticker strings are generated in the RandomValueGenerator class.

If you'd like to use a different system for providing the randomness you can implement your own IRandomValueGenerator or extend the RandomValueGenerator class.

You can also see our Documentation and Videos. You can also get in touch with us via Chat.

Did you find this page Helpful ?