๐๐ซ๐๐๐ข๐ง๐ ๐
๐ฅ๐จ๐ฐ
๐น Steps 1-4: Bob wants to buy 100 shares of Microsoft at a price of $247. The order is small, so it can go through DMA (Direct Market Access) to the exchange. The exchange gateway is responsible to normalize the order based on the exchangeโs requirements and route to the exchange that provides the best price.
๐น Steps 5-6: The buy order is sent to the exchangeโs trading engine, which validates the order and maintains the order state. The order goes to the ๐ฆ๐๐ญ๐๐ก๐ข๐ง๐ ๐๐ง๐ ๐ข๐ง๐ to find a match (same price, different buy/sell direction). The matching engine maintains an order book. Letโs assume Bobโs order cannot find a match at a price of $247, and stays in the order book, waiting to be taken.
๐น Steps 7-10: Alice wants to sell 10000 Microsoft shares at a price of $247. The sell order goes through the ๐๐ฅ๐ ๐จ๐ซ๐ข๐ญ๐ก๐ฆ ๐ญ๐ซ๐๐๐ข๐ง๐ ๐๐ง๐ ๐ข๐ง๐ because it is relatively large, and Alice wants to minimize the market impact. The order is split into smaller orders and sent to the exchange.
๐น Steps 11-12: One of Aliceโs split orders matches Bobโs buy order in the matching engine: Bob gets a โfully filledโ message, and Alice gets a โpartially filledโ message. This trade is done.
๐๐๐ซ๐ค๐๐ญ ๐๐๐ญ๐ ๐
๐ฅ๐จ๐ฐ
๐น Steps D1-D4:ย Stock trading relies heavily on market data. The order book data and the candlestick chart are published via the market data publisher and exposed to various parties via the data service. The broker then listens to the data service and provides the data to the trading engines.
๐๐๐ฉ๐จ๐ซ๐ญ๐ข๐ง๐ ๐
๐ฅ๐จ๐ฐ
๐น Steps R1-R3: The reporter receives trading messages from the trading engines and persists them into the databases. These are the ๐๐จ๐จ๐ค๐ฌ ๐๐ง๐ ๐ซ๐๐๐จ๐ซ๐๐ฌ for the broker and the exchange