microsoft/qlib
Modular Python framework for quant research, from market data to backtests
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
Qlib is a modular Python framework for quantitative investment research, not an LLM inference runtime. Its workflow turns market data into instrument pools and time-bounded features, passes prepared datasets to models, and feeds predictions into strategies and executors for simulation and analysis. The components are loosely coupled: a team can reuse the data API without adopting the entire workflow, or run a benchmark end to end through qrun and a configuration file.
The pyqlib package uses PyYAML and NumPy; its build stack includes setuptools, setuptools-scm, Cython, and NumPy. Model dependencies are separate concerns: the benchmark catalog spans tree learners, PyTorch, and TensorFlow. Configuration-driven extensions also have a version-sensitive trust boundary. The source migration path retains package imports but requires per-component trusted: true for local .py imports, restricts expressions, and requires explicit extension mappings.
Key Capabilities & Differentiators
The data layer supports date-bounded instrument and feature queries, including lagged values and rolling calculations. Daily and one-minute data preparation paths are exposed through the CLI, and v0.9.7 added Parquet support. The benchmark catalog spans LightGBM, XGBoost, CatBoost, PyTorch models such as LSTM and Transformer, and a legacy TensorFlow TFT example. Supervised learning, market-dynamics modeling, and reinforcement learning serve different parts of the research stack rather than requiring one model family.
Strategies and executors can be nested across granularities, allowing signal generation and execution behavior to be evaluated at different levels within a simulation. Experiment outputs include information coefficient (IC) and backtest results, and Qlib provides an online model-serving path. RD-Agent is a separate integration for automating factor mining and model optimization; that integration does not make Qlib an LLM-serving engine.
Trade-offs & Limitations
Compared with using a model library directly, Qlib takes on more of the research workflow: feature preparation, shared experiment configuration, and simulation. That pays off when several models need to be evaluated under the same assumptions. If signals are already produced elsewhere and the only task is evaluating trading rules, a dedicated backtester has a smaller integration surface. Neither Qlib's backtest nor its online model-serving path should be treated as a ready-made broker integration or evidence of live execution performance.
The model catalog is broader than any one compatible environment. The legacy TFT example calls for TensorFlow 1.15 and Python 3.6–3.7, outside the current core package's declared Python range. The batch benchmark runner is Linux-only, creates a separate virtual environment per model, and does not run repeated trials of the same model in parallel. Reproducibility therefore depends on pinning the data snapshot and model environment, not just saving the workflow configuration. The MIT license covers the code; market-data rights must be evaluated separately.
Hardware & Deployment Guide
For a first run, install pyqlib in an isolated Python environment, prepare a dataset, then run a LightGBM benchmark with qrun. The core package declares Python 3.8 or later and lists classifiers through 3.12; verify the requirements of the chosen benchmark separately. The Dockerfile uses a Miniconda base, Python 3.8, build-essential, and pins including NumPy 1.23.5 and pandas 1.5.3. Its default IS_STABLE=yes installs pyqlib from PyPI; the other branch invokes python setup.py install. Pin the image base and package version if you need reproducible builds. The Node manifest is for pull-request title checks, not the research runtime.
The official sample dataset is marked temporarily unavailable; plan on a vetted community snapshot or your own data conversion. In addition to the data-layer changes in v0.9.7, the v0.9.8 release entry lists restrictions on executable recorder artifacts. Before upgrading, test saved-model reloads, resumed or delayed training, and DDG-DA; check whether HIST mappings or high-frequency cache paths need migration. Source, tagged, and PyPI builds can differ, so verify the exact version before relying on a migration flag or configuration setting.
csi500 and request date-bounded features with expressions such as Ref($close, 1) and Mean($close, 3).qrun for configuration-driven runs or examples/workflow_by_code.py for Python integration.BaseDataHandler.Quant teams that want to compare factors and models on a shared, versioned data and backtest workflow, with room for custom Python components.
You need an LLM inference server, turnkey live brokerage integration, or a single ready-to-run environment for every legacy benchmark.
Quick Start & Installation
pip install pyqlibComparison vs. Top LLMs & Inference Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| qlib ★ | 50.8k | +197 | Python | MIT | Modular Python framework for quant research, from market data to backtests |
| transformers | 169.6k | +337 | Python | Apache-2.0 | A PyTorch model-definition SDK for unified inference and training across modalit |
| pytorch | 105.9k | +299 | Python | — | Python-first tensor SDK for GPU-accelerated training and inference |
| scikit-learn | 68.5k | +126 | Python | BSD-3-Clause | In-process Python library for machine learning and data mining |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/microsoft/qlib.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about qlib
Do I have to adopt the entire workflow to use Qlib's data or modeling components?
qrun to launch a configuration-driven benchmark, or use examples/workflow_by_code.py as a starting point for a Python integration. The data API can be used independently through D.instruments, D.list_instruments, and D.features. When moving a workflow between source and packaged releases, verify the configuration rules for the target version before reusing local extensions.How should I size hardware for a first run?
Can we self-host Qlib for commercial research?
When is Qlib preferable to standalone modeling and backtesting tools?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy