How hummingbot/quants-lab works
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: orchestrator.py Task Orchestrator · candles_downloader_task.py Candles Downloader · runner.py Task Runner · candles.py Candles Model
Components 21
Task Runtime
YAML-driven recurring task execution.
- CLI
cli.py - Pipeline YAML · Selects task cadence and parameters.
config/tf_pipeline.yml - Task Runner
core/tasks/runner.py - Task Orchestrator · Loads, validates, schedules, and persists task execution.
core/tasks/orchestrator.py - Task Registry
core/tasks/registry.py
Market Data
Acquisition, normalization, and storage.
- Candles Downloader
app/tasks/data_collection/candles_downloader_task.py - Source Adapters · Abstracts CLOB, gateway, exchange, DEX/API, and Hummingbot DB sources.
core/data_sources/clob.py - Market Feeds Manager
core/data_sources/market_feeds/market_feeds_manager.py
Research & Trading
Features, controllers, and quantitative evaluation.
- Candles Model · Represents research market series.
core/data_structures/candles.py - Feature Framework · Separates feature computation from persistence.
core/features/feature_base.py - Trend Fury
core/features/candles/trend_fury.py - Backtesting Engine · Evaluates controllers against historical data.
core/backtesting/engine.py - Optimizer
core/backtesting/optimizer.py - Trading Controllers · Directional, market-making, and generic executable trading logic.
app/controllers/directional_trading/macd_bb_v1.py - Stat-Arb Config Generator · 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 · Boundary for application deployment workflows.
app/tasks/deployment/deployment_base_task.py - MongoDB · Stores task state and database-backed market data.
core/services/mongodb_client.py - Stat-Arb Deployment · Packages strategy outputs for execution.
app/tasks/deployment/implementation/stat_arb_deployment_task.py - Notifier Manager · Publishes events to Discord, email, Slack, and Telegram.
core/notifiers/manager.py - Docker Runtime · Runs recurring tasks in containers.
Dockerfile - Mongo Compose · Provisions MongoDB and optional Mongo Express.
docker-compose-db.yml
Connections 24
- 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