API Reference

lean library add

Introduction

Add a custom library to a project.

$ lean library add <project> <name> [options]

Description

Adds a third-party or project library to a project so you can use it in local backtesting, local live trading, local optimizations, and the local research environment. Additionally, this command updates your local environment so you get autocomplete on the libraries.

C# libraries are added to your C# project file (the file ending in .csproj). If dotnet is on your PATH and --no-local is not given, the CLI also restores all dependencies using dotnet restore to make local autocomplete work.

Third-party Python libraries are added to your project's requirements.txt file. If pip is on your PATH and --no-local is not given, the CLI also installs the Python package in your local Python environment to make local autocomplete work.

If --version is not given, the package is pinned to the latest compatible version. For C# projects, this is the latest available version. For Python projects, this is the latest version compatible with Python 3.11 (which is what the Docker images use).

If --version is given and the project is a Python project, the CLI will additionally check whether the given version is compatible with Python 3.6. If this is not the case, the command aborts because libraries incompatible with Python 3.11 cannot be installed in the official Docker images.

If a project is encrypted, you can only add a project library to it if the project library is unencrypted or is encrypted with the same key as the project. When you add a project library to a project, the name and path of the library is added to the project configuration file.

Arguments

The lean library add command expects the following arguments:

ArgumentDescription
<project>The path to the project directory.
<name>For third-party C# libraries, the name of the NuGet package to add. For third-party Python libraries, the name of the PyPI package to add. For project libraries, the path to the library in the Library directory of your organization workspace.

Options

The lean library add command supports the following options:

OptionDescription
--version <value>The version of the package to add to the project (defaults to the latest compatible version).
--no-localSkip making changes to the local environment.
--verboseEnable debug logging.
--helpDisplay the help text of the lean library add 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: