Local data

Generating random data

Introduction

Running the LEAN engine locally with the CLI requires you to have your own local data. Instead of using actual market data, you can also opt to use realistic fake data by using LEAN's random data generator. This generator uses a Brownian motion model to generate realistic market data. It is capable of generating data for most of LEAN's supported security types and resolutions, which makes it a good solution to design and test algorithms without the need to buy real financial data.

Running the generator

Follow these steps to generate random data:

  1. Open a terminal in the directory you ran lean init in.
  2. Run lean data generate --start 20150101 --symbol-count 10 to generate dense minute equity data since 01-01-2015 for 10 random symbols.
    $ lean data generate --start 20150101 --symbol-count 10
    Begin data generation of 10 randomly generated Equity assets...
    You can also specify an end date using --end <yyyyMMdd>, generate data for a different security type using --security-type <type>, for a different resolution using --resolution <resolution>, or with a different density using --data-density <density>.
    It may also be helpful to run lean data generate --help for the full list of options.

Supported security types

The random data generator supports the following security types and resolutions:

Security typeSupported resolutions
EquityTick, Second, Minute, Hour, and Daily
ForexTick, Second, Minute, Hour, and Daily
CFDTick, Second, Minute, Hour, and Daily
FutureTick, Second, Minute, Hour, and Daily
CryptoTick, Second, Minute, Hour, and Daily
OptionMinute

Support for options data is limited at the moment, with generated options data not having underlying equity data. This limitation is tracked in GitHub issue #2839.

Supported densities

The random data generator supports the following densities:

DensityDescription
DenseAt least one data point per resolution step.
SparseAt least one data point per 5 resolution steps.
VerySparseAt least one data point per 50 resolution steps.

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

Did you find this page helpful?

Contribute to the documentation: