We Just Made Trading Signals _Microsecond-Level Easy_ — 100 Factors in 40µs
Quantitative trading boils down to one core objective: identifying and exploiting market inefficiencies. Like a gecko frozen in anticipation of its prey, the quant trader must act with precision the instant an opportunity emerges—then resume the wait.
In today's intensely competitive landscape, however, spotting opportunities and seizing them are two entirely different challenges. Discovery hinges on creative factor design and modeling; capture depends on raw speed and technical execution. This is a ruthless contest governed by hardware constraints, exhaustive optimization cycles, and one uncompromising imperative: be fast—then be faster.
Consequently, C++ has emerged as the industry standard for ultra-low-latency trading infrastructure. But this choice comes with significant costs: while C++ excels at runtime performance, it considerably slows the development lifecycle, limiting agility and escalating maintenance overhead.
Now, there's a compelling alternative. DolphinDB's scripting environment enables traders to construct factor models and strategies that combine Python-like development speed with production performance matching elite C++ implementations. The critical question is whether this dual advantage in engineering efficiency and computational speed could fundamentally transform quantitative trading.
To put this to the test, we benchmarked the computational performance of Swordfish by testing nearly 150 factors of varying complexity, and comparing its latency against a highly optimized C++ framework.
The findings are striking:
- For the ten most intricate, fully custom Level-2 factors, Swordfish recorded a minimum latency of just 4.4 microseconds.
- Across 100 production-grade factors deployed in live trading environments, the average latency was approximately 40 microseconds.
Pushing Performance Boundaries: 100-Factor Computation in 40 Microseconds
In this benchmark, we assessed the performance and reliability of the Swordfish through two comprehensive evaluations.
The initial phase analyzed 40 factors constructed from Level 1 market data (including standard quotes and trades) and Level 2 market data (encompassing order book depth and queue information). We measured latency for single-factor execution and ten-factor batches, while monitoring the marginal latency increase as each additional factor was introduced.
In the subsequent phase, we examined 100 production-ready factors currently deployed in live trading environments. This comparison pitted Swordfish against a rigorously optimized native C++ factor computation engine, with particular attention to how concurrent processing impacts overall system reliability.
Our test dataset comprised 10 minutes of Level 2 market data spanning 645 securities—representing 5.21 million individual data records. All performance tests were executed on an 8-core server infrastructure provided by Rongchaowei.
Latency Results: Single-Factor vs. Ten-Factor Performance Across Complexity Tiers

Whether processing straightforward or highly complex factors, Swordfish consistently delivered single-factor latency between 1–2 microseconds. When computing 10 factors concurrently, average latency held steady at approximately 4 microseconds.
The stability metrics are equally impressive. For the most computationally intensive Level 2 custom factors, each additional factor contributed only 260 nanoseconds of marginal latency—demonstrating exceptional scalability and predictable performance characteristics.
Swordfish Scripting vs. C++: Head-to-Head Performance with 100 Production Factors
In the second phase of our evaluation, we selected 100 production-grade C++ indicators—all highly complex Level 2 custom factors—and reimplemented them using DLang (DolphinDB's scripting language) to benchmark Swordfish's computational performance.
The findings demonstrate that Swordfish now matches the performance of meticulously optimized C++ computation engines.
- 100 Factors computed in 40 μs: Under identical conditions, the conventional C++ implementation recorded an average latency of approximately 139 μs, whereas Swordfish achieved an average of just 42 μs. Across 100 factors, average latency measured 42.7 μs with a 99th percentile of 45.9 μs—demonstrating exceptional performance consistency. This improvement in computational speed directly translates to higher strategy win rates, enabling traders to capture fleeting opportunities that would otherwise be lost to latency delays.
| 100 Factors | Min(μs) | Max(μs) | Avg(μs) | Median(μs) | p99(μs) |
|---|---|---|---|---|---|
| Swordfish | 40.1 | 75.0 | 42.7 | 42.6 | 45.9 |
- Multi-concurrency stability: Under concurrent workloads, 99% of requests completed within 46 μs , with the deviation between median and mean latency consistently below 3%—indicating that strategy execution remains virtually immune to performance jitter. This combination of low latency and high stability ensures that strategies won't produce false signals due to computational fluctuations, even during extreme market conditions.
As concurrency scaled from 1 to 6 parallel tasks, average latency increased only marginally—from 42.7 to 44.4 μs—representing approximately 4% variance. This demonstrates that Swordfish can reliably run multiple independent strategy instances on a single server, each monitoring different securities or factor combinations, with negligible performance degradation.
| 100 Factors | Concurrency | Min (μs) | Max (μs) | Avg (μs) | Median (μs) | P99 (μs) |
|---|---|---|---|---|---|---|
| Test 1 | 1 | 40.1 | 75.0 | 42.7 | 42.6 | 45.9 |
| Test 2 | 2 | 39.8 | 81.0 | 43.0 | 42.9 | 46.5 |
| Test 3 | 4 | 40.3 | 86.1 | 43.8 | 43.6 | 48.0 |
| Test 4 | 6 | 40.2 | 136.5 | 44.4 | 44.3 | 49.2 |
How DolphinDB Achieves This Engineering Breakthrough
C++ has long been synonymous with high performance in quantitative trading. So how did DolphinDB transform a complex framework into one where users simply write factors and strategies—yet achieve execution efficiency rivaling high-performance C++? The answer lies in deep industry expertise combined with comprehensive product optimization.
In simple terms, Swordfish is an embedded version of DolphinDB. It integrates seamlessly with existing trading systems, delivering DolphinDB's robust computational capabilities without the overhead of inter-process communication. To achieve C++-comparable performance, we've implemented end-to-end optimizations across the computation engine's data structures, scripting language, low-latency operators, and overall architectural design.
- Data Architecture : Row-based storage with scalar computation enables continuous processing of single-row data in memory, improving CPU cache hit rates by an order of magnitude.
- Script Execution : Type binding and memory pre-allocation occur at compile time, eliminating runtime dynamic construction and type checking—resulting in instruction flows equivalent to hand-written native C++ code.
- Engineering Implementation : Pre-allocated static buffer pools combined with lock-free atomic operations reduce synchronization overhead to nanosecond levels, with zero memory allocation and zero lock contention in critical paths.
- Operator Level : Most DolphinDB operators are already written in C++, delivering computational efficiency identical to native C++ code. Additionally, the majority of operators employ incremental algorithms that process only changed data in streaming scenarios rather than full recalculation—dramatically accelerating data processing throughput.
For in-depth technical analysis and architectural details, stay tuned for the upcoming White Paper: Swordfish Low-Latency Computing.
Beyond Performance: A Paradigm Shift
Behind the dramatic performance leap lies something even more significant: DolphinDB is fundamentally transforming the research-to-trading architecture across the industry.
Under traditional frameworks, launching a strategy from initial concept to production requires a lengthy and complex journey. To balance research flexibility with trading performance, teams are forced to maintain parallel codebases in Python and C++—a conversion process that is both intricate and time-consuming.
DolphinDB's unified batch-streaming architecture genuinely bridges the gap between research and production trading. Powered by the Swordfish low-latency framework, researchers can focus almost entirely on logic and creative problem-solving rather than engineering implementation details—while still meeting the stringent low-latency requirements of high-performance trading systems.
With the impressive capabilities demonstrated by Gemini 3 in testing, we're beginning to see an efficient workflow built on DolphinDB that combines exceptional live trading performance + unified batch-streaming architecture + AI assistance. We believe that in the near future, as AI continues to evolve, engineering implementation will no longer be a barrier for those with breakthrough ideas—from concept to strategy, liberating creativity from the constraints of code.