Abstract
Concurrent programming is essential to exploit parallel processing capabilities of modern multi-core CPUs. While there exist many languages and tools to simplify the development of concurrent programs, they are not always readily applicable to domain-specific problems that rely on complex shared data structures associated with various semantics (e.g., priorities or consistency). In this paper, we explore such a domain-specific application from the financial field, where a data structure—an order book—is used to store and match orders from buyers and sellers arriving at a high rate. This application has interesting characteristics as it exhibits some clear potential for parallelism, but at the same time it is relatively complex and must meet some strict guarantees, notably w.r.t. the ordering of operations. We first present an accurate yet slightly simplified description of the order book problem and describe the challenges in parallelizing it. We then introduce several approaches for introducing concurrency in the shared data structure, in increasing order of sophistication starting from lock-based techniques to partially lock-free designs. We propose a comprehensive workload generator for constructing histories of orders according to realistic models from the financial domain. We finally perform an evaluation and comparison of the different concurrent designs.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
To avoid possible confusion with the word “order” used to designate trading requests and for prioritizing operations (arrival and processing order), we will only use it in the former sense and resort to alternative expressions for the latter.
- 2.
We assume that this queue is thread-safe as processing threads may dequeue orders concurrently with one another and with the (unique) thread that enqueues incoming orders.
- 3.
Some implementation details, such as avoiding a second traversal of the heap by keeping track of locked queues, are omitted for simplicity.
- 4.
java.util.concurrent.ConcurrentSkipListMap.
- 5.
While the algorithms do not use explicit locks, they are not completely “lock-free” as in some situations a thread may be blocked waiting for the status flag to be updated by another thread. Techniques based on “helping” could be used to avoid such situations, at the price of increased complexity in the algorithms. We therefore slightly abuse the word “lock-free” in the rest of the paper.
References
Ende, B., Uhle, T., Weber, M.C.: The impact of a millisecond: measuring latency effects in securities trading. In: Wirtschaftsinformatik Proceedings, Paper 116 (2011)
WIRED: Raging bulls: how wall street got addicted to light-speed trading (2012). http://www.wired.com/2012/08/ff_wallstreet_trading/2/
Leber, C., Geib, B., Litz, H.: High frequency trading acceleration using FPGAs. In: International Conference on Field Programmable Logic and Applications, FPL (2011)
Preis, T.: Ökonophysik - Die Physik des Finanzmarktes. Springer, Wiesbaden (2011)
Maslov, S.: Simple model of a limit order-driven market. Phys. A Stat. Mech. Appl. 278(3), 571–578 (2000)
Maslov, S., Mills, M.: Price fluctuations from the order book perspective - empirical facts and a simple model. Phys. A Stat. Mech. Appl. 299(1), 234–246 (2001)
Lea, D.: Concurrent Programming in Java: Design Principles and Patterns. Addison-Wesley, Boston (1996)
Bartolozzi, M.: Price variations in a stock market with many agents. Eur. Phys. J. B 78(2), 265–273 (2010)
Bak, P., Paczuski, M., Shubik, M.: Price variations in a stock market with many agents. Phys. A Stat. Mech. Appl. 246(3–4), 430–453 (1997)
Gabaix, X.: Power laws in economics and finance, Technical report. National Bureau of Economic Research (2008)
Bouchaud, J.-P., Mézard, M., Potters, M.: Statistical properties of stock order books: empirical results and models. Quant. Finan. 2(4), 251–256 (2002)
Khanna, K., Smith, M., Wu, D., Zhang, T.: Reconstructing the order book, Technical report. Stanford University (2009)
Singla, A., Chandrasekaran, B., Godfrey, P.B., Maggs, B.: The internet at the speed of light. In: 13th ACM Workshop on Hot Topics in Networks, HotNets (2014)
Thompson, M., Farley, D., Barker, M., Gee, P., Stewart, A.: Disruptor: high performance alternative to bounded queues for exchanging data between concurrent threads. White paper (2011). http://disruptor.googlecode.com/files/Disruptor-1.0.pdf
Shetty, Y., Jayaswal, S.: The order-matching engine. In: Practical .NET for Financial Markets. Apress, pp. 41–103 (2006)
Huang, W., Lehalle, C.-A., Rosenbaum, M.: Simulating, analyzing order book data: the queue-reactive model. J. Am. Stat. Assoc. 110(509), 107–122 (2013)
Cont, R., Stoikov, S., Talreja, R.: A stochastic model for order book dynamics. J. Am. Stat. Assoc. 58(3), 549–563 (2010)
Kercheval, A.N., Zhang, Y.: Modelling high-frequency limit order book dynamics with support vector machines. Quant. Financ. 15(8), 1315–1329 (2015)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2016 Springer International Publishing AG
About this paper
Cite this paper
Barazzutti, R.P., Hayduk, Y., Felber, P., Rivière, E. (2016). Exploiting Concurrency in Domain-Specific Data Structures: A Concurrent Order Book and Workload Generator for Online Trading. In: Abdulla, P., Delporte-Gallet, C. (eds) Networked Systems. NETYS 2016. Lecture Notes in Computer Science(), vol 9944. Springer, Cham. https://doi.org/10.1007/978-3-319-46140-3_2
Download citation
DOI: https://doi.org/10.1007/978-3-319-46140-3_2
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-46139-7
Online ISBN: 978-3-319-46140-3
eBook Packages: Computer ScienceComputer Science (R0)