How are the actual prices for stocks determined? A trivial question at first glance, 95% would blurt out «Eeeeasy: demand and supply!». Well, not entirely false. But what exactly is the mechanism behind that? How does this exchange machine work under the hood? This is not only great knowledge for bragging at dinner parties, but an essential foundation for becoming a better trader. Knowing how stock prices are determined and what happens to orders after submission to your broker is important for your ability to pick the right tools from your toolchest. Read more to learn why (and incidentally learn why you want liquid markets).

tl;dr

You should know the benefits and pitfalls of using limit orders. You should know what happens behind the scenes when (and why) your orders do not get executed. You want to look for liquid markets, even if this means to undertake some research with the different exchanges your broker might offer (we will touch this topic again in another blog post and have a deeper look at exchanges, traded volumes, trading times and spreads).

This article covers:

The key takeaways:

  • Exchanges are not pool-like mechanisms but enable direct transactions between market participants: each time you buy or sell a stock, you buy/sell it from/to someone else
  • You want liquid markets for your transactions: check the Times&Sales for the stock of your interest, check the exchange options your broker offers
  • a market (unlimited) order will be filled faster, but you have less control over the transaction price
  • a limit order gives you control over the transaction price, but may take a while to be filled (if at all)

Imagine a fictional stock exchange, opening 09:00 a.m. The first transactions of the stock FooBar Corp. already took place and the last traded price was $100. The next orders come in:

  • (1) at 09:05 a buy order: the buyer is willing to buy 100 shares for a price of not more than $100 (a so called limit order)
  • (2) Two minutes later at 09:07, a potential seller is transmitting her sell order: she wants to sell 200 units, for a minimum price of $105 (again, a limit order)
  • (3) One minute later another buyer (3) is interested in 150 units, for no more than $100
  • (4) 09:09 a second potential seller will sell 150 units, for a minimum price of $103
  • (5) 09:10 another seller offers 100 units for a minimum of $103
  • (6) 09:10 a third buyer would buy 200 shares for a price no more than $102

The orderbook for this five minute timeframe would look like this:

 

Orderbook for FooBar Corp. stocks
Order Time Side Qty Price
(1) 09:05  Buy 100 Limit $100
(2)  09:07  Sell  200  Limit $105
(3)  09:08  Buy  150 Limit $100
(4)  09:09  Sell 150  Limit $103
(5)  09:10  Sell  100  Limit $104
(6)  09:10  Buy  200  Limit $102

 

Due to non-matching prices for supply and demand, during those 5 minutes there wouldn’t have been a single transaction. If we compare the demand and supply of this market, you can see why: 

 

Demand and Supply for FooBar Corp
    Demand (Buy)   Suppy (Sell)
 Order  Time Qty Price Time Qty
(2)     $105 09:07 200
(4)     $103 09.09 150
(5)     $103 09:10 100
(1) 09:05 100 $100    
(3) 09:06 150 $100    
 (6) 09:10 200 $102    

 

Above table reordered the rows to have the supply and demand side both in blocks. The last official stock price is highlighted in bold at $100. As all participants submitted limit orders, and none of those limits fit to each other, no order can be filled. So here is the first key takeaway from this article: exchanges enable transactions between participants. An exchange is not a pool-like mechanism, where participants drop their stocks into or pull them out. Every trade is a direct transaction between two participants. Take a minute to let that thought sink in: every time you buy a stock, you purchase it directly from somebody that is selling it. And while you have good reasons to buy this particular stock (at least you should), at the same time somebody else should have good reasons to sell that very same stock. We will come back to that later on!

This example market is very illiquid. For a market considered as liquid, every minute there would be dozens, hundreds or even thousands of orders, including a lot of orders without any limit- so called market orders. So here is another takeaway of this article: In an illiquid market your limit order might take a long time to be filled (or even never get executed). What happens if a matching order arrives and how is this order mathing performed?


Order Matching Algorithms

So back to the initial question: how is the actual stock price determined? In above´s example, the demand side equals the supply side: 450 stocks in total. But due to different price limits, no transaction is taking place. Just by increasing demand, the stock price will not move (think about an addional buyer who would buy 1000 stocks for $99- still no transaction).

If you imagine a stock exchange, you might picture yourself a buzzing trading floor, with hundreds of traders shouting at each other in a codified language, mysteriously waving their hands all the time, completely uncomprehensible to outsiders . This method of determining prices was called open outcry auction and can be seen today in movies and historic documentations only. Every market participant had a chance to hear every bid and (at least in theory) compete with the offered or demanded prices.

Those trading pits are gone, now that computers and algorithms took over the world. The requirements for an order matching algorithm are pretty tough, as this task touches the inner sanctum of an exchange: the implementation must be very fast, it must not favor supply or demand side, and it should be fair to all market participants.

There are a couple of algorithms to match supply and demand side, they are mostly based on two principles:

  • First In/ First out- a price/time prioritization (FIFO) and
  • Pro Rata- proportionally considering quantities for a price level

There are variations and combinations for both algorithms, for the sake of clarity I will only show both basic concepts. If you are not interested in all the trading technical mumbo-jumbo but the consequences, you can skip the next to headings and proceed to Limit Orders vs. Market Orders.

FIFO order matching

First in- First out is a very straightforward algorithm: orders are sorted first by price. Then for each price level, the earlier orders get priority over newer ones. To demonstrate this algorithm at the example for FooBar Corp. stocks, I reordered the orderbook to reflect the FIFO priorities. The Buy order with the highest priority is at the top, going down in the orderbook the priority decreases. On the Sell side, the highest priority order is at the bottom, going up the priorities decrease. Using this way of ordering the buy and sell orders with the highest priority meet in the center.

 

 Demand and Supply ordered by FIFO
    Demand (Buy)   Suppy (Sell)
 Order  Time Qty Price Time Qty
(2)     $10 09:07 200
(5)     $103 09.10 100
(4)     $103 09:09 150
(6)  09:10  200 $102    
(1) 09:05 100 $100    
(3) 09:06 150 $100    

 

Now imagine at 09:12 a new Buy order coming in:

  • (7) Buy 200 units market (unlimited).

This buyer is willing to buy at any price. Sell order (4) has priority as it has the lowest price and was first in it´s price level. This person will sell all 150 units to the buyer. Next in line is Sell order (5): this order will be executed partially, because only 50 units are remaining for buy order (7). The following table shows how the matching leads to Buy order (7) and Sell order (4) filled and Sell order (5) partially executed:

 

 Fill quantities for FIFO order matching
    Demand (Buy)   Suppy (Sell)
 Order  Time Qty Price Time Qty
(5)     $103 09.10 50+50
(4)     $103 09:09 150
(7)  09:12  200 any    

 

After that transactions are handled, the orderbook is in the following state: 

 Orderbook after FIFO order matching
    Demand (Buy)   Suppy (Sell)
 Order  Time Qty Price Time Qty
(2)     $105 09:07 200
(5)     $103 09.10 50
(6)  09:10  200 $102    
(1) 09:05 100 $100    
(3) 09:06 150 $100    

 

Orders (4) and (7) have been filled, Order (5) partially filled. Also, a new stock price was determined: as the last transaction happend for a price of $103, this is what runs now over the screen in your CNBC ticker (or whatever live-ticker you chose to stare at the whole day :)) (I really hope you don´t)

 

Pro Rata order matching

In contrast to FIFO the Pro Rata algorithm does not consider the times of orders- only price levels are relevant. The matching of orders is done via the relative quantities of each Sell order at the given price level. To stay in above example, when Buy order (7) comes in, the lowest possible price level (for any transaction to happen) is $103. At this price level, there is a total of 250 stocks supply: 150 from sell order (4) and 100 from sell order (5). So (4) has a relative quantity of (150:250 = 0.6) and thus get a partial execution of (0.6 * 200 = 120) units. Accordingly, (5) with a relative quantity of (100:250=0.4) will be filled with (0.4 * 200 = 120) units. To illustrate that as a table:

 Fill quantities for Pro Rata order matching
    Demand (Buy)   Suppy (Sell)
 Order  Time Qty Price Time Qty
(5)     $103 09.10 80+20
(4)     $103 09:09 120 + 30
(7)  09:12  200 any    

 

This leads to a slightly different orderbook as shown for the FIFO algorithm: 

 

 Orderbook after Pro Rata order matching
    Demand (Buy)   Suppy (Sell)
 Order  Time Qty Price Time Qty
(2)     $105 09:07 200
(5)     $103 09.10 20
(4)     $103 09:09 30
(6)  09:10  200 $102    
(1) 09:05 100 $100    
(3) 09:06 150 $100    

 

As you see, order (7) was filled completely, as orders (4) and (5) were only partially filled. Also, the new stock price is determined at $103.

 

Limit Orders vs. Market Orders

As you´ve seen, different order types have different characteristics and resulting behaviour. The limited Buy Orders (1), (3) and (6) for example, were not filled yet- and will not be until a fitting Sell order arrives. The stock price in our example moved from $100 (after the opening of the market) to $103. If the market continues to go up (if you read that far you know how the engine works) that might take a very long time (and after a certain time orders do get canceled automatically).

On the other hand, the buyer of order (7) might be surprised that he payed $103 for the stocks- he saw the last price in his system was $100. By submitting a market order he made sure that the order gets filled- but market also means «by any price».

 

