# hummingbot/quants-lab architecture

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

- Interactive diagram: https://gitdiagram.com/hummingbot/quants-lab
- Repository: https://github.com/hummingbot/quants-lab

## Overview

#### Purpose and entry points
QuantsLab is a Python quantitative-trading research and automation framework built around Hummingbot workflows. It collects market data, derives features, backtests/optimizes strategies, and runs configured recurring jobs. Primary entry points are the CLI and YAML-driven task runtime: `cli.py`, `core/tasks/runner.py`, and `config/tf_pipeline.yml`.

#### Task orchestration and scheduling
The core task subsystem loads task definitions, validates/instantiates registered classes, schedules execution, and persists task state. Application tasks implement concrete workflows while pipeline YAML selects cadence and parameters. Key boundaries: framework orchestration versus application-specific task implementations.
Paths: `core/tasks/orchestrator.py`, `core/tasks/registry.py`, `app/tasks/deployment/deployment_base_task.py`.

#### Market-data ingestion and persistence
Data-collection tasks acquire candles, trades, funding rates, open interest, and pool data through source adapters. The source layer abstracts CLOB, gateway, Hummingbot DB, exchange feeds, and DEX/API access; collected data is directed to application data/cache and database-backed storage.
Paths: `app/tasks/data_collection/candles_downloader_task.py`, `core/data_sources/clob.py`, `core/data_sources/market_feeds/market_feeds_manager.py`.

#### Research data model and features
Canonical structures represent candles, trading rules, backtest results, and controller performance. Feature modules transform market series into trends, volatility, volume, and strategy signals, with feature storage separating computation from persistence.
Paths: `core/data_structures/candles.py`, `core/features/feature_base.py`, `core/features/candles/trend_fury.py`.

#### Strategy/controller layer
Controllers encode executable trading logic in directional trading, market making, and generic strategies. They are the bridge from research signals/configuration to Hummingbot-oriented trading behavior; multiple implementations provide reusable and experimental strategy variants.
Paths: `app/controllers/directional_trading/macd_bb_v1.py`, `app/controllers/market_making/pmm_dynamic.py`, `app/controllers/generic/stat_arb.py`.

#### Backtesting, optimization, and quantitative workflows
The backtesting engine evaluates controllers against historical data, while optimization and triple-barrier components support parameter search and labeling/evaluation. Quantitative tasks, especially cointegration/statistical-arbitrage generation, feed deployable strategy configurations.
Paths: `core/backtesting/engine.py`, `core/backtesting/optimizer.py`, `app/tasks/quantitative_methods/cointegration/stat_arb_config_generator_task.py`.

#### Deployment, notifications, and runtime infrastructure
Deployment tasks package strategy outputs for execution, and notifier adapters publish operational/reporting events to Discord, email, Slack, or Telegram. Runtime targets Python 3.12/Conda locally or Docker for recurring tasks; MongoDB is the material persistence service, provisioned separately with an optional Mongo Express UI.
Paths: `app/tasks/deployment/implementation/stat_arb_deployment_task.py`, `core/notifiers/manager.py`, `core/services/mongodb_client.py`, `Dockerfile`, `docker-compose-db.yml`.

