Invest: Stock trade execution explained

Posted by

This post is a summary of my study of trading system, to be specific, how a trade is executed.

Trade Execution - Overview, Methods, Restrictions


InstrumentAny tradable thing, generally interchangeable with “security”.
LotUsually means 100 shares of a particular stock.
Some stocks, like BRK-A are so expensive that a “lot” of that stock is just 1.
Odd lotAny number of shares of a stock less than a lot.

For example, 50 shares of AAPL is an odd lot.
OrderA firm commitment to trade an instrument at a certain price, either buying or selling.
An order can be cancelled, but until it is, the issuer of the order must stand ready to fulfill their promise to buy or sell.
FlowA stream of orders, sometimes also used for a stream of IoIs.
BookThe totality of all orders that an entity knows about, for a particular instrument.

For example, NASDAQ may have a book for GOOG that looks like:
Bids: 100shares@$100, 200shares@$90
Asks: 100shares@$101, 300shares@$110
Top of Book (ToB)The best bid and ask of a book.

In the example above, the ToB would be:
Best bid: 100shares@$100
Best ask: 100shares@$101
TradeAlso called an “execution”. A trade happens when 2 orders, one buying and one selling, agree upon a price and quantity for an instrument. This results in money going from the buyer to the seller, and the instrument going from the seller to the buyer.
Order matchingThe act of finding 2 orders to produce a trade.

In our example above, no 2 orders can match, because the best bid is below the best asking price.
However, if a new order comes in to buy 50shares@101, then this order can be matched with our best ask, to produce a trade

After this trade, our ToB would be:
Best bid: 100shares@$100
Best ask: 50shares@$101
Market dataA (maybe real time, maybe delayed) stream of information about the trades and the state of the books of an exchange.

AKA trading venue
A venue refers to either an exchange or alternative trading system, where traders can send their orders to get routed to another venue, or to be executed.

AKA lit exchange

AKA lit venue
A trading venue that publishes market data publicly, e.g: NASDAQ, NYSE, Amex, etc.
Dark pool

AKA Alternative Trading System (ATS)
A trading venue that does not publish market data publicly, e.g: Sigma X, CrossFinder, MS SORT, etc.

They are not always an “exchange” — an “exchange” implies a book and order matching — dark pools may not have a book and may not match orders, they may trade against incoming orders using their own portfolio.
Protected quotes

AKA National Best Bid and Offer (NBBO)
This is the ToB of all lit exchanges put together.

For example, if NASDAQ has these quotes for MSFT:
Bids: 100@$50, 200@$49
Asks: 300@$52, 400@$53

and NYSE has these quotes for MSFT:
Bids: 500@$49, 600@$48
Asks: 700@$51, 800@$52

Then the NBBO is:
Best bid: 100@$50
Best ask: 700@$51

Note that odd lots are generally ignored for the purpose of computing the NBBO. i.e: Odd lots are generally not protected, even if they are the best bid or ask.
NMSNational Market System, created by Investment Act of 1933. NMS is a rule which says that any order that is executed, must execute at a price within NBBO (inclusive).  There are some exceptions, but these typically don’t apply to retail orders.
Regular trading hours (RTH)Between 9.30am and 4pm Eastern time on a trading day. This is the period of time when the market is said to be “open”, and starts with the opening auction at 9.30am, and ends shortly after the closing auction around 4pm.
After hoursAny time other than RTH.
BrokerAn entity that takes an order and figures out where to send it so that it can get matched and executed.
DealerAn entity that takes an order, and trades against it (i.e: the dealer is the counterparty of the order creator).
Broker/Dealer (BD)Most brokers are also dealers, and vice versa. Because of this, brokers and dealers are collectively known as brokers/dealers or BDs for short.
Market maker (MM)An entity that is mandated by SEC/FINRA rules to always keep a bid and ask up for the instrument that it is market making for, on a particular exchange.

Note that a market maker for FB on NASDAQ may not be a market maker for FB on NYSE, etc.
Wholesale market maker (WMM)Really a BD, a WMM is an entity that accepts orders from retail brokers, and either
a) Figures out where to route that order so that it can be matched and executed, OR
b) Trades against the order using their own portfolio, OR
c) Holds the order in their own book for matching against future orders.
InformedAn adjective to describe either an entity, order or flow.

An informed entity, order or flow is someone or something that has an edge. In general, this edge involves some non-trivial understanding of the system and/or the macro and/or micro environment(s).

Usually, “informed” is applied with a very short time horizon. For example, an order is informed if within a few milliseconds to seconds of the order being sent, the price of the instrument moves upwards.

Also called “toxic”.
UninformedAn adjective to describe either an entity, order or flow.

An entity, order or flow that is uninformed is, well, not informed.

Typically synonymous to “retail orders/traders”, it is also generally applicable to more sophisticated entities, such as hedge funds, if they are not trying to optimize for very short term (milliseconds to seconds) time horizons.


There are 10+ lit exchanges in the US for equities, several more for options, futures, etc. In general, to be called an “exchange” requires being subject to stringent regulatory rules set by the SEC, a Federal government agency. Exchanges, in turn, are part of FINRA, which is a self-regulatory body consisting of exchanges and large brokerages. Together, SEC and FINRA set the rules that govern all equities trading in the USA.

A trade can happen as long as all the rules that SEC/FINRA impose are met. The rules which generally apply are:

  • NMS is enforced during RTH and so all trades must occur within NBBO (inclusive).
    • There are exceptions to this rule, such as for large orders (block trades), corrective trades (busts, corrects), etc.
  • During RTH, prices cannot move by too much within a 5-minute period. The bands are defined using an algorithm the SEC dictated.
    • Orders which are outside the band must be modified to comply or rejected by the broker.
    • Even if trades are within the bands, if volatility is too high as judged by various parties (SEC, FINRA, exchanges, etc.), trading in a particular stock can be halted.
  • During RTH, circuit breakers are in effect — if the price of S&P500 declines by too much, the entire market is halted for defined periods of time, up to an including an early end of the trading day.

Order handling

Only licensed BDs are allowed to connect directly to exchanges. As part of maintaining that license, BDs agree to a shared responsibility to “maintain orderly markets”. What this means, is that all rules that the SEC/FINRA impose, must be adhered to by all BDs. If an order which is in breach of the rules is received by a BD, they are responsible for either modifying the order so that it is compliant, or rejecting the order. Any BD who forwards (routes) a non-compliant order to another BD or exchange, may find themselves being disciplined by the SEC/FINRA.

Because there are so many rules to pay attention to just to validate an order, most BDs don’t actually connect to the exchanges directly. Instead, they have contracts with other BDs, such that the original BD is allowed to send some types of non-compliant orders to the second BD, and the second BD assumes the responsibility of validating and possibly rejecting those orders. In effect, our original BD has its own BD. The original BD, the introducing BD, will forward any orders they receive to the second BD, the executing BD. The executing BD will then figure out what to do with the order, also known as “working the order”.

Retail orders

In general, retail BDs, such as Robinhood, E-Trade, Charles Schwab, etc., typically do not know how to work an order. They are, for the most part, glorified UI+app+accounting.  When you send in an order to a retail BD, they will route the order to a specialized BD, also called a WMM, not to be confused with a regular MM — though most WMM’s are also regular MMs, in some capacity (i.e: some instrument+exchange pairs). There are 3 major WMMs in the US – Citadel Securities, Two Sigma Securities and Virtu Financial. There are also a bunch of minor WMMs in the US, but they have very little flow compared to the big 3.

So, when JoeRetail sends an order to RetailBroker, RetailBroker will send the order to WholesaleMarketMaker, who then has 4 choices:

  1. Trade against the order, using their own portfolio.
    • There are a bunch of rules they have to comply with, enforced by the SEC/FINRA, to ensure that the WMM gives JoeRetail a reasonable deal.
  2. Forward the order to a dark pool or lit exchange or another BD.
  3. Hold the order on its books.
  4. Cross the order against another order already on its books.
    • Must comply with all the rules mentioned above relating to order execution.

From worst to best for JoeRetail:

  • In general, the first option is usually a bad deal for JoeRetail — because the WMM is informed, while JoeRetail is almost definitely uninformed — there is an information asymmetry and generally speaking, the WMM will come out of the deal better off.
  • Routing to a dark pool is generally bad for the order as well, for similar reasons.
  • Being held on the WMM’s books is sort of bad — it implies the order is not immediately executable (it does not cross the far price, which is the best bid for a sell order, or the best ask for a buy order), so the WMM is putting it on ice until something changes and the WMM can decide again later.
  • Routing to another BD just repeats the process.
  • Immediately crossing against an order already on the WMM books is OK, but not the best thing.
  • Routing to an exchange is probably the best thing that can happen to the order.

National best guess for bid and offer

Why is it not the best thing for the order to trade against other client orders on the WMM’s books?  Surely those orders must also be uninformed?
Yes, those orders are uninformed, but the problem is that NBBO is weird.

Remember that WMM has to execute within NBBO.  But NBBO is not the best bid/offer of all exchanges (it’s just called that).  It is just the best protected and lit bid/offer.

For example, if the absolute 2 best offers on all lit exchanges are:
Sell 99 GOOG @ $100
Sell 100 GOOG @ $101

The first order (@ $100) is not the NBBO — because it is an odd lot. So, even though the WMM knows about that order (lit exchange books are public), and you only want to buy 99 GOOG, the WMM does not have to execute your trade at $100, it can execute your buy order at $101. However, if your order to buy 99 GOOG was routed to the exchange, it’ll definitely be executed at $100.

More interestingly, and this is something that most people don’t appreciate — the WMM may not be allowed to fill your buy order @ $100, even if it wants to.  For example, if NASDAQ has both those sell orders, and NYSE has this buy order:
Buy 100 GOOG @ $100.10

Then the NBBO is $100.10 to $101.  Which means filling your order at $100 will be below the $100.10 best bid, which is against the NMS rule.  This situation is known as a crossed market.  It happens, but rarely and usually not for very long.

Another problem with NBBO is that it is not well defined.  Remember that all the exchanges are located at different geographic locations.  So, depending on where you are, market data (i.e: the book) of different exchanges will reach you at different times.

So even if you use the exact same algorithm to build the NBBO, someone in Kentucky and someone in Connecticut can genuinely see different NBBOs, simply because the exchanges’ market data reach them at different times.

Because of all these issues, BDs cannot just use any NBBO algorithm. The algorithm they use must be blessed by the SEC/FINRA.  OR, they can just use the SIP. The SIP is a company that publishes various market data for all participants.  Because it is sanctioned by the SEC/FINRA, if you use the NBBO published by the SIP, you’ll generally be fine — SEC/FINRA generally won’t give you grief about that.

But that introduces 3 other problems:

  1. The SIP itself is located at some location, which means it’s seeing market data of a certain latency.
  2. The SIP itself has very little incentives to get better (since it’s effectively a mandated monopoly), so it’s software is very slow compared to the rest of the market.  It’s common for the SIP to send out data that’s 1-100ms behind what the rest of the market actually see.
  3. Depending on where you are in relation to the SIP source, you may get data that’s even slower because now the data source is 2 hops away.

Finally, the last bad thing about NBBO is that it doesn’t account for hidden orders.  We already know the NBBO ignores odd lots.  But it also is ignorant of hidden orders.  Venues (lit or otherwise) typically allow orders to be hidden from the public and not published in market data.  These are typically orders that are big, because if someone wants to sell 1,000,000 shares of GOOG in a single order, anyone seeing that order will freak out and dump GOOG (OMG! They know something we don’t!). To avoid market panic, these large orders are typically hidden — sometimes totally hidden, sometimes they may show up as only 100 shares on the books of the exchanges. That’s why even if you see NBBO as $100 – $101, and you send an order to an exchange to buy at $100.50, you may actually hit a hidden order, and get executed.

Of course, because these orders are hidden, they don’t show up in NBBO, which means WMMs don’t have to honor that $100.50, even if they can reasonably guess that the order is there (there are ways to forecast/predict this, I won’t go into that).

To conclude, by not going to an exchange, you potentially lose out on potential liquidity that can fill your order at a better price.  WMMs can, perfectly legally (and sometimes forced to by SEC rules), fill your order against their own portfolio, then go out and buy/sell at a better price on the lit exchange to make an instant profit.


Comments are closed.