Repolode
QuantConnect

QuantConnect/Lean

Event-driven C# algorithmic trading engine for backtesting and live trading strategies across multiple financial markets, with Python support.

Open-source alternative to:QuantConnect

Stars
22,433
Forks
5,394
Open issues
286
Last commit
24 hours ago

Repolode describes open-source projects and does not give investment advice. Trading and investing can lose money: assess the risk yourself and follow the laws where you live before using this project.

What is it?

LEAN is an event-driven algorithmic trading engine that lets developers write a strategy once and run it against historical data for backtesting or against live brokerage accounts. Strategies can be written in C# or Python. The engine is built around pluggable components, including data feeds, universe selection, alpha models, portfolio construction, execution, and risk management, each of which can be replaced or customized.

The project also includes the LEAN CLI, a command-line tool installed with pip that creates projects, launches a local Jupyter Lab research environment, runs backtests and parameter optimizations, and starts live trading, all through Docker. Local development is supported on Windows, macOS, and Linux with Visual Studio, VS Code, or the dotnet CLI.

LEAN is maintained by QuantConnect and is commonly used by quant developers who need a single engine that covers research, backtesting, and deployment.

Key features

  • 01Event-driven engine for backtesting and live trading with the same strategy code.
  • 02Strategies can be written in C# or Python.
  • 03Pluggable models for data, alpha, portfolio, execution, and risk.
  • 04LEAN CLI for running projects, backtests, optimizations, and live trading via Docker.
  • 05Local development support in Visual Studio, VS Code, and the dotnet CLI.

Use cases

  • Backtesting a trading strategy against historical market data before risking capital.
  • Running a live algorithmic trading strategy connected to a brokerage account.
  • Prototyping quantitative research in a local Jupyter Lab environment.
  • Building a custom trading system with replaceable data, execution, and risk components.

Quick start

  1. 1

    Install the LEAN CLI with pip

    pip install lean
  2. 2

    Create a new project with starter code

    lean project-create
  3. 3

    Backtest the project locally using Docker

    lean backtest

Things to know

  • Running backtests and live trading locally requires Docker.
  • Building from source needs the .NET 10 SDK, and Visual Studio for Mac is discontinued.

Topics

FAQ

What is Lean?
Event-driven C# algorithmic trading engine for backtesting and live trading strategies across multiple financial markets, with Python support. LEAN is an event-driven algorithmic trading engine that lets developers write a strategy once and run it against historical data for backtesting or against live brokerage accounts. Strategies can be written in C# or Python. The engine is built around pluggable components, including data feeds, universe selection, alpha models, portfolio construction, execution, and risk management, each of which can be replaced or customized.
Is Lean free to use? What license does it have?
Lean is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
Is Lean still maintained?
Actively maintained. The last commit to Lean was on Nov 6, 2026.
What can I use Lean for?
Backtesting a trading strategy against historical market data before risking capital. Running a live algorithmic trading strategy connected to a brokerage account. Prototyping quantitative research in a local Jupyter Lab environment. Building a custom trading system with replaceable data, execution, and risk components.
How do I install Lean?
Install the LEAN CLI with pip: pip install lean Create a new project with starter code: lean project-create Backtest the project locally using Docker: lean backtest
Where can I get Lean?
The source code and installation instructions are on GitHub: https://github.com/QuantConnect/Lean

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects