Lean Algorithmic Trading Engine by QuantConnect (C#, Python)
Lean Engine is an open-source algorithmic trading engine built for easy strategy research, backtesting and live trading. We integrate with common data providers and brokerages so you can quickly deploy algorithmic trading strategies.
The core of the LEAN Engine is written in C#; but it operates seamlessly on Linux, Mac and Windows operating systems. It supports algorithms written in Python 3.6 or C#. Lean drives the web-based algorithmic trading platform QuantConnect.
Want your company logo here? Sponsor LEAN to be part of radically open algorithmic-trading innovation.
Join the team and solve some of the most difficult challenges in quantitative finance. If you are passionate about algorithmic trading we'd like to hear from you. The below roles are open in our Seattle, WA office. When applying, make sure to mention you came through GitHub:
The Engine is broken into many modular pieces which can be extended without touching other files. The modules are configured in config.json as set "environments". Through these environments, you can control LEAN to operate in the mode required.
The most important plugins are:
Result Processing (IResultHandler)
Handle all messages from the algorithmic trading engine. Decide what should be sent, and where the messages should go. The result processing system can send messages to a local GUI, or the web interface.
Datafeed Sourcing (IDataFeed)
Connect and download the data required for the algorithmic trading engine. For backtesting this sources files from the disk, for live trading, it connects to a stream and generates the data objects.
Transaction Processing (ITransactionHandler)
Process new order requests; either using the fill models provided by the algorithm or with an actual brokerage. Send the processed orders back to the algorithm's portfolio to be filled.
Realtime Event Management (IRealtimeHandler)
Generate real-time events - such as the end of day events. Trigger callbacks to real-time event handlers. For backtesting, this is mocked-up a works on simulated time.
Algorithm State Setup (ISetupHandler)
Configure the algorithm cash, portfolio and data requested. Initialize all state parameters required.
These are all configurable from the config.json file in the Launcher Project.
We recommend using the docker images. These are perfectly configured to run out of the box without interfering with your development environment. You can pull these images with
docker pull quantconnect/leanand
docker pull quantconnect/research.
git clone https://github.com/QuantConnect/Lean.git cd Lean
QuantConnect.Lean.slnin Visual Studio
Visual Studio will automatically start to restore the Nuget packages. If not, in the menu bar, click
Project > Restore NuGet Packages.
Run > Start Debugging.
Alternatively, run the compiled
dllfile. First, in the menu bar, click
Build > Build All, then:
cd Lean/Launcher/bin/Debug dotnet QuantConnect.Lean.Launcher.dll
cd Launcher/bin/Debug dotnet QuantConnect.Lean.Launcher.dll
Make sure you fix the
ib-controller-dirfields in the
config.jsonfile with the actual paths to the TWS and the IBController folders respectively.
If after all you still receive connection refuse error, try changing the
ib-portfield in the
config.jsonfile from 4002 to 4001 to match the settings in your IBGateway/TWS.
QuantConnect.Lean.slnin Visual Studio
A full explanation of the Python installation process can be found in the Algorithm.Python project.
Seamlessly develop locally in your favorite development environment, with full autocomplete and debugging support to quickly and easily identify problems with your strategy. For more information please see the CLI Home.
Please submit bugs and feature requests as an issue to the Lean Repository. Before submitting an issue please read others to ensure it is not a duplicate.
The mailing list for the project can be found on LEAN Forum. Please use this to request assistance with your installations and setup questions.
Contributions are warmly very welcomed but we ask you to read the existing code to see how it is formatted, commented and ensure contributions match the existing style. All code submissions must include accompanying tests. Please see the contributor guide lines.
All accepted pull requests will get a 2mo free Prime subscription on QuantConnect. Once your pull-request has been merged write to us at [email protected] with a link to your PR to claim your free live trading. QC <3 Open Source.
The open-sourcing of QuantConnect would not have been possible without the support of the Pioneers. The Pioneers formed the core 100 early adopters of QuantConnect who subscribed and allowed us to launch the project into open source.
Ryan H, Pravin B, Jimmie B, Nick C, Sam C, Mattias S, Michael H, Mark M, Madhan, Paul R, Nik M, Scott Y, BinaryExecutor.com, Tadas T, Matt B, Binumon P, Zyron, Mike O, TC, Luigi, Lester Z, Andreas H, Eugene K, Hugo P, Robert N, Christofer O, Ramesh L, Nicholas S, Jonathan E, Marc R, Raghav N, Marcus, Hakan D, Sergey M, Peter McE, Jim M, INTJCapital.com, Richard E, Dominik, John L, H. Orlandella, Stephen L, Risto K, E.Subasi, Peter W, Hui Z, Ross F, Archibald112, MooMooForex.com, Jae S, Eric S, Marco D, Jerome B, James B. Crocker, David Lypka, Edward T, Charlie Guse, Thomas D, Jordan I, Mark S, Bengt K, Marc D, Al C, Jan W, Ero C, Eranmn, Mitchell S, Helmuth V, Michael M, Jeremy P, PVS78, Ross D, Sergey K, John Grover, Fahiz Y, George L.Z., Craig E, Sean S, Brad G, Dennis H, Camila C, Egor U, David T, Cameron W, Napoleon Hernandez, Keeshen A, Daniel E, Daniel H, M.Patterson, Asen K, Virgil J, Balazs Trader, Stan L, Con L, Will D, Scott K, Barry K, Pawel D, S Ray, Richard C, Peter L, Thomas L., Wang H, Oliver Lee, Christian L..