Main entry points: [`core/tasks/orchestrator.py`](https://github.com/hummingbot/quants-lab/blob/main/core/tasks/orchestrator.py) (Task Orchestrator), [`app/tasks/data_collection/candles_downloader_task.py`](https://github.com/hummingbot/quants-lab/blob/main/app/tasks/data_collection/candles_downloader_task.py) (Candles Downloader), [`core/tasks/runner.py`](https://github.com/hummingbot/quants-lab/blob/main/core/tasks/runner.py) (Task Runner), [`core/data_structures/candles.py`](https://github.com/hummingbot/quants-lab/blob/main/core/data_structures/candles.py) (Candles Model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Task Runtime"]
  node_cli["CLI<br/>entry point<br/>[cli.py]"]
  node_pipeline["Pipeline YAML<br/>task configuration<br/>[tf_pipeline.yml]"]
  node_runner["Task Runner<br/>runtime<br/>[runner.py]"]
  node_orchestrator["Task Orchestrator<br/>framework service<br/>[orchestrator.py]"]
  node_registry["Task Registry<br/>class registry<br/>[registry.py]"]
end

subgraph group_data["Market Data"]
  node_candles_task["Candles Downloader<br/>collection task"]
  node_source_adapters["Source Adapters<br/>data-source layer<br/>[clob.py]"]
  node_market_feeds["Market Feeds Manager<br/>feed manager"]
end

subgraph group_research["Research &amp; Trading"]
  node_candles_model["Candles Model<br/>canonical data model<br/>[candles.py]"]
  node_feature_base["Feature Framework<br/>feature layer<br/>[feature_base.py]"]
  node_trend_fury["Trend Fury<br/>candle feature<br/>[trend_fury.py]"]
  node_backtest["Backtesting Engine<br/>evaluation engine<br/>[engine.py]"]
  node_optimizer["Optimizer<br/>parameter search<br/>[optimizer.py]"]
  node_controllers["Trading Controllers<br/>strategy implementations<br/>[macd_bb_v1.py]"]
  node_stat_arb_generator["Stat-Arb Config Generator<br/>quantitative task"]
end

subgraph group_operations["Deployment &amp; Operations"]
  node_deployment_base["Deployment Task Base<br/>application task base"]
  node_mongo[("MongoDB<br/>persistence service<br/>[mongodb_client.py]")]
  node_stat_arb_deployment["Stat-Arb Deployment<br/>deployment task"]
  node_notifier["Notifier Manager<br/>notification adapter<br/>[manager.py]"]
  node_docker["Docker Runtime<br/>runtime target"]
  node_mongo_compose["Mongo Compose<br/>database provisioning"]
end

node_cli -->|"starts"| node_runner
node_pipeline -->|"configures"| node_runner
node_runner -->|"delegates to"| node_orchestrator
node_orchestrator -->|"instantiates tasks from"| node_registry
node_orchestrator -->|"persists state"| node_mongo
node_orchestrator -->|"schedules"| node_candles_task
node_orchestrator -->|"schedules"| node_stat_arb_generator
node_orchestrator -->|"schedules"| node_stat_arb_deployment
node_candles_task -->|"collects through"| node_source_adapters
node_source_adapters -->|"uses feeds"| node_market_feeds
node_candles_task -->|"stores data"| node_mongo
node_candles_task -->|"produces"| node_candles_model
node_candles_model -->|"feeds"| node_feature_base
node_feature_base -->|"implements"| node_trend_fury
node_trend_fury -->|"supplies signals"| node_controllers
node_candles_model -->|"historical input"| node_backtest
node_controllers -->|"evaluated by"| node_backtest
node_optimizer -->|"searches parameters with"| node_backtest
node_stat_arb_generator -->|"generates config for"| node_controllers
node_stat_arb_generator -->|"outputs configuration"| node_stat_arb_deployment
node_stat_arb_deployment -->|"implements"| node_deployment_base
node_orchestrator -->|"reports events"| node_notifier
node_docker -.->|"hosts"| node_runner
node_mongo_compose -.->|"provisions"| node_mongo

click node_cli "https://github.com/hummingbot/quants-lab/blob/main/cli.py"
click node_pipeline "https://github.com/hummingbot/quants-lab/blob/main/config/tf_pipeline.yml"
click node_runner "https://github.com/hummingbot/quants-lab/blob/main/core/tasks/runner.py"
click node_orchestrator "https://github.com/hummingbot/quants-lab/blob/main/core/tasks/orchestrator.py"
click node_registry "https://github.com/hummingbot/quants-lab/blob/main/core/tasks/registry.py"
click node_deployment_base "https://github.com/hummingbot/quants-lab/blob/main/app/tasks/deployment/deployment_base_task.py"
click node_candles_task "https://github.com/hummingbot/quants-lab/blob/main/app/tasks/data_collection/candles_downloader_task.py"
click node_source_adapters "https://github.com/hummingbot/quants-lab/blob/main/core/data_sources/clob.py"
click node_market_feeds "https://github.com/hummingbot/quants-lab/blob/main/core/data_sources/market_feeds/market_feeds_manager.py"
click node_mongo "https://github.com/hummingbot/quants-lab/blob/main/core/services/mongodb_client.py"
click node_candles_model "https://github.com/hummingbot/quants-lab/blob/main/core/data_structures/candles.py"
click node_feature_base "https://github.com/hummingbot/quants-lab/blob/main/core/features/feature_base.py"
click node_trend_fury "https://github.com/hummingbot/quants-lab/blob/main/core/features/candles/trend_fury.py"
click node_backtest "https://github.com/hummingbot/quants-lab/blob/main/core/backtesting/engine.py"
click node_optimizer "https://github.com/hummingbot/quants-lab/blob/main/core/backtesting/optimizer.py"
click node_controllers "https://github.com/hummingbot/quants-lab/blob/main/app/controllers/directional_trading/macd_bb_v1.py"
click node_stat_arb_generator "https://github.com/hummingbot/quants-lab/blob/main/app/tasks/quantitative_methods/cointegration/stat_arb_config_generator_task.py"
click node_stat_arb_deployment "https://github.com/hummingbot/quants-lab/blob/main/app/tasks/deployment/implementation/stat_arb_deployment_task.py"
click node_notifier "https://github.com/hummingbot/quants-lab/blob/main/core/notifiers/manager.py"
click node_docker "https://github.com/hummingbot/quants-lab/blob/main/Dockerfile"
click node_mongo_compose "https://github.com/hummingbot/quants-lab/blob/main/docker-compose-db.yml"

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_cli,node_pipeline,node_runner,node_orchestrator,node_registry toneBlue
class node_candles_task,node_source_adapters,node_market_feeds toneAmber
class node_candles_model,node_feature_base,node_trend_fury,node_backtest,node_optimizer,node_controllers,node_stat_arb_generator toneMint
class node_deployment_base,node_mongo,node_stat_arb_deployment,node_notifier,node_docker,node_mongo_compose toneRose
```

## Components

### Task Runtime

YAML-driven recurring task execution.

- [CLI](https://github.com/hummingbot/quants-lab/blob/main/cli.py): entry point · `cli.py`
- [Pipeline YAML](https://github.com/hummingbot/quants-lab/blob/main/config/tf_pipeline.yml): task configuration · Selects task cadence and parameters. · `config/tf_pipeline.yml`
- [Task Runner](https://github.com/hummingbot/quants-lab/blob/main/core/tasks/runner.py): runtime · `core/tasks/runner.py`
- [Task Orchestrator](https://github.com/hummingbot/quants-lab/blob/main/core/tasks/orchestrator.py): framework service · Loads, validates, schedules, and persists task execution. · `core/tasks/orchestrator.py`
- [Task Registry](https://github.com/hummingbot/quants-lab/blob/main/core/tasks/registry.py): class registry · `core/tasks/registry.py`

### Market Data

Acquisition, normalization, and storage.

- [Candles Downloader](https://github.com/hummingbot/quants-lab/blob/main/app/tasks/data_collection/candles_downloader_task.py): collection task · `app/tasks/data_collection/candles_downloader_task.py`
- [Source Adapters](https://github.com/hummingbot/quants-lab/blob/main/core/data_sources/clob.py): data-source layer · Abstracts CLOB, gateway, exchange, DEX/API, and Hummingbot DB sources. · `core/data_sources/clob.py`
- [Market Feeds Manager](https://github.com/hummingbot/quants-lab/blob/main/core/data_sources/market_feeds/market_feeds_manager.py): feed manager · `core/data_sources/market_feeds/market_feeds_manager.py`

### Research & Trading

Features, controllers, and quantitative evaluation.

- [Candles Model](https://github.com/hummingbot/quants-lab/blob/main/core/data_structures/candles.py): canonical data model · Represents research market series. · `core/data_structures/candles.py`
- [Feature Framework](https://github.com/hummingbot/quants-lab/blob/main/core/features/feature_base.py): feature layer · Separates feature computation from persistence. · `core/features/feature_base.py`
- [Trend Fury](https://github.com/hummingbot/quants-lab/blob/main/core/features/candles/trend_fury.py): candle feature · `core/features/candles/trend_fury.py`
- [Backtesting Engine](https://github.com/hummingbot/quants-lab/blob/main/core/backtesting/engine.py): evaluation engine · Evaluates controllers against historical data. · `core/backtesting/engine.py`
- [Optimizer](https://github.com/hummingbot/quants-lab/blob/main/core/backtesting/optimizer.py): parameter search · `core/backtesting/optimizer.py`
- [Trading Controllers](https://github.com/hummingbot/quants-lab/blob/main/app/controllers/directional_trading/macd_bb_v1.py): strategy implementations · Directional, market-making, and generic executable trading logic. · `app/controllers/directional_trading/macd_bb_v1.py`
- [Stat-Arb Config Generator](https://github.com/hummingbot/quants-lab/blob/main/app/tasks/quantitative_methods/cointegration/stat_arb_config_generator_task.py): quantitative task · Generates deployable statistical-arbitrage configurations. · `app/tasks/quantitative_methods/cointegration/stat_arb_config_generator_task.py`

### Deployment & Operations

Execution packaging, notifications, and infrastructure.

- [Deployment Task Base](https://github.com/hummingbot/quants-lab/blob/main/app/tasks/deployment/deployment_base_task.py): application task base · Boundary for application deployment workflows. · `app/tasks/deployment/deployment_base_task.py`
- [MongoDB](https://github.com/hummingbot/quants-lab/blob/main/core/services/mongodb_client.py): persistence service · Stores task state and database-backed market data. · `core/services/mongodb_client.py`
- [Stat-Arb Deployment](https://github.com/hummingbot/quants-lab/blob/main/app/tasks/deployment/implementation/stat_arb_deployment_task.py): deployment task · Packages strategy outputs for execution. · `app/tasks/deployment/implementation/stat_arb_deployment_task.py`
- [Notifier Manager](https://github.com/hummingbot/quants-lab/blob/main/core/notifiers/manager.py): notification adapter · Publishes events to Discord, email, Slack, and Telegram. · `core/notifiers/manager.py`
- [Docker Runtime](https://github.com/hummingbot/quants-lab/blob/main/Dockerfile): runtime target · Runs recurring tasks in containers. · `Dockerfile`
- [Mongo Compose](https://github.com/hummingbot/quants-lab/blob/main/docker-compose-db.yml): database provisioning · Provisions MongoDB and optional Mongo Express. · `docker-compose-db.yml`

## Connections

- CLI → Task Runner: starts
- Pipeline YAML → Task Runner: configures
- Task Runner → Task Orchestrator: delegates to
- Task Orchestrator → Task Registry: instantiates tasks from
- Task Orchestrator → MongoDB: persists state
- Task Orchestrator → Candles Downloader: schedules
- Task Orchestrator → Stat-Arb Config Generator: schedules
- Task Orchestrator → Stat-Arb Deployment: schedules
- Candles Downloader → Source Adapters: collects through
- Source Adapters → Market Feeds Manager: uses feeds
- Candles Downloader → MongoDB: stores data
- Candles Downloader → Candles Model: produces
- Candles Model → Feature Framework: feeds
- Feature Framework → Trend Fury: implements
- Trend Fury → Trading Controllers: supplies signals
- Candles Model → Backtesting Engine: historical input
- Trading Controllers → Backtesting Engine: evaluated by
- Optimizer → Backtesting Engine: searches parameters with
- Stat-Arb Config Generator → Trading Controllers: generates config for
- Stat-Arb Config Generator → Stat-Arb Deployment: outputs configuration
- Stat-Arb Deployment → Deployment Task Base: implements
- Task Orchestrator → Notifier Manager: reports events
- Docker Runtime → Task Runner: hosts
- Mongo Compose → MongoDB: provisions
