Quantitative Trading in Practice: Deep Dive into 5 Major Open-Source Frameworks
This post from zhichai.net reviews the five most-starred open-source quantitative trading frameworks on GitHub, with architecture diagrams, code examples, and use-case guidance. Below is a structured summary of the full article.
Key points
Overview of the Top 5 projects
| Rank | Project | Stars | Language | Focus | Markets | |---|---|---|---|---|---| | 1 | Freqtrade | 46.9k | Python | Crypto trading bot | Cryptocurrency | | 2 | Microsoft Qlib | 37.5k | Python | AI quant investment platform | China A-shares / US stocks | | 3 | VeighNa (vnpy) | 36.6k | Python | Quant trading dev framework | Futures / stocks / options | | 4 | Backtrader | 20.4k | Python | Backtesting & live trading | Multi-market | | 5 | Zipline | 19.4k | Python | Event-driven backtester | US stocks |
All five are Python-based. The typical quant stack has four layers: data (ingestion, cleaning, feature/factor engineering), strategy (signal generation, risk control, position sizing, execution), execution (broker APIs, order management, settlement), and analysis (performance, risk, attribution).
1. Freqtrade — the crypto trading king
- Most popular open-source crypto bot; supports 100+ exchanges via the CCXT library (Binance, OKX, Bybit, Kraken, etc.).
- Features: Python strategy classes, backtesting on candlestick/tick data, Optuna-based Hyperopt parameter optimization, FreqAI ML module (LightGBM/XGBoost/PyTorch), spot and futures trading, stop-loss/trailing-stop protections, Web UI + Telegram bot.
- Example RSI strategy shown with optimizable buy/sell RSI thresholds, EMA200 trend filter, and trailing stop.
- Workflow:
pip install freqtrade→new-config→download-data→backtesting→hyperopt→ dry-run → live trading. - Best for: crypto, Python developers, low/medium-frequency strategies, individuals/small teams. Not for: stocks/futures, millisecond HFT, large institutions.
- Covers the full pipeline: data processing, model training, strategy backtesting.
- Model library of 20+ SOTA models (LightGBM, LSTM, Transformer, GATs); Alpha158/Alpha360 factor libraries; RL framework based on Tianshou; MLflow experiment tracking.
- Full workflow example: init with
qlib.init(provider_uri='~/.qlib/qlib_data/cn_data', region='cn'), build an Alpha158 DatasetH on CSI300, train an LGBModel, runTopkDropoutStrategy(top 50, drop 5) withbacktest_dailyandrisk_analysis. - RD-Agent: LLM-driven automated factor/model research (
rdagent fin_quant,rdagent fin_factor_report). Paper-reported results: ~2x annualized return vs. the base factor library with 70% fewer factors. - Powerful expression engine for custom factors (MACD, RSI as expression strings).
- Best for: A-share/US quant research, AI/ML strategies, factor investing, academia. Not for: crypto, HFT, simple technical analysis.
- Event-driven architecture (MainEngine / EventEngine / Gateways / App modules) with a Qt GUI (VeighNa Trader).
- Domestic gateways: CTP (futures/options), XTP (Zhongtai), TORA (Huaxin), UFT ( Hundsun), COMSTAR (interbank). International: IB (Interactive Brokers), TAP, DA.
- App modules: CTA strategies, portfolio strategies, spread trading, options management, algo trading, risk control, data recorder; VeighNa 4.0 adds
vnpy.alpha(Alpha158 dataset, Lasso/LGB/MLP models, AlphaLab) inspired by Qlib. - Example Bollinger Band breakout CTA strategy using
BarGeneratorandArrayManageron 15-minute bars. - Best for: Chinese futures/stocks/options, live trading, CTA/arbitrage. Not for: pure crypto, research-only, overseas users, HFT.
- Mature framework with a clean API and 122+ built-in indicators; Cerebro engine coordinates data feeds, strategies, brokers, analyzers, observers, and sizers.
- "Lines" architecture (index 0 = current, -1 = previous bar) prevents look-ahead bias.
- Example SMA crossover strategy with Yahoo Finance data, broker cash/commission setup, plotting; parameter optimization via
optstrategywithSharpeRatio/DrawDownanalyzers and multi-core support; advanced order types (buy_bracket with stop-loss/take-profit, OCO orders). - Best for: research & backtesting, multi-market, Python developers. Not for: Chinese docs, HFT, GUI users.
- Event-driven backtest engine from Quantopian (platform closed in 2020, project remains open source).
- Architecture: TradingAlgorithm (initialize + handle_data), AlgorithmSimulator event loop, DataPortal, Blotter, Pipeline.
- Pipeline API is its key innovation: efficient cross-sectional factor computation (e.g., RSI top/bottom selections with screening).
- Example strategy: daily-rebalanced RSI long/short portfolio (long top 3, short bottom 3, 1/3 weight each side) with PerShare commission and VolumeShareSlippage models.
- Crypto bot / easy start: Freqtrade
- AI/ML factor research on stocks: Microsoft Qlib
- Live trading on Chinese markets: VeighNa
- General backtesting & learning: Backtrader
- Cross-sectional factor pipelines (US equities): Zipline