Stock Exchanges’ Order Matching System
Investing in stocks and other financial products are now something common among people. Until few decades ago, trading stocks or any other financial devices were done over the counter (OTC), and was probably not as easily available for most of the people to participate. But with the development of online trading and various stock exchange platforms, now anyone of us can own stocks of our favorite companies. I got curious of how these online platforms replicate the OTC way of trading stocks, and decided to take a further look into it.
Over-The-Counter (OTC) is pretty self-explanatory. Back then, people would shout out their ask price (if selling) and bid price (if buying) over the counter, and if two parties were able to reach an agreement on a certain price, trades were made. This is where the so-called bid-ask spread came from, as sellers wanted to sell at higher price, while buyers wanted to buy at lower price. Until the two parties meet at the middle ground in-between the bid-ask spread, no trades were made.
In today’s world, trades can be easily made online. While OTC methods allowed direct negotiating, the number of traders in the market was limited hence the number of orders were also limited. But as online stock exchanges were developed, now millions of users can join the market, post the price they want, and once the market finds a match… BOOM! The order is filled. It is now that easy.
But some of you now may wonder, how are the bid-ask spread narrowed down to meet each other so that a trade can actually happen? Or say, how are orders matched?
Most of the stock exchange systems use either the First-In-First-Out (FIFO) way of matching orders, or the Pro-rata way, and both have their pros and cons. The FIFO algorithm, also called the Price/Time algorithm, prioritizes orders with better price, and made first. So when two orders are submitted at the same price, the order submitted first will fulfilled first. But if the latter order has a better price (narrowed the bid-ask spread), this order will be matched first. This algorithm may seem the fairest, as it tackles the two most important factors in trading — price and time. It seems so natural that if I am willing to buy at a higher price than the other person (or sell lower than the other person), my order will be more popular for the other side of the trade. If the same price, of course I should be fulfilled first. I was in the line before the other guy, right?
But this way can pose some inefficiency in the system, as people who were late will be discouraged to even place an order. When there are millions of users in the stock exchange platform and I’m late few minutes, my order will be fulfilled after all the millions of orders unless I submit a less favorable price for myself. Some may say that it’s karma. I was late, so I’m paying for it. True, maybe that’s right. If that price I must pay for being late is reasonable, I can accept it. But again, there are MILLIONS of orders in the market, and if you look into the order book, this means that there are still thousands of orders placed in every penny difference price. Unless placing an order that beats all of the others in price (this will cause a huge fortune by the way), my order will take place after all other orders are matched. Additionally, if the users decide to place multiple orders at different price levels, that could cause a burden on the system since the system needs to keep track of who came first while looking at the order too.
The other way of matching orders is pro-rata. This means that if the orders are placed in the same price, they both get fulfilled in the same time, as pro-rata. So, let’s say I placed an order to buy 100 of stock A at $100. You placed an order to buy 300 of stock A at $100. When there is a sell order of 200 stock A at $100, I would get 100 / (100 + 300) of the 200 sell order, which is 50. You will get 150. As more sell order come in at this price, both you and I will eventually be done buying. The pros of this algorithm is that it allows all traders coming in at different time to still trade relatively faster than they would have in the FIFO algorithm. If the price is good, I need not worry about how late I am. This method poses less burden to the system, as the time order or the orders are no longer needed to be considered. If the price match, the system just needs to distribute the matching orders according to the size of each order. But as a consequence, this algorithm theoretically does not help narrow the bid-ask spread, and leaves a risk of less-knowledgable users to place orders at a less favorable price. If the time of when I placed the order doesn’t matter, why would I give up my money to place a less favorable order as I would have done under the FIFO method? I’ll just submit the order as others did, and wait for it to be fulfilled.
It is hard yet to tell which algorithm is the absolute better for order matching. Both have pros and cons. I’m still on my own journey to figure out a better way too.