# quantmlresearch/qlib architecture

> Architecture diagram of the GitHub repository quantmlresearch/qlib, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/quantmlresearch/qlib
- Repository: https://github.com/quantmlresearch/qlib

## Overview

Qlib is an AI-oriented quantitative investment platform. A researcher’s documented workflow moves from market data through data processing and model training to backtesting and analysis; the platform also covers alpha research, risk modeling, portfolio optimization, reinforcement learning, and online model updates. The graph combines those documented capabilities with relationships visible in the supplied source index and excerpts. Several capability paths are directory-level because their implementation files were not sampled.

Main entry points: [`qlib/data/dataset/handler.py`](https://github.com/quantmlresearch/qlib/blob/main/qlib/data/dataset/handler.py) (Dataset Handler), [`qlib/model/trainer.py`](https://github.com/quantmlresearch/qlib/blob/main/qlib/model/trainer.py) (Model Trainer), [`qlib/data/data.py`](https://github.com/quantmlresearch/qlib/blob/main/qlib/data/data.py) (Market Data), [`qlib/backtest/executor.py`](https://github.com/quantmlresearch/qlib/blob/main/qlib/backtest/executor.py) (Trade Executor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Market Data"]
  node_market_data["Market Data<br/>[data.py]"]
  node_data_cache[("Data Cache<br/>[cache.py]")]
  node_dataset["Dataset Handler<br/>[handler.py]"]
  node_processors["Data Processors<br/>[processor.py]"]
  node_contrib_data["Data Handlers"]
end

subgraph group_research["Research and Modeling"]
  node_models["ML Models"]
  node_trainer["Model Trainer<br/>[trainer.py]"]
  node_alpha_eval["Alpha Evaluation<br/>[evaluate.py]"]
  node_risk["Risk Models<br/>[base.py]"]
  node_optimizer["Portfolio Optimizers"]
  node_rl["RL Framework<br/>[trainer.py]"]
end

subgraph group_trading["Trading Simulation"]
  node_strategy["Trading Strategy<br/>[base.py]"]
  node_decision["Trade Decisions<br/>[decision.py]"]
  node_executor["Trade Executor<br/>[executor.py]"]
  node_exchange["Simulated Exchange<br/>[exchange.py]"]
  node_account["Account and Positions<br/>[account.py]"]
  node_backtest_report["Backtest Reports<br/>[report.py]"]
end

subgraph group_operations["Workflow and Serving"]
  node_init["Initialization<br/>[__init__.py]"]
  node_workflow["Experiment Workflow<br/>[recorder.py]"]
  node_online["Online Updates<br/>[manager.py]"]
  node_online_strategy["Online Strategies<br/>[strategy.py]"]
end

node_researcher(("Quant Researcher"))

node_researcher -->|"explores data"| node_market_data
node_researcher -->|"runs research"| node_workflow
node_init -->|"initializes cache"| node_data_cache
node_market_data -->|"uses cache"| node_data_cache
node_dataset -->|"uses processors"| node_processors
node_market_data -->|"feeds processing"| node_dataset
node_dataset -->|"supplies training data"| node_trainer
node_trainer -->|"trains models"| node_models
node_models -->|"produces signals"| node_alpha_eval
node_alpha_eval -->|"informs investment research"| node_risk
node_risk -->|"supports allocation"| node_optimizer
node_optimizer -->|"guides strategy"| node_strategy
node_strategy -->|"makes decisions"| node_decision
node_decision -->|"directs execution"| node_executor
node_executor -->|"executes trades"| node_exchange
node_executor -->|"updates account"| node_account
node_account -->|"provides results"| node_backtest_report
node_trainer -->|"records experiments"| node_workflow
node_online -->|"manages strategies"| node_online_strategy
node_online -->|"re-trains models"| node_trainer
node_researcher -->|"trains policies"| node_rl
node_rl -->|"supports trading"| node_strategy
node_contrib_data -->|"extends handlers"| node_dataset

click node_init "https://github.com/quantmlresearch/qlib/blob/main/qlib/__init__.py"
click node_market_data "https://github.com/quantmlresearch/qlib/blob/main/qlib/data/data.py"
click node_data_cache "https://github.com/quantmlresearch/qlib/blob/main/qlib/data/cache.py"
click node_dataset "https://github.com/quantmlresearch/qlib/blob/main/qlib/data/dataset/handler.py"
click node_processors "https://github.com/quantmlresearch/qlib/blob/main/qlib/data/dataset/processor.py"
click node_contrib_data "https://github.com/quantmlresearch/qlib/tree/main/qlib/contrib/data"
click node_models "https://github.com/quantmlresearch/qlib/tree/main/qlib/contrib/model"
click node_trainer "https://github.com/quantmlresearch/qlib/blob/main/qlib/model/trainer.py"
click node_alpha_eval "https://github.com/quantmlresearch/qlib/blob/main/qlib/contrib/evaluate.py"
click node_risk "https://github.com/quantmlresearch/qlib/blob/main/qlib/model/riskmodel/base.py"
click node_optimizer "https://github.com/quantmlresearch/qlib/tree/main/qlib/contrib/strategy/optimizer"
click node_rl "https://github.com/quantmlresearch/qlib/blob/main/qlib/rl/trainer/trainer.py"
click node_strategy "https://github.com/quantmlresearch/qlib/blob/main/qlib/strategy/base.py"
click node_decision "https://github.com/quantmlresearch/qlib/blob/main/qlib/backtest/decision.py"
click node_executor "https://github.com/quantmlresearch/qlib/blob/main/qlib/backtest/executor.py"
click node_exchange "https://github.com/quantmlresearch/qlib/blob/main/qlib/backtest/exchange.py"
click node_account "https://github.com/quantmlresearch/qlib/blob/main/qlib/backtest/account.py"
click node_backtest_report "https://github.com/quantmlresearch/qlib/blob/main/qlib/backtest/report.py"
click node_workflow "https://github.com/quantmlresearch/qlib/blob/main/qlib/workflow/recorder.py"
click node_online "https://github.com/quantmlresearch/qlib/blob/main/qlib/workflow/online/manager.py"
click node_online_strategy "https://github.com/quantmlresearch/qlib/blob/main/qlib/workflow/online/strategy.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_market_data,node_data_cache,node_dataset,node_processors,node_contrib_data toneBlue
class node_models,node_trainer,node_alpha_eval,node_risk,node_optimizer,node_rl toneAmber
class node_strategy,node_decision,node_executor,node_exchange,node_account,node_backtest_report toneMint
class node_init,node_workflow,node_online,node_online_strategy toneRose
class node_researcher toneIndigo
```

## Components

### Market Data

- [Market Data](https://github.com/quantmlresearch/qlib/blob/main/qlib/data/data.py): `qlib/data/data.py`
- [Data Cache](https://github.com/quantmlresearch/qlib/blob/main/qlib/data/cache.py): `qlib/data/cache.py`
- [Dataset Handler](https://github.com/quantmlresearch/qlib/blob/main/qlib/data/dataset/handler.py): `qlib/data/dataset/handler.py`
- [Data Processors](https://github.com/quantmlresearch/qlib/blob/main/qlib/data/dataset/processor.py): `qlib/data/dataset/processor.py`
- [Data Handlers](https://github.com/quantmlresearch/qlib/tree/main/qlib/contrib/data): `qlib/contrib/data`

### Research and Modeling

- [ML Models](https://github.com/quantmlresearch/qlib/tree/main/qlib/contrib/model): `qlib/contrib/model`
- [Model Trainer](https://github.com/quantmlresearch/qlib/blob/main/qlib/model/trainer.py): `qlib/model/trainer.py`
- [Alpha Evaluation](https://github.com/quantmlresearch/qlib/blob/main/qlib/contrib/evaluate.py): `qlib/contrib/evaluate.py`
- [Risk Models](https://github.com/quantmlresearch/qlib/blob/main/qlib/model/riskmodel/base.py): `qlib/model/riskmodel/base.py`
- [Portfolio Optimizers](https://github.com/quantmlresearch/qlib/tree/main/qlib/contrib/strategy/optimizer): `qlib/contrib/strategy/optimizer`
- [RL Framework](https://github.com/quantmlresearch/qlib/blob/main/qlib/rl/trainer/trainer.py): `qlib/rl/trainer/trainer.py`

### Trading Simulation

- [Trading Strategy](https://github.com/quantmlresearch/qlib/blob/main/qlib/strategy/base.py): `qlib/strategy/base.py`
- [Trade Decisions](https://github.com/quantmlresearch/qlib/blob/main/qlib/backtest/decision.py): `qlib/backtest/decision.py`
- [Trade Executor](https://github.com/quantmlresearch/qlib/blob/main/qlib/backtest/executor.py): `qlib/backtest/executor.py`
- [Simulated Exchange](https://github.com/quantmlresearch/qlib/blob/main/qlib/backtest/exchange.py): `qlib/backtest/exchange.py`
- [Account and Positions](https://github.com/quantmlresearch/qlib/blob/main/qlib/backtest/account.py): `qlib/backtest/account.py`
- [Backtest Reports](https://github.com/quantmlresearch/qlib/blob/main/qlib/backtest/report.py): `qlib/backtest/report.py`

### Workflow and Serving

- [Initialization](https://github.com/quantmlresearch/qlib/blob/main/qlib/__init__.py): `qlib/__init__.py`
- [Experiment Workflow](https://github.com/quantmlresearch/qlib/blob/main/qlib/workflow/recorder.py): `qlib/workflow/recorder.py`
- [Online Updates](https://github.com/quantmlresearch/qlib/blob/main/qlib/workflow/online/manager.py): `qlib/workflow/online/manager.py`
- [Online Strategies](https://github.com/quantmlresearch/qlib/blob/main/qlib/workflow/online/strategy.py): `qlib/workflow/online/strategy.py`

### Other components

- **Quant Researcher**

## Connections

- Quant Researcher → Market Data: explores data (evidence: `README.md`)
- Quant Researcher → Experiment Workflow: runs research (evidence: `README.md`)
- Initialization → Data Cache: initializes cache (evidence: `qlib/__init__.py`)
- Market Data → Data Cache: uses cache (evidence: `qlib/data/data.py`)
- Dataset Handler → Data Processors: uses processors (evidence: `qlib/data/dataset/handler.py`)
- Market Data → Dataset Handler: feeds processing (evidence: `README.md`)
- Dataset Handler → Model Trainer: supplies training data (evidence: `qlib/model/trainer.py`)
- Model Trainer → ML Models: trains models (evidence: `README.md`)
- ML Models → Alpha Evaluation: produces signals (evidence: `README.md`)
- Alpha Evaluation → Risk Models: informs investment research (evidence: `README.md`)
- Risk Models → Portfolio Optimizers: supports allocation (evidence: `README.md`)
- Portfolio Optimizers → Trading Strategy: guides strategy (evidence: `README.md`)
- Trading Strategy → Trade Decisions: makes decisions (evidence: `qlib/backtest/decision.py`)
- Trade Decisions → Trade Executor: directs execution (evidence: `qlib/backtest/executor.py`)
- Trade Executor → Simulated Exchange: executes trades (evidence: `qlib/backtest/executor.py`)
- Trade Executor → Account and Positions: updates account (evidence: `qlib/backtest/executor.py`)
- Account and Positions → Backtest Reports: provides results (evidence: `README.md`)
- Model Trainer → Experiment Workflow: records experiments (evidence: `qlib/model/trainer.py`)
- Online Updates → Online Strategies: manages strategies (evidence: `qlib/workflow/online/manager.py`)
- Online Updates → Model Trainer: re-trains models (evidence: `qlib/workflow/online/manager.py`)
- Quant Researcher → RL Framework: trains policies (evidence: `README.md`)
- RL Framework → Trading Strategy: supports trading (evidence: `README.md`)
- Data Handlers → Dataset Handler: extends handlers (evidence: `qlib/contrib/data/handler.py`)
