This post is based on Chapter 4 of the book “Algorithmic Trading and DMA: An Introduction to High-Frequency Trading” by Barry Johnson.

Introduction

An order holds the instructions for the execution of a trade, allowing investors and traders to communicate their requirements, both from the type of order used, as well as with additional conditions and instructions that can be added to the order.

The two main types of orders are market orders and limit orders. Market orders are executed at the best available price in the market, while limit orders are executed at a specified price or better. Therefore, MOs demand liquidity, while LOs provide liquidity.

Market Orders

A market order (MO) is an order to buy or sell a security immediately at the best available price in the market. The main risk associated with MOs is the uncertainty of the execution price, which can vary from when the decision to trade is made to when the order is executed.

MOs demand liquidity:

  • Buy Market Order: The order is executed at the lowest available ask price.
  • Sell Market Order: The order is executed at the highest available bid price.

For example, look at the following order book:

Bid Price Bid Size Ask Price Ask Size
100 10 101 5
99 15 102 10
98 20 103 8

If a buy market order is placed to purchase 12 shares, it will be executed at the best available ask price of 101, consuming the first ask of 5 shares and then partially consuming the second ask of 10 shares, resulting in a total of 12 shares purchased at an average price of approximately 101.58.

If a sell market order is placed to sell 12 shares, it will be executed at the best available bid price of 100, consuming the first bid of 10 shares and then partially consuming the second bid of 15 shares, resulting in a total of 12 shares sold at an average price of approximately 99.83.

When the order is partially filled with the best available price, then it walks the book, using the following limit orders until the order is completed. Therefore, the execution price price depends on both the market liquidity and the size of the order.

Limit Orders

A limit order (LO) is an instruction to buy or sell a given quantity of a security at a specified price or better. LOs will try to fill as much of the order as possible at the specified price, and any remaining quantity will remain in the order book until it is either filled or canceled. This way, LOs provide liquidity to the market, since other traders will see that we are willing to buy or sell at a specific price, and they can trade with us if they agree with our price.

The main risk of LOs is the execution risk, as the order may not be filled if the market does not reach the specified price.

At the market: LOs submitted at the best available price. A buy LO at the best bid price or a sell LO at the best ask price. The traders who submit at the market are said to be making the market, as they are providing liquidity to the market.
Behind the market: More passive LOs, submitted at lower bid prices or higher ask prices than the best available price. These orders are not immediately executable and will wait until the market reaches their specified price.

Optional Instructions

Orders can include additional instructions to specify how they should be executed. Some common optional instructions include:

  • Duration: Specifies how long the order remains active. Common durations include:
    • Day Order: Valid only for the trading day it is placed.
    • Good-Til-Canceled: Remains active until filled or canceled by the trader.
    • Good-Til-Date: Remains active until a specified date.
    • Good-After-Time: Becomes active only after a specified time.
  • Auction session: Some markets have specific auction sessions (e.g., opening or closing auctions) where orders can be placed to be executed at the auction price.
  • Fill: Specifies how the order should be filled. Common fill instructions include:
    • All-or-None: The order must be filled in its entirety or not at all.
    • Immediate-or-Cancel: Any portion of the order that cannot be filled immediately is canceled.
    • Fill-or-Kill: The order must be filled immediately in its entirety or canceled.
    • Minimum Volume: The order will only be executed if a minimum volume can be filled.
    • Must-be-Filled: The order must be filled completely, but it can wait in the order book until it is filled.
  • Preferencing: permits bilateral trading by directing orders to a specific broker or dealer
  • Routing: Specifies how the order should be routed to different exchanges or trading venues:
    • Do-not-route: The order should not be routed to other venues.
    • Directed-routing: The order should be routed to a specific venue.
    • Inter-market sweep: The order should not be routed to multiple venues to find the best price. Instead, it walks the book at the venue where it is placed.
    • Flashing: The order is shown to subscribers of the venue before being routed to other venues.
  • Linking: Allows traders to link multiple orders together, so that they are executed as a single unit. This can be useful for complex trading strategies that involve multiple securities or multiple legs:
    • One-cancels-other: If one order is executed, the other order is automatically canceled.
    • One-triggers-other: If one order is executed, the other order is automatically placed.
  • Miscellaneous: Other optional instructions that can be included in an order, such as:
    • Identity: Specifies whether the order is anonymous or not.
    • Short sales: A flag that must be set for markets that enforce short sales regulations.
    • Odd lots: Specifies whether the order is for an odd lot (less than the standard trading unit) or not.
    • Settlement: Specifies the settlement some reasonably common non-standard settlement instructions, such as foreign currency settlement or cash settlement