Real-Time Order Book Building and Snapshot Generating for High Frequency Trading on FPGA
Yao Liu, Shiyang Chen, Long Ma, Guolong Yang, Kun Wan · 2024
Stock exchanges provide tick-by-tick quotes for traders who want to obtain speed advantage by building order book and generating snapshots on their local servers. Order book building is a burdensome task for software because CPU pipelines would be occupied by a large amount of operations like sorting, table looking up, inserting and deleting. The work presented in this paper describes an FPGA solution to fully take over this task. There are two main contributions in this work. First, we map price levels of stocks directly to external DRAM addresses, which naturally solve sorting issues within one DRAM access. Second, we customize a novel two-level CACHE to manage the best bids and offers in real-time to reduce the latency of snapshot generating. In the experiment, the latency of the FPGA solution ranges from 26 to 209 ns, which is 3.5 to 37.6 times faster than the software solution. The throughput of the FPGA solution exceeds 3.26 million messages per second, offering a speedup of 4.3 to 22.3 times over the software solution. The FPGA solution also demonstrates commendable scalability.