# Repository Briefing: microsoft/qlib
> Source: https://repoforai.com/repo/microsoft/qlib (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/microsoft/qlib
- **Official Docs / Website**: https://qlib.readthedocs.io/en/latest/
- **Category**: LLMs & Inference (大模型与推理微调)
- **Primary Language**: Python
- **License**: MIT
- **Engineering Health**: A+ (93/100 · Maintenance 31/35 · Adoption 25/25 · Releases 17/20 · License 20/20)
- **Latest Release**: v0.9.8 (2026-10-08) — https://github.com/microsoft/qlib/releases
- **Review Snapshot**: 2026-12-03
- **Deployment / Stack Signals**: Docker, CLI
- **Momentum**: 50,825 ★ total (+12 24h / +197 7d) · 8,020 forks
- **Topics**: `algorithmic-trading`, `auto-quant`, `deep-learning`, `finance`, `fintech`, `investment`, `machine-learning`, `paper`, `platform`, `python`, `quant`, `quant-dataset`
- **When to Use**: Best for: Quant teams that want to compare factors and models on a shared, versioned data and backtest workflow, with room for custom Python components. Skip if: You need an LLM inference server, turnkey live brokerage integration, or a single ready-to-run environment for every legacy benchmark.

## Overview
```text
### Architecture & 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.
```

## Key Capabilities
```text
- Data API: Query instrument pools such as `csi500` and request date-bounded features with expressions such as `Ref($close, 1)` and `Mean($close, 3)`.
- Workflow entry points: Use `qrun` for configuration-driven runs or `examples/workflow_by_code.py` for Python integration.
- Model zoo: Compare XGBoost, LightGBM, CatBoost, PyTorch sequence models, and a legacy TensorFlow TFT example, subject to per-model dependencies.
- Simulation: Nest strategies and executors across granularities and evaluate runs with IC and backtest outputs.
- Release evolution: v0.9.7 added Parquet support and unified the data-handler fetch interface through `BaseDataHandler`.
- Artifact trust: v0.9.8 lists restrictions on executable recorder artifacts while keeping fresh in-memory training and supported data-only reads available without opt-in.
```

## Quick Start / Clone
```bash
pip install pyqlib
```
