LEAN
The engine behind QuantConnect, Apache-2.0 and runnable on your own machine.
by QuantConnect
Last updated
What it is
An event-driven algorithmic trading engine written in C#, with first-class Python support for the
algorithm you write. The same QCAlgorithm subclass runs a backtest, a paper session and a live
deployment, which removes the class of bug where the research code and the production code drift
apart — that is the reason to choose it and the reason it is so much larger than a backtesting
library.
Everything that touches the simulation is a plug-in point with a default: brokerage model, fee model, fill model, slippage model, margin model, settlement model, buying-power model. Crypto is one asset class among equities, options, futures, forex and CFDs, which cuts both ways — the portfolio accounting is genuinely multi-asset, and the crypto-specific surface is smaller than a crypto-native framework's.
This card is the open-source engine. QuantConnect also sells a hosted platform built on it, with its own datasets, compute and live-trading infrastructure; that is a different product bought by somebody else and it is not described here.
Pricing
The engine is free under Apache-2.0 — a permissive licence, so no obligation to publish anything you build on it. Clone the repository, take the zip, pull the Docker image or the NuGet packages; there is no paid edition of the engine and nothing is gated.
What costs money is data and, if you want it, hosting. QuantConnect's pricing page sells plans for the hosted platform — Quant Researcher, Team, Trading Firm and Institution — separated by compute nodes, hosted dataset access, collaboration and which live brokerages you may deploy to; the "Free Plan Includes" line reads equity, indexes, forex, crypto, futures and options data, community support and unlimited backtesting in their cloud. The figures on that page are rendered by JavaScript and are not reproduced here, because they price the platform rather than this card's product.
One small and real incentive from the repository: an accepted pull request earns 50 USD of cloud credit.
Data & coverage
LEAN ships no market data. The repository carries a handful of sample files so the examples
run — spot samples under Data/crypto for binance, bitfinex, bybit and coinbase, and crypto-future
samples under Data/cryptofuture for binance, bybit and dydx. Everything else you download, buy or
write yourself into LEAN's format: CSV inside zip at
/data/securityType/market/resolution/ticker/date_tickType.zip for tick, second and minute, and a
single zip per ticker for hour and daily.
Venues with a maintained brokerage plugin: Binance, including Binance US and both the
USDT-margined and coin-margined futures endpoints, plus Bybit, Coinbase, Kraken, Bitfinex and dYdX.
None is archived and all six had commits on master during 2026, though not at the same pace —
Bybit, Coinbase, Kraken and dYdX moved in September 2026, Binance and Bitfinex last in June. The
FTX plugin is archived and still in the organisation as a headstone; its last commit is dated May
2023. Be careful with the market constants in Common/Market.cs: Bittrex, Poloniex, HitBTC,
OkCoin, Bithumb, Coinone and Bitstamp all have a market name and no plugin. A constant is not
connectivity.
Funding on perpetuals is modelled, and it is worth knowing exactly how. The crypto-future
margin-interest models compute funding = rate × position notional and add it to the quote
currency cash, sign flipped so that a long pays on a positive rate. Binance's model applies it at
00:00, 08:00 and 16:00 UTC — eight-hour intervals, matching the venue.
There appear to be three venue models and there is one. BybitFutureMarginInterestRateModel
and dYdXFutureMarginInterestRateModel are declared as subclasses of
BinanceFutureMarginInterestRateModel with empty bodies — no overridden method, no different
schedule, nothing but a name. All three therefore settle funding three times a day on Binance's
clock. For Bybit that happens to be right. For dYdX it is not: the v4 chain runs a funding-tick
epoch every hour and the vendor's own documentation says funding "is calculated at the end of each
hour" and is paid or received hourly. A dYdX perp backtest in LEAN applies twenty-four hours of
accrued rate in three lumps at the wrong times, and nothing in the engine says so. (Read from the
repository on 19 September 2026.)
The catch is the data behind it. The model reads a MarginInterestRate object out of the
security cache and returns immediately if there is none. Funding rates are distributed as separate
datasets rather than as part of the engine, one per venue. Run a perp backtest without loading one
and nothing is charged and nothing is logged — the failure is silent, and the equity curve is the
funding-free fantasy the whole feature exists to prevent.
Free history straight from the exchange is coarser than it looks. The Binance brokerage will serve history from the exchange's own REST API, but it rejects tick and second resolution and rejects any tick type other than trade, logging a warning and returning nothing. Minute bars of trades and upwards, no quotes, no order book. For quote data or tick data you are buying a dataset or building the files yourself.
A note on the repository's own documentation: Data/crypto/readme.md still states that the
supported markets are "GDAX/Coinbase Pro" and "Bitfinex (Beta)", points at ToolBox downloaders
named after GDAX, and credits a data supplier — all of this beside a directory tree that ships
binance and bybit. Read the code and the folder listing, not that file.
Integrations
Eleven maintained brokerage plugins beyond crypto, each in its own repository under the QuantConnect organisation: Interactive Brokers, Tradier, OANDA, Alpaca, TradeStation, Tastytrade, Zerodha, Samco, Trading Technologies, Wolverine and Raiffeisen Bank International. Data-source plugins are packaged the same way, including CoinAPI, CoinGecko, a crypto coarse universe for selection, and the per-venue funding-rate feeds.
The engine is a .NET solution — dotnet 10 SDK to build from source, or the published Docker images.
Most people drive it through the LEAN CLI, pip install lean, which wraps lean backtest,
lean research, lean optimize and lean live around the Docker image. Research runs in Jupyter.
Algorithms can send email, webhook and SMS notifications from a live run, and that path is
implemented in the open-source engine rather than only in the cloud.
QuantConnect publishes an MCP server, and it is not for this product: it is a bridge for an AI client to drive their cloud API — creating projects, running cloud backtests, deploying live algorithms. Its standalone repository now opens with a line saying it is deprecated in favour of the one embedded in VS Code. Nothing there talks to an engine running on your laptop, which is why this card does not claim an MCP server.
Limitations
No crypto options. LEAN models options thoroughly — equity options, index options, options on futures, chains, Greeks — and none of that reaches crypto. There is no crypto option security type and no data folder for one. If you are pricing a BTC option strategy, this is the wrong engine regardless of everything else on this page.
No AMM execution and no chain data. There is no swap fill model, no pool state, no wallet and no on-chain analytics anywhere in the engine. The one decentralised venue LEAN can trade is dYdX, which has a maintained brokerage plugin, a funding model and sample files — and it is an order-book perpetuals exchange, so it is reached through an exchange API like the rest. If the strategy needs to read a pool or route a swap, none of that exists here.
Funding is opt-in data, and its absence is silent. Covered above, and it is the single easiest way to publish a wrong perp backtest with this engine. There is no warning, no log line and no non-zero default.
The dYdX funding model is Binance's funding model. Also covered above. It is the second easiest way, and harder to catch than the first, because the class exists, is wired up and runs — it is simply on the wrong schedule for the venue it is named after.
The cost of entry is a build, not an install. You need the .NET SDK or Docker, and the solution is dozens of projects. Compared with importing a Python library and passing it a DataFrame, the first hour is spent on infrastructure. That is a fair trade if you intend to trade the result live; it is a poor one if you want to check whether a moving-average cross works.
Documentation lives on the cloud product's site, and one of its own links is broken. The repository readme still advertises a documentation URL on the LEAN domain that now redirects to a 404. The working engine documentation sits under quantconnect.com and is written throughout from the perspective of somebody using the hosted platform, so separating "this is the engine" from "this is the subscription" is work you do yourself.
Scale, for context rather than comfort: 240 open issues as of 19 September 2026 — counted as issues, not issues plus pull requests — against 21,675 stars, with the last commit on master dated 18 September 2026. It is busy and it is complicated, and both of those are load-bearing facts.
Alternatives
LEAN is the answer when the backtest is a rehearsal for live trading and the strategy spans more than crypto. When it is a research question about one pair, the ratio of setup to insight is bad, and something smaller in this category will get you to a number faster — at the price of an engine that does not know what funding is.
Lumibot is the smaller version of the same promise — one Python strategy that backtests and then trades live, across eight CCXT exchanges — with far less apparatus and the same warning about defaults, since its fees and slippage are zero until you set them.
Specs
- Interfaces
- Python, C#
- Export
- CSV, JSON
- Asset classes
- Spot, Perpetuals, Futures
- Chains
- —
- Venues
- CEX, DEX, Derivatives
- KYC required
- No
- Platforms
- Library, CLI
- AI features
- None
- Capabilities
- Backtesting, Automation, Live trading, Paper trading, Alerts, Derivatives analytics
- Pricing verified
- Capabilities verified
- Coverage verified
Also from QuantConnect
Also worth comparing
- Backtesting.py — Two thousand lines, one OHLC series, and no idea what a funding payment is.
- Barter — Rust trading engine and market-data streams — live execution is a trait you implement.
- HftBacktest — Tick-by-tick backtesting that models order queue position and feed and order latency.
- Lumibot — One Python strategy that backtests and then trades live, across eight CCXT exchanges.
- NautilusTrader — Event-driven Rust engine that settles perpetual funding at the venue boundary.
- Jesse — Python backtesting and research framework whose live-trading half is a paid plugin.
Named as a replacement for
On these shelves
Background
How this part of the industry works, rather than which product to pick.
- What a crypto backtest silently assumes — Every engine ships a fill rule and a cost model with defaults. What those defaults assume about fees, funding and liquidation, and which engines model which.
FAQ
Is LEAN free, or do I have to pay QuantConnect?
The engine is Apache-2.0 and runs on your own machine with nothing to buy. What QuantConnect sells is the hosted platform — compute nodes, hosted datasets, cloud live trading — and that is a separate product with a separate price. Running LEAN locally costs you the data and the machine.
Does LEAN model perpetual funding?
It models one schedule and gives it three names. The crypto-future funding model applies position notional times the funding rate at 00:00, 08:00 and 16:00 UTC; the Bybit and dYdX classes are empty subclasses of the Binance one and change nothing. That is wrong for dYdX, whose chain pays funding every hour. It also needs a funding-rate feed loaded; with none, it charges nothing and says nothing.
Which crypto exchanges does LEAN support?
Brokerage plugins are maintained for Binance (including Binance US and both USDT- and coin-margined futures), Bybit, Coinbase, Kraken, Bitfinex and dYdX. The FTX plugin is archived, its last commit dated May 2023. The engine also defines market names for exchanges that have no plugin at all, so the constant list is not the supported list.
Do I need to know C# to use LEAN?
No — algorithms can be written entirely in Python, and the Python examples live beside the C# ones in the repository. You do need the .NET SDK or the Docker image to run the engine itself, which is the part that surprises people coming from a pip-installable library.