Abstract
Financial quantitative analysis requires processing vast amounts of time-series data with minimal latency. While Python’s Pandas library is widely used for its flexibility, it often fails to leverage modern hardware capabilities like SIMD and GPUs effectively. This paper introduces HXPY, a high-performance data processing package designed specifically for financial time-series. By combining a C++ backend with a user-friendly Python interface, HXPY implements low-level optimizations including SIMD vectorization, streaming algorithms, and CUDA acceleration. Our evaluations demonstrate that HXPY can outperform industry standards like Pandas and cuDF by up to several hundred times across various financial data operations.
Introduction
In the high-stakes environment of quantitative trading, computational efficiency is a primary competitive advantage. Traditional data analysis tools like Pandas, while feature-rich, are primarily single-threaded and lack deep integration with modern hardware features. Furthermore, financial data presents unique challenges, such as the frequent occurrence of "outliers" (e.g., stock suspensions represented as NaNs) that traditional libraries handle inefficiently. HXPY was developed to bridge this gap, providing a "Pandas-ready" framework that is hardware-optimized from the ground up.
System Architecture
The design of HXPY follows a layered approach to balance high-level usability with low-level performance.
As shown in the architecture diagram, the system is divided into several layers:
- Interface Layer: Provides Python and C++ APIs, along with documentation and unit tests.
- Class and Function Layers: Manage data structures like Dataframes and implement specialized financial functions (e.g., time-series and industry-grouped functions).
- Operations and Implementation Layers: Handle the core computational logic using SIMD, CUDA, and multi-threading (OpenMP), leveraging libraries such as Eigen and Cub.
Performance Optimizations
HXPY employs several key strategies to maximize throughput:
- Row-Major Storage: Optimized for "cross-sectional" analysis, a common requirement in finance where multiple stocks are compared at a single timestamp.
- SIMD & SIMT Acceleration: The package utilizes AVX-512 and AVX2 instruction sets for CPU vectorization and CUDA for GPU parallelization.
- Streaming Algorithms: For time-series window functions (e.g., moving averages), HXPY uses streaming updates. This reduces computational complexity from $O(nmT)$ to $O(nm)$, making execution time independent of the window size $T$.
- Memory Management: HXPY ensures data alignment for SIMD and supports zero-copy modifications to avoid the overhead of data duplication. By copying column data into temporary 1D arrays before processing, the system significantly reduces non-contiguous memory access bottlenecks.
Evaluation and Results
HXPY was benchmarked using daily stock data (2006–2021) and high-frequency 1-minute data (4.34GB). The results show dramatic gains across all metrics:
- I/O Performance: HXPY achieved over 5x speedup in CSV reading compared to Pandas.
- Element-wise Functions: For operations like
relu, HXPY was up to 298x faster than Pandas through SIMD and C++ lambda functions. - Multi-threading: HXPY outperformed Modin (a multi-threaded Pandas variant) by 2x to 200x, largely due to its lightweight OpenMP threading model.
- GPU Acceleration: The CUDA implementation outperformed NVIDIA’s cuDF by 2x to 400x on specific tasks like power calculations.
Conclusion and Future Work
HXPY is a robust, production-ready framework currently deployed on over 10,000 CPU cores at the International Digital Economy Academy (IDEA). While it offers significant performance advantages, the authors acknowledge current limitations in GPU memory constraints and partial CUDA support for complex operations like rank. Future work will focus on implementing Just-In-Time (JIT) compilation and a dynamic operator registration system to further enhance user flexibility and performance.
Summary updated