Lean: The Open-Source Algorithmic Trading Engine by QuantConnect

Summary
Lean is a professional-caliber, event-driven algorithmic trading engine developed by QuantConnect, supporting strategies in Python and C#. It provides a robust platform for backtesting and live trading across various financial markets. With its modular design and comprehensive features, Lean empowers quantitative developers to build and deploy sophisticated trading algorithms.
Repository Info
Tags
Click on any tag to explore related repositories
Introduction
Lean is an advanced, open-source algorithmic trading engine crafted by QuantConnect. Designed with elegant engineering and deep quant concept modeling in mind, it offers a powerful framework for developing, backtesting, and live trading algorithms. Supporting both Python and C#, Lean is an event-driven platform that comes with out-of-the-box alternative data and live-trading capabilities, making it a versatile tool for quantitative finance.
The engine's modular architecture ensures that each component is pluggable and customizable, providing flexibility for developers to tailor the platform to their specific needs. It includes models for all major plug-in points, facilitating extensive customization and integration.
Installation
For most users, the recommended way to get started with Lean is through the LEAN CLI, which is prebuilt and runs on all platforms.
To install the CLI:
pip install lean
For local development and direct source code access, you can clone the repository:
git clone https://github.com/QuantConnect/Lean.git
cd Lean
Detailed installation guides for specific operating systems are available:
macOS
- Install Visual Studio Code for Mac.
- Install the C# Dev Kit extension.
- Install .NET 9 SDK.
- Build the solution:
dotnet build - Run the solution:
cd Launcher/bin/Debug dotnet QuantConnect.Lean.Launcher.dll
Linux (Debian, Ubuntu)
- Install .NET 9.
- Compile Lean Solution:
dotnet build QuantConnect.Lean.sln - Run Lean:
cd Launcher/bin/Debug dotnet QuantConnect.Lean.Launcher.dll
Windows
- Install Visual Studio.
- Open
QuantConnect.Lean.slnin Visual Studio. - Build the solution (this should trigger NuGet package restore).
- Press
F5to run.
For comprehensive Python support details, refer to the Algorithm.Python project.
Examples
The LEAN CLI simplifies common tasks for managing and running your algorithmic trading projects. Here are some examples of commands you can use:
- Create a new project:
lean project-create - Run a local Jupyter Lab environment:
lean research - Backtest a project locally:
lean backtest - Optimize a project locally:
lean optimize - Start live trading a project locally:
lean live
For a full list of commands, download the LEAN CLI Cheat Sheet.
Why Use Lean?
Lean stands out as a premier choice for algorithmic trading due to several key advantages:
- Professional Caliber: It's an event-driven platform built for serious quant development, offering robust features for complex strategies.
- Multi-Language Support: Develop your algorithms in either Python or C#, leveraging the strengths of both languages.
- Modular and Customizable: Its highly modular design allows for extensive customization, enabling developers to integrate custom components and data sources.
- Comprehensive Functionality: Supports backtesting, optimization, and live trading across various asset classes, including stocks, options, forex, and futures.
- Active Community and Support: Benefit from a vibrant community, extensive documentation, and dedicated forums for assistance and collaboration.
- Local-Cloud Hybrid Development: Seamlessly develop and debug strategies locally while integrating with cloud services for deployment and scaling.
Links
- Lean Home Page: https://www.lean.io/
- Documentation: https://www.lean.io/docs/
- GitHub Repository: https://github.com/QuantConnect/Lean
- LEAN Forum: https://www.quantconnect.com/forum/discussions/1/lean
- Discord Chat: https://www.quantconnect.com/discord
- Docker Hub: https://hub.docker.com/orgs/quantconnect/repositories
- NuGet: https://www.nuget.org/profiles/jaredbroad