Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Building Low Latency Applications with C++

You're reading from   Building Low Latency Applications with C++ Develop a complete low latency trading ecosystem from scratch using modern C++

Arrow left icon
Product type Paperback
Published in Jul 2023
Publisher Packt
ISBN-13 9781837639359
Length 506 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Sourav Ghosh Sourav Ghosh
Author Profile Icon Sourav Ghosh
Sourav Ghosh
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

Preface 1. Part 1:Introducing C++ Concepts and Exploring Important Low-Latency Applications
2. Chapter 1: Introducing Low Latency Application Development in C++ FREE CHAPTER 3. Chapter 2: Designing Some Common Low Latency Applications in C++ 4. Chapter 3: Exploring C++ Concepts from A Low-Latency Application’s Perspective 5. Chapter 4: Building the C++ Building Blocks for Low Latency Applications 6. Part 2:Building a Live Trading Exchange in C++
7. Chapter 5: Designing Our Trading Ecosystem 8. Chapter 6: Building the C++ Matching Engine 9. Chapter 7: Communicating with Market Participants 10. Part 3:Building Real-Time C++ Algorithmic Trading Systems
11. Chapter 8: Processing Market Data and Sending Orders to the Exchange in C++ 12. Chapter 9: Building the C++ Trading Algorithm’s Building Blocks 13. Chapter 10: Building the C++ Market Making and Liquidity Taking Algorithms 14. Part 4:Analyzing and Improving Performance
15. Chapter 11: Adding Instrumentation and Measuring Performance 16. Chapter 12: Analyzing and Optimizing the Performance of Our C++ System 17. Index 18. Other Books You May Enjoy

What this book covers

Chapter 1, Introducing Low Latency Application Development in C++, introduces the desired behavior and performance profile of low latency applications. It also discusses what attributes of the C++ programming language have made it the preferred language for low latency application development. This chapter also discusses some of the most important low latency applications in different business areas.

Chapter 2, Designing Some Common Low Latency Applications in C++, dives into a discussion of the technical details driving some important low latency applications in practice. This chapter explores the details of low latency applications, such as live video streaming, online and offline gaming applications, Internet of Things (IoT) applications, and low latency electronic trading.

Chapter 3, Exploring C++ Concepts from a Low Latency Application’s Perspective, jumps into the details of the C++ programming language from the perspective of low latency application development. It will discuss how to approach the design and development of these applications in C++ and best practices. It will discuss the technical details of the C++ programming language itself and discuss which features are particularly helpful for low latency applications, along with which features to avoid when trying to boost performance. This chapter will also dive into all the modern compiler optimization techniques employed by modern C++ compilers, as well as the optimization parameters and flags supported in the GCC compiler.

Chapter 4, Building the C++ Building Blocks for Low Latency Applications, implements some of the basic C++ building blocks that find use in a lot of low latency applications. The first component built in this chapter is a threading library to support multi-threaded processing in low latency applications. The second component is a memory pool abstraction that avoids dynamic memory allocations, which are extremely slow. This chapter then builds a low latency lock-free queue to transfer generic data between threads without the use of locks, which are too slow for many low latency applications. The chapter also builds a flexible and low latency logging framework. Finally, this chapter will build a library of utilities and classes to support TCP and UDP network socket operations.

Chapter 5, Designing Our Trading Ecosystem, discusses the theory, requirements, and design of a full electronic trading ecosystem and all the components that we will build from scratch in C++ over the next few chapters. This chapter will describe the requirements and design of the matching engine at the trading exchange, which is responsible for executing orders against each other. We will also describe the order server and market data publisher components, which communicate with market participants. We will also discuss the requirements and design of the order gateway client and market data consumer components that exist in trading clients’ systems to communicate with the exchange. This chapter concludes by describing and designing the trade engine framework used to build and run different trading algorithms in the clients’ systems.

Chapter 6, Building the C++ Matching Engine, describes the details behind the design of the matching engine component at the exchange, which is responsible for building the limit order book and performing matching between client orders. The limit order book tracks all orders sent by all market participants. The chapter then fully implements the matching engine and limit order book components in C++ with all the functionality they need.

Chapter 7, Communicating with Market Participants, describes the details behind the design of the market data publisher and order server components at the exchange, which are responsible for publishing market data updates and communicating with the trading clients. It then fully implements these two components in C++ with all the functionality they need. This chapter concludes by building the binary to be used as the electronic trading exchange, tying together components from Chapter 6 and Chapter 7.

Chapter 8, Processing Market Data and Sending Orders to the Exchange in C++, describes the details behind the design of the market data consumer and the limit order book in the trading strategy framework, which are responsible for consuming market data updates and building order books in clients’ systems. This chapter will also discuss the order gateway in the trading clients’ systems that is used to communicate with the exchange and send orders. This chapter then fully implements these three components in C++ with all the needed functionality.

Chapter 9, Building the C++ Trading Algorithm Building Blocks, describes the design of the trading strategy framework and its sub-components, which will be used to run the trading algorithms. We will implement the full framework in C++, including all the components to track positions, profits, and losses, compute trading features/signals to build intelligence, send and manage live orders in the market, and perform risk management.

Chapter 10, Building the C++ Market Making and Liquidity Taking Algorithms, completes the C++ implementation of the entire electronic trading ecosystem. This chapter builds the market-making and liquidity-taking trading algorithms in the framework we built in the previous chapter. Before we implement the trading algorithms, we will discuss the trading behavior of these algorithms, the motivation behind building them, and how these strategies aim to profit. This chapter also builds the trade engine framework needed to build the final trading client application, tying together components from Chapter 8, Chapter 9, and Chapter 10. This chapter concludes by running a fully electronic trading ecosystem and understanding the interactions between the different exchange and trading client components.

Chapter 11, Adding Instrumentation and Measuring Performance, creates a system to measure the performance of our low latency components at a higher granularity level. We will also add a system to timestamp order and market data events through our system as they move from component to component. This chapter concludes by rerunning our electronic trading ecosystem with the performance measurement system, generating performance data.

Chapter 12, Analyzing and Optimizing the Performance of Our C++ System, starts off by analyzing and visualizing the performance data from the previous chapter. It then presents specific tips and techniques that can be used to optimize the performance of our electronic trading components and the overall ecosystem. It implements some of the performance optimization ideas and benchmarks the performance improvements. This chapter concludes by presenting a couple of possible future enhancements to the electronic trading system that was built in this book, and implements and benchmarks one such idea.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime