API Reference

lean cloud optimize

Introduction

Optimize a project in the cloud.

$ lean cloud optimize [OPTIONS] PROJECT

Description

Runs an optimization for a cloud project. While running the optimization, a progress bar shows to keep you up-to-date on the status of the optimization. After running the optimization, the optimal parameters and the statistics of the backtest with the optimal parameters are logged.

By default, an interactive wizard is shown, letting you configure the target, the parameters, the constraints, the node type, and the number of parallel nodes. When --target is given the command runs in non-interactive mode and does not prompt for input or confirmation.

When --target is given, the optimizer configuration is read from the command-line options. This means the --target, --target-direction, --parameter, --node, and --parallel-nodes options become required. Additionally, you can also use --constraint to specify optimization constraints.

In non-interactive mode, the parameters can be configured using the --parameter option. This option takes the following values: the name of the parameter, its minimum value, its maximum value, and its step size. You can provide this option multiple times to configure multiple parameters.

In non-interactive mode, the constraints can be configured using the --constraint option. This option takes a "statistic operator value" string as value, where the statistic must be a path to a property in a backtest's output file, like "TotalPerformance.PortfolioStatistics.SharpeRatio". This statistic can also be shortened to "SharpeRatio" or "Sharpe Ratio", in which case, the command automatically converts it to the longer version. The value must be a number and the operator must be <, >, <=, >=, ==, or ==. You can provide this option multiple times to configure multiple constraints.

Example non-interactive usage:

$ lean cloud optimize "My Project" \
    --target "Sharpe Ratio" \
    --target-direction "max" \
    --parameter my-first-parameter 1 10 0.5 \
    --parameter my-second-parameter 20 30 5 \
    --constraint "Drawdown < 0.5" \
    --constraint "Sharpe Ratio >= 1" \
    --node O4-12 \
    --parallel-nodes 12 \
    --push

If you have a local copy of the cloud project, you can use the --push option to push local modifications to the cloud before starting the optimization.

Arguments

The lean cloud optimize command expects the following arguments:

ArgumentDescription
<project>The name or Id of the project to optimize.

Options

The lean cloud optimize command supports the following options:

OptionDescription
--target <string>The target statistic of the optimization
--target-direction <enum: min|max>Whether the target must be minimized or maximized
--parameter <<string> <float> <float> <float>>...The 'parameter min max step' pairs configuring the parameters to optimize
--constraint <string>The 'statistic operator value' pairs configuring the constraints of the optimization
--node <enum: O2-8|O4-12|O8-16>The node type to run the optimization on
--parallel-nodes <integer>The number of nodes that may be run in parallel
--name <string>The name of the optimization (a random one is generated if not specified)
--pushPush local modifications to the cloud before starting the optimization
--verboseEnable debug logging
--helpDisplay the help text of the lean cloud optimize 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: