Designing the C++ matching engine in a trading exchange
In this section, we will discuss the matching engine component inside the electronic trading exchange system introduced in the previous section. The first thing we will do is understand what purpose the matching engine serves and why it is needed.
Understanding the purpose of the matching engine
In the electronic trading ecosystem consisting of a single trading exchange, generally, there is a single exchange that is responsible for accepting and managing orders from numerous market participants. The matching engine in this case accepts different kinds of orders that the participants are allowed to send for any given trading instrument. An order is simply a request sent by any market participant to the trading exchange to convey their interest in buying or selling a tradeable product. Every time a new order is received by the matching engine from the order gateway server infrastructure, it checks to see whether this new order...