Quick answer
Qlib is Microsoft’s open-source, AI-oriented quantitative investment platform. It provides a fast data layer and expression engine for factors (such as the Alpha158 set), a model zoo from LightGBM to LSTMs and Transformers, a backtesting and portfolio-strategy layer, and YAML workflows that run end to end. RD-Agent builds on it to automate factor and model research with LLMs.
Qlib at a glance
- Category
- Machine learning & AI
- Language
- Python
- License
- MIT
- Does
- Machine learning, Backtesting, Market data, Performance analytics
- Markets
- Stocks
- Best for
- Cross-sectional stock prediction with machine learning at research scale.
- In AlgoGP
- Use the exported strategy object from your own code
Pick it if
Cross-sectional stock prediction with machine learning at research scale.
Watch out for
Built around daily cross-sectional equity data (China and US datasets).
Qlib strengths and limitations
Strengths
- Complete ML research pipeline.
- Strong baselines and benchmarks.
- Backed by Microsoft Research.
Limitations
- Built around daily cross-sectional equity data (China and US datasets).
- Not a live-trading engine.
Qlib example
pip install pyqlibpip install pyqlib
python -m qlib.run.get_data qlib_data --target_dir ~/.qlib/qlib_data/cn_data --region cn
qrun examples/benchmarks/LightGBM/workflow_config_lightgbm_Alpha158.yamlUse Qlib with AlgoGP
AlgoGP does not add Qlib to projects automatically yet, but nothing stops you using them together. Every AlgoGP project exports plain Python with a framework-neutral strategy object, so you can call it from Qlib yourself.
- 1
Design and backtest in AlgoGP
Describe the idea to the copilot and backtest it on AlgoGP’s normalized history.
- 2
Add any bridge to get the adapter core
Adding a bridged framework (for example Backtrader) writes
frameworks/algogp_bridge.py, whoseStrategyBridge.on_bar()returns the orders the strategy wants. - 3
Call it from Qlib
Feed Qlib’s bars to
StrategyBridge, place the returned orders with Qlib, and report fills back withsync().
Qlib connects to Yahoo Finance. Each guide shows how to create the API key, which you can store in the project’s Keys & secrets.
Qlib: frequently asked questions
Can Qlib trade live?
It focuses on research and simulation; signals are exported to an execution system.
Qlib alternatives
- FinRLPythonDeep reinforcement learning library for trading from the AI4Finance Foundation: market environments, DRL agents and train-test-trade pipelines.
- PyBrokerPythonPython framework for machine-learning trading strategies: walk-forward analysis, bootstrapped metrics and a fast Numba backtesting engine.
- Alphalens ReloadedPythonFactor analysis from the Quantopian lineage: information coefficients, quantile returns and turnover to test whether an alpha factor predicts returns.
- RQAlphaPythonRicequant’s extensible Python backtesting and simulation framework for China A-shares and futures, with a mod system for data and brokers.
Independent guide. AlgoGP is not affiliated with Qlib. Features, licenses and maintenance change; check the official documentation. Nothing here is investment advice.