Look for liquid markets!

Now it´s time to introduce a new concept: Liquidity! The artificial market in our artificial example is not very liquid: there was only a single transaction in 12 minutes! Another downside of this illiquid market are the possible price jumps from one order matching to the next (again, 3% in our example). This is due to a lack of market participants and therefore a lack of orders. Keep in mind that those jumps can occur in both directions! And consider the following fun fact: a Stop Loss order, placed usually as safety net to prevent losses when a price crosses a certain price become Market Orders, once the price trigger is reached. Imagine the investor whose Stop Loss order gets executed at a price level down another 10%… Not every trader is aware of this (mental note to myself: maybe Stop Losses and their characteristics are worth an article for their own). Do you remember the point I made above, about the direct transaction between market participants and their individual reasons for buying and selling? It is not hard to imagine why a market with more participants is better for stop loss orders: during a sharp correction each seller needs a buyer, too. In an illiquid market it is simply less likely, that a buyer is present who will buy your shares.

In a liquid market, on the other hand, there are dozens, hundreds and even thousands transactions each minute. Each transaction potentially resulting in a new price, creating an endless stream of price ticks. This also reduces the likelyhood of partial executions, as in our example. Plus, market orders (and hence triggered Stop Loss orders) are less likely to lead to rude awakenings.

So what can you do to ensure liquidity? Basically you have have influence on two variables: First and most intuitively, on the stock you intend to buy. Second: the exchange you intend to buy that stock. Both options should be seen in combination. Usually, your broker allows you to select different exchanges before submitting an order. And if not, chances are that your trading fees are very low but your broker makes money by bringing unaware customers (you!) to some obscure low liquity exchange (but again, this should be the topic of another blog post).

 

Times and Sales

Most brokers I am aware of offer so called Times and Sales (T&S) for your combination of stock and exchange. Think of T&S as a real time ticker of all transactions currently going on at the moment (with the focus on your stock). T&S include a timestamp, price, direction and volume. Every transaction like the two examples above would result in a line of that list. You can access that lists either through your brokers webpage, or via the broker´s trading software. If you see a T&S like the following, you should stay away if you expect your orders to be executed in a timely manner (and at least in the range of the current price):

Time Price Qty cum. Qty.
09:00:21 28.18 50 90
09:04:15 27.94 250 340
09:04:53 27.92 200 540
09:17:58 28.82 173 713
09:21:06 27.92 50 763
09:29:54 27.96 150 913
09:38:03 27.88 25 938
09:40:31 27.96 5 943
09:42:08 27.96 40 983
10:01:12 27.98 50 1033

 

That´s a real world example of a german small-cap stock, traded at a exchange aiming for retail traders. Have a look at the large intervals between each trade, and the overall pretty small volumes that are going over the counter. This is an indication, that for this stock at that specific exchange mostly retail traders are interacting with each other. While the quantity of the each trade might fit your usual position sizes pretty well, this is what I would call an illiquid market. If markets have a violent downmove, it will be very difficult to get out of a position for a reasonable price. Remember: for every seller there has to be a buyer. This is also true for positions that are sold because of a triggered stop loss.A liquid market, by contrast, looks more like that:
Time Price Qty cum. Qty
17:39:59 381.93 100 7249612
17:39:59 381.94 100 7249712
17:39:59 381.95 100 7249812
17:39:59 381.95 100 7249912
17:39:59 381.93 100 7250012
17:39:59 381.96 200 7250212
17:39:59 381.96 200 7250412
17:39:59 381.92 100 7250512
17:39:59 381.92 100 7250612
17:39:59 381.95 100 7250712

 

This is another real-world example, this time a well-known blue chip, traded at the NASDAQ. The same amount of trades as in above example, but this time executed within the very same second. Also note that the amount of money that is moved for each transaction, is way higher. More trades mean more orders which results also in a smoother price curve.

Summary

What is important for you as a trader? First, to look for liquid markets. As you learned, exchanges are not pool-like mechanisms, but enable transactions between market participants. The more participants within a market, the better. Liquidity is not only about the volume of single trades, it is about a constant flow of volume through time. You can use that information in two ways: first, the exchange of your choice should provide enough volume- even if that means you pay more fees. Exchanges constantly try to fit supply and demand with each other, their «job description» is to find the prices where demand and supply find their maximum. That way liquidity of this market is maximized.
Another takeaway from this article is how orders work, especially the difference between market (unlimited) orders and limit orders. And that a stop loss order usually becomes a market order if the price threshhold is reached.
If you have additional questions or feedback, please leave a comment!


Enjoy life and happy trading!

Comments powered by CComment