A Reference Architecture for Cryptocurrency Quantitative Trading Platforms

DolphinDB
2026-05-28

1. Market Data Processing

In quantitative trading research, market data is the core for strategy development, factor construction, backtesting, simulated trading, and live trading. DolphinDB integrates a high-performance distributed storage engine with a streaming computation framework, enabling efficient storage and batch processing of massive data while also supporting real-time computation and persistence of streaming data.

The processing workflow is organized into three stages: ingestion, computation, and consumption.

Data ingestion: This solution integrates data sources from two major cryptocurrency exchanges—Binance and OKX. For different data types, it provides best-practice database and table designs, covering tick data, trading data, OHLC data, funding rate data, liquidation data, and more. In addition, it supports customizing the cryptocurrency list to meet diverse data requirements. DolphinDB supports acquiring trading data through the following tools:

  • APIs: APIs for multiple programming languages, including Python, C++, Java, and Go.
  • Plugins: Data communication plugins such as httpClient and WebSocket.

To address issues such as network interruptions, exchange API errors, and database errors, this solution provides a comprehensive monitoring, alerting, and data backfill mechanism to prevent data loss. The specific methods include:

  • Writing real-time streaming data to stream tables on two servers simultaneously, with key-based deduplication to mitigate the impact of network disruptions.
  • Automatically retrying connections upon abnormal disconnections, caching data locally, and reloading them into the database once the connection is restored.
  • Periodically monitoring the status of stream tables and databases, and triggering alerts promptly when anomalies are detected.
  • Periodically validating the completeness of OHLC data for the previous trading day and re-fetching missing data when necessary.

Computation: DolphinDB provides a powerful computation framework that supports both batch and streaming processing, including real-time snapshot aggregation, batch and real-time factor computation, and real-time data storage into databases.

  • Streaming engines: DolphinDB provides multiple built-in streaming engines, such as the time-series engine (e.g., used to generate OHLC bars at different frequencies), the reactive state engine (e.g., used to cleanse data in real time), join engines (e.g., used to aggregate snapshot data), and the cross-sectional engine (e.g., used to rank cryptocurrency types).
  • High-performance batch processing: DolphinDB supports distributed batch processing and comes with multiple factor libraries and more than 2,000 optimized functions. Its powerful programming language enables efficient processing and analysis of large-scale datasets.

Consumption: Results computed by DolphinDB can be stored in DFS tables, in-memory tables, or stream tables. Consumers can subscribe to stream tables in real time to obtain the latest market data for simulated or live trading. Alternatively, computation results can be accessed in real time through APIs or pushed via message middleware.

2. Unified Stream and Batch Processing

Factor research remains central to quantitative strategy development. Factors are quantitative metrics that capture market characteristics and reflect price dynamics and risk structures, forming the foundation of model prediction and signal generation.

Traditional quantitative research platforms often adopt a dual-system architecture: using scripting languages like Python for strategy and factor development, and high-performance languages such as C++ for real-time computation in production. This approach not only incurs high development and maintenance costs, but also risks inconsistencies between batch and streaming results.

DolphinDB’s unified stream and batch processing framework eliminates this issue by enabling a single codebase that allows seamless migration of factor logic from development to real-time computation. This ensures consistent results between research and live trading while significantly reducing development costs and maintenance complexity.

Based on DolphinDB’s built-in 191 Alpha and WorldQuant 101 Alpha factor libraries, this solution supports both batch and streaming computations for these factors, along with a highly extensible factor storage architecture. User-defined factors can also be developed as needed.

On this foundation, machine learning models, such as LSTM, XGBoost, and Transformer, are trained on existing factors in a Python environment, with full support for data access, preprocessing, and model training. Trained models can be loaded into DolphinDB via the GpuLibTorch plugin for backtesting and simulated trading, enabling real-time trading signal generation. Leveraging these capabilities, this solution delivers an end-to-end pipeline from factor development and streaming-batch computation, to Python-based model training and real-time trading signal generation.

3. Backtesting and Simulated Trading

Before being deployed in live trading, quantitative strategies are subjected to extensive backtesting and simulation to validate their effectiveness and feasibility. DolphinDB provides a comprehensive backtesting and simulation framework for cryptocurrency quantitative trading, featuring core components such as historical market data replay, real-time data ingestion, an order matching simulator, and a backtesting engine.

  • Historical data replay: In simulated trading, quantitative strategies usually process real-time data in an event-driven manner. To ensure consistent strategy logic across backtesting and simulated trading, DolphinDB provides a data replay mechanism that feeds historical market data into the backtesting engine in strict chronological order, reproducing real trading conditions.

  • Real-time data ingestion: In simulated trading, the DolphinDB backtesting engine supports continuous ingestion of streaming data. During execution, results such as trade details, real-time positions, and account equity are written to stream tables in real time.
  • Backtesting plugin: The DolphinDB backtesting plugin includes a built-in order matching simulator optimized to reflect real-world matching logic, enabling more accurate evaluation and prediction of strategy performance in live trading. The plugin consists of four core components: user-defined strategy functions, strategy configuration and creation, market data replay, and execution of the backtesting engine. It supports snapshot and minute-level cryptocurrency market data, as well as multi-account management.

To reduce strategy development costs, we focus on real-world quantitative trading requirements to provide an integrated backtesting and simulation solution. The solution unifies market data replay and processing, backtesting and simulation engine creation, strategy development and code management, strategy visualization and management, and user-level strategy permission control. This allows developers to focus solely on strategy logic, enabling both individual users and quantitative trading teams to conduct efficient research and development with minimal code and a low learning curve.

1.4 Live Trading

After thorough backtesting and simulation, strategy researchers aim to deploy high-performing strategies in live cryptocurrency markets to generate real returns. To support this transition, this solution integrates with exchange order and account APIs and provides a live trading module fully consistent with the simulation logic. This enables a true “single codebase” approach across backtesting, simulation, and live trading. This solution supports both Binance and OKX, offering capabilities such as order placement and cancellation, querying open orders, and retrieving trade details. In addition, it incorporates risk metrics to build real-time risk control models for timely monitoring and alerting of account conditions.

1.5 Real-Time Risk Control

The cryptocurrency market is highly volatile, offering significant return potential alongside substantial risk. In practice, many existing solutions compute risk metrics by directly consuming exchange-provided fields such as margin usage and unrealized profit and loss (P&L). Although simple, this approach has several limitations:

  • Risk data provided by exchanges often has low update frequency or high latency, making it difficult to promptly reflect risks caused by rapid market movements.
  • It does not support portfolio-level risk computation across multiple accounts.
  • It cannot be combined with simulated market data for scenario analysis and stress testing.

To address these issues, we provide a DolphinDB-based real-time risk control solution for cryptocurrency trading. By continuously ingesting exchange account data and periodically computing key metrics such as portfolio’s net asset value, position P&L, total asset value, and leverage ratio, this solution enables timely monitoring and alerting of account risk, helping investors better understand and manage their investment risks. Compared with traditional risk control approaches, this solution offers the following advantages:

  • Stronger real-time performance: Compared with exchange-provided leverage estimates, this solution captures market changes promptly and issues real-time risk alerts, ensuring superior timeliness.
  • Real-time data persistence: Account information and risk metrics are persisted in real time, enabling advanced analysis, scenario simulation, and stress testing.
  • High extensibility: You can flexibly modify and extend risk metric computation to meet diverse risk management requirements across different scenarios.
  • Isolation from business logic: The risk control module operates independently from trading logic and runs on read-only account data, ensuring the stability and continuity of the trading system.

Conclusion

This article outlined a reference architecture for constructing a full-lifecycle cryptocurrency quantitative trading platform, spanning market data ingestion, unified stream–batch factor computation, backtesting, live execution, and real-time risk control.

Rather than relying on separate research and production systems, the design emphasizes a single computational core where historical analysis and real-time processing share the same data model and execution logic. In practice, this reduces duplicated development effort, minimizes discrepancies between offline research and online trading, and simplifies operational maintenance.

For teams facing rapidly growing data volumes and increasing strategy complexity, adopting an integrated architecture can provide a more sustainable foundation for future expansion—while preserving the flexibility required to incorporate new models, exchanges, and risk frameworks.