1"use strict";(self.webpackChunkwonderland_handbook=self.webpackChunkwonderland_handbook||[]).push([[8294],{13591:(e,i,r)=>{r.r(i),r.d(i,{assets:()=>a,contentTitle:()=>l,default:()=>h,frontMatter:()=>d,metadata:()=>n,toc:()=>o});const n=JSON.parse('{"id":"development/research/onboarding/knowledge-base/defi/limit-order","title":"Limit Order Books","description":"Understanding the mechanics and importance of limit order books in financial markets","source":"@site/docs/development/research/onboarding/knowledge-base/defi/limit-order.md","sourceDirName":"development/research/onboarding/knowledge-base/defi","slug":"/development/research/onboarding/knowledge-base/defi/limit-order","permalink":"/docs/development/research/onboarding/knowledge-base/defi/limit-order","draft":false,"unlisted":false,"editUrl":"https://github.com/defi-wonderland/handbook/tree/main/sites/wonderland/docs/development/research/onboarding/knowledge-base/defi/limit-order.md","tags":[],"version":"current","frontMatter":{"id":"limit-order","title":"Limit Order Books","description":"Understanding the mechanics and importance of limit order books in financial markets","sidebar_label":"Limit Order Books"},"sidebar":"tutorialSidebar","previous":{"title":"Cryptography","permalink":"/docs/development/research/onboarding/knowledge-base/intermediate/cryptography"},"next":{"title":"Automated Market Makers","permalink":"/docs/development/research/onboarding/knowledge-base/defi/amm"}}');var s=r(50612),t=r(50831);const d={id:"limit-order",title:"Limit Order Books",description:"Understanding the mechanics and importance of limit order books in financial markets",sidebar_label:"Limit Order Books"},l="Limit Order Books",a={},o=[{value:"The Role of Markets",id:"the-role-of-markets",level:2},{value:"Liquidity",id:"liquidity",level:3},{value:"Price Discovery",id:"price-discovery",level:3},{value:"Structure of a Limit Order Book",id:"structure-of-a-limit-order-book",level:2},{value:"<strong>Bid and Ask Orders</strong>",id:"bid-and-ask-orders",level:3},{value:"<strong>Tick Size and Lot Size</strong>",id:"tick-size-and-lot-size",level:3},{value:"<strong>Order Book Visualization</strong>",id:"order-book-visualization",level:3},{value:"<strong>Order Matching and Execution</strong>",id:"order-matching-and-execution",level:2},{value:"<strong>Price/Time Priority</strong>",id:"pricetime-priority",level:3},{value:"<strong>Types of Orders</strong>",id:"types-of-orders",level:3},{value:"<strong>Trade Execution Example</strong>",id:"trade-execution-example",level:3},{value:"<strong>Market Participants and Trading Strategies</strong>",id:"market-participants-and-trading-strategies",level:2},{value:"<strong>Liquidity Providers and Market Makers</strong>",id:"liquidity-providers-and-market-makers",level:3},{value:"<strong>Order Visibility</strong>",id:"order-visibility",level:3},{value:"<strong>Auctions in Traditional Markets</strong>",id:"auctions-in-traditional-markets",level:3},{value:"<strong>Market Data and Depth Analysis</strong>",id:"market-data-and-depth-analysis",level:2},{value:"<strong>Levels of Market Data</strong>",id:"levels-of-market-data",level:3},{value:"<strong>Market Impact and Depth Charts</strong>",id:"market-impact-and-depth-charts",level:3}];function c(e){const i={a:"a",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",ol:"ol",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,t.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.header,{children:(0,s.jsx)(i.h1,{id:"limit-order-books",children:"Limit Order Books"})}),"\n",(0,s.jsx)(i.p,{children:"Limit order books serve as the foundation of modern financial markets, enabling buyers and sellers to interact in a structured manner. While financial professionals may find the concept intuitive, many people, including retail investors, lack a clear understanding of how order books facilitate trading."}),"\n",(0,s.jsx)(i.p,{children:"This article aims to provide an overview of limit order books, from basic concepts to advanced mechanics. It also introduces some key terminology and market behaviours. Apart from that, we encourage you to read the resources at the end of the article."}),"\n",(0,s.jsx)(i.h2,{id:"the-role-of-markets",children:"The Role of Markets"}),"\n",(0,s.jsx)(i.p,{children:"A functional market requires both buyers and sellers. Whether at a farmers' market or a stock exchange, transactions occur when both parties agree on a price. Financial exchanges consolidate all trading activity in a centralized location, enabling two fundamental processes:"}),"\n",(0,s.jsxs)(i.ol,{children:["\n",(0,s.jsx)(i.li,{children:(0,s.jsx)(i.strong,{children:"Liquidity Provision"})}),"\n",(0,s.jsx)(i.li,{children:(0,s.jsx)(i.strong,{children:"Price Discovery"})}),"\n"]}),"\n",(0,s.jsx)(i.h3,{id:"liquidity",children:"Liquidity"}),"\n",(0,s.jsx)(i.p,{children:"Liquidity refers to how easily an asset can be bought or sold without significantly affecting its price."}),"\n",(0,s.jsx)(i.p,{children:"For example, during the PlayStation 5 shortage, the limited supply (low liquidity) caused prices to rise as demand exceeded availability. Similarly, in financial markets, a stock with low liquidity can experience drastic price fluctuations when traders buy or sell in large quantities."}),"\n",(0,s.jsx)(i.p,{children:"From a seller's perspective, liquidity is crucial as well. If there are too few buyers, the seller may need to reduce prices to attract demand. Highly liquid markets ensure price stability and efficie
1nt trading."}),"\n",(0,s.jsx)(i.h3,{id:"price-discovery",children:"Price Discovery"}),"\n",(0,s.jsx)(i.p,{children:"Price discovery is the process by which an asset's market price is determined."}),"\n",(0,s.jsx)(i.p,{children:"Consider a customer at a market looking to buy tomatoes. To find the best deal, they compare prices from different vendors. Similarly, in financial markets, price discovery occurs as buyers and sellers place orders at varying prices, leading to a consensus price."}),"\n",(0,s.jsxs)(i.p,{children:["An ideal market structure ensures that all participants have equal access to price information, reducing ",(0,s.jsx)(i.strong,{children:"information asymmetry"}),", where one side has an advantage over the other. Limit order books help achieve this transparency."]}),"\n",(0,s.jsx)(i.h2,{id:"structure-of-a-limit-order-book",children:"Structure of a Limit Order Book"}),"\n",(0,s.jsx)(i.p,{children:"A limit order book compiles all buy and sell orders for a given security. Each order typically consists of:"}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"Side:"})," Buy or Sell"]}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"Quantity:"})," Number of units to be traded"]}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"Limit Price:"})," Maximum price a buyer is willing to pay or minimum price a seller is willing to accept"]}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"Submission Time:"})," The time at which the order was placed"]}),"\n"]}),"\n",(0,s.jsx)(i.h3,{id:"bid-and-ask-orders",children:(0,s.jsx)(i.strong,{children:"Bid and Ask Orders"})}),"\n",(0,s.jsx)(i.p,{children:"Orders are categorized into two groups:"}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"Bid Orders (Buy Side):"})," Represent buyers and are sorted from the highest to the lowest price."]}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"Ask Orders (Sell Side):"})," Represent sellers and are sorted from the lowest to the highest price."]}),"\n"]}),"\n",(0,s.jsxs)(i.p,{children:["A market participant placing a ",(0,s.jsx)(i.strong,{children:"buy limit order at $150 for 1,000 shares"})," will wait until a seller is willing to trade at that price. Meanwhile, a seller placing a ",(0,s.jsx)(i.strong,{children:"sell limit order at $152 for 2,000 shares"})," will wait for a buyer at that price."]}),"\n",(0,s.jsx)(i.h3,{id:"tick-size-and-lot-size",children:(0,s.jsx)(i.strong,{children:"Tick Size and Lot Size"})}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"Tick Size:"})," The minimum price increment between order levels (e.g., $0.01 or $0.10)."]}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"Lot Size:"})," The minimum number of units required per order (e.g., 100 shares per lot)."]}),"\n"]}),"\n",(0,s.jsx)(i.p,{children:"These constraints ensure uniformity in order placement."}),"\n",(0,s.jsx)(i.h3,{id:"order-book-visualization",children:(0,s.jsx)(i.strong,{children:"Order Book Visualization"})}),"\n",(0,s.jsx)(i.p,{children:"Order books are displayed in different formats, such as:"}),"\n",(0,s.jsxs)(i.ol,{children:["\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"Vertical View (Ladder Format):"})," Orders are arranged from highest to lowest prices."]}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"Side-by-Side View:"})," Buy and sell orders are displayed separately, with the best prices at the top."]}),"\n"]}),"\n",(0,s.jsx)(i.p,{children:"A typical order book example can be:"}),"\n",(0,s.jsxs)(i.table,{children:[(0,s.jsx)(i.thead,{children:(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.th,{children:"Price Level"}),(0,s.jsx)(i.th,{children:"Bid Quantity"}),(0,s.jsx)(i.th,{children:"Ask Quantity"})]})}),(0,s.jsxs)(i.tbody,{children:[(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.td,{children:"152"}),(0,s.jsx)(i.td,{}),(0,s.jsx)(i.td,{children:"2000"})]}),(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.td,{children:"151"}),(0,s.jsx)(i.td,{}),(0,s.jsx)(i.td,{children:"1500"})]}),(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.td,{children:"150"}),(0,s.jsx)(i.td,{children:"1000"}),(0,s.jsx)(i.td,{})]}),(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.td,{children:"149"}),(0,s.jsx)(i.td,{children:"1800"}),(0,s.jsx)(i.td,{})]})]})]}),"\n",(0,s.jsxs)(i.p,{children:["In this case, the ",(0,s.jsx)(i.strong,{children:"best bid"})," (highest buy order) is 150, and the ",(0,s.jsx)(i.strong,{children:"best ask"}
1)," (lowest sell order) is 151. The difference between these two prices is called the ",(0,s.jsx)(i.strong,{children:"bid-ask spread"}),"."]}),"\n",(0,s.jsx)(i.h2,{id:"order-matching-and-execution",children:(0,s.jsx)(i.strong,{children:"Order Matching and Execution"})}),"\n",(0,s.jsx)(i.h3,{id:"pricetime-priority",children:(0,s.jsx)(i.strong,{children:"Price/Time Priority"})}),"\n",(0,s.jsxs)(i.p,{children:["Orders in the book are ranked using ",(0,s.jsx)(i.strong,{children:"price/time priority"}),":"]}),"\n",(0,s.jsxs)(i.ol,{children:["\n",(0,s.jsx)(i.li,{children:"Orders at better prices have higher priority."}),"\n",(0,s.jsx)(i.li,{children:"If multiple orders exist at the same price, the earliest one is prioritized."}),"\n"]}),"\n",(0,s.jsx)(i.p,{children:"For example:"}),"\n",(0,s.jsxs)(i.table,{children:[(0,s.jsx)(i.thead,{children:(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.th,{children:"Order ID"}),(0,s.jsx)(i.th,{children:"Side"}),(0,s.jsx)(i.th,{children:"Price Level"}),(0,s.jsx)(i.th,{children:"Quantity"}),(0,s.jsx)(i.th,{children:"Submission Time"})]})}),(0,s.jsxs)(i.tbody,{children:[(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.td,{children:"A"}),(0,s.jsx)(i.td,{children:"Buy"}),(0,s.jsx)(i.td,{children:"150"}),(0,s.jsx)(i.td,{children:"500"}),(0,s.jsx)(i.td,{children:"10:00:05"})]}),(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.td,{children:"B"}),(0,s.jsx)(i.td,{children:"Buy"}),(0,s.jsx)(i.td,{children:"150"}),(0,s.jsx)(i.td,{children:"1000"}),(0,s.jsx)(i.td,{children:"10:00:10"})]})]})]}),"\n",(0,s.jsx)(i.p,{children:"Order A has higher priority over Order B because it was placed earlier."}),"\n",(0,s.jsx)(i.h3,{id:"types-of-orders",children:(0,s.jsx)(i.strong,{children:"Types of Orders"})}),"\n",(0,s.jsx)(i.p,{children:"We will find different types of orders, such as:"}),"\n",(0,s.jsxs)(i.ol,{children:["\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"Limit Orders:"}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsx)(i.li,{children:"Define a maximum (buy) or minimum (sell) price."}),"\n",(0,s.jsxs)(i.li,{children:["Can be ",(0,s.jsx)(i.strong,{children:"passive"})," (resting in the book) or ",(0,s.jsx)(i.strong,{children:"aggressive"})," (executing immediately)."]}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"Market Orders:"}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsx)(i.li,{children:"Execute immediately at the best available price."}),"\n",(0,s.jsxs)(i.li,{children:["May experience ",(0,s.jsx)(i.strong,{children:"slippage"})," if liquidity is low."]}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"Stop Orders:"}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsx)(i.li,{children:"Become active once a trigger price is reached."}),"\n",(0,s.jsx)(i.li,{children:"Commonly used for risk management (e.g., stop-loss orders)."}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(i.h3,{id:"trade-execution-example",children:(0,s.jsx)(i.strong,{children:"Trade Execution Example"})}),"\n",(0,s.jsx)(i.p,{children:"Consider an order book with the following levels:"}),"\n",(0,s.jsxs)(i.table,{children:[(0,s.jsx)(i.thead,{children:(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.th,{children:"Price Level"}),(0,s.jsx)(i.th,{children:"Bid Quantity"}),(0,s.jsx)(i.th,{children:"Ask Quantity"})]})}),(0,s.jsxs)(i.tbody,{children:[(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.td,{children:"151"}),(0,s.jsx)(i.td,{}),(0,s.jsx)(i.td,{children:"1500"})]}),(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.td,{children:"150"}),(0,s.jsx)(i.td,{children:"1000"}),(0,s.jsx)(i.td,{})]})]})]}),"\n",(0,s.jsxs)(i.p,{children:["If a ",(0,s.jsx)(i.strong,{children:"market buy order"})," for 2000 shares is placed:"]}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsx)(i.li,{children:"1500 shares executed at 151 USD"}),"\n",(0,s.jsx)(i.li,{children:"500 shares execute at 152 USD, next available price"}),"\n",(0,s.jsx)(i.li,{children:"The average execution price (VWAP) is:"}),"\n"]}),"\n",(0,s.jsx)(i.p,{children:"[(1500 x 151) + (500 x 152)] / 2000"}),"\n",(0,s.jsx)(i.h2,{id:"market-participants-and-trading-strategies",children:(0,s.jsx)(i.strong,{children:"Market Participants and Trading Strategies"})}),"\n",(0,s.jsx)(i.h3,{id:"liquidity-providers-and-market-makers",children:(0,s.jsx)(i.strong,{children:"Liquidity Providers and Market Makers"})}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"Market Makers:"})," Continuously place bid and ask orders to facilitate liquidity."]}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"Liquidity Takers:"})," Execute trades against existing orders, removing liquidity."]}),"\n"]}),"\n",(0,s.jsxs)(i.p,{children:["Market makers earn profits by capturing the ",(0,s.jsx)(i.strong,{children:"bid-ask spread"}),"."]}),"\n",(0,s.jsx)(i.h3,{id:"order-visibility",children:(0,s.jsx)(i.strong,{children:"Order Visibility"})}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"Hidden Orders:"})," Do not appear in public order books but execute normally."]}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"Iceberg Orders:"})," Display only a small portion of the total order to prevent price mani
1pulation."]}),"\n"]}),"\n",(0,s.jsx)(i.h3,{id:"auctions-in-traditional-markets",children:(0,s.jsx)(i.strong,{children:"Auctions in Traditional Markets"})}),"\n",(0,s.jsxs)(i.p,{children:["Stock exchanges conduct ",(0,s.jsx)(i.strong,{children:"opening and closing auctions"})," to establish fair prices when markets open or close. During auctions:"]}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsx)(i.li,{children:"Orders accumulate but do not execute immediately."}),"\n",(0,s.jsxs)(i.li,{children:["A theoretical ",(0,s.jsx)(i.strong,{children:"Indicative Equilibrium Price (IEP)"})," is calculated."]}),"\n",(0,s.jsxs)(i.li,{children:["The book ",(0,s.jsx)(i.strong,{children:'"uncrosses"'}),", matching orders at a single opening price."]}),"\n"]}),"\n",(0,s.jsx)(i.p,{children:"For example:"}),"\n",(0,s.jsxs)(i.table,{children:[(0,s.jsx)(i.thead,{children:(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.th,{children:"Price Level"}),(0,s.jsx)(i.th,{children:"Bid Quantity"}),(0,s.jsx)(i.th,{children:"Ask Quantity"})]})}),(0,s.jsxs)(i.tbody,{children:[(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.td,{children:"103"}),(0,s.jsx)(i.td,{children:"1200"}),(0,s.jsx)(i.td,{children:"1500"})]}),(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.td,{children:"102"}),(0,s.jsx)(i.td,{children:"1800"}),(0,s.jsx)(i.td,{})]})]})]}),"\n",(0,s.jsx)(i.p,{children:"An auction might determine the open price as 103, maximizing traded volume."}),"\n",(0,s.jsx)(i.h2,{id:"market-data-and-depth-analysis",children:(0,s.jsx)(i.strong,{children:"Market Data and Depth Analysis"})}),"\n",(0,s.jsx)(i.h3,{id:"levels-of-market-data",children:(0,s.jsx)(i.strong,{children:"Levels of Market Data"})}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"Level 1 (L1):"})," Shows only the best bid and ask prices."]}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"Level 2 (L2):"})," Displays aggregated quantities at multiple price levels."]}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"Level 3 (L3):"})," Provides full details of individual orders at each level."]}),"\n"]}),"\n",(0,s.jsx)(i.h3,{id:"market-impact-and-depth-charts",children:(0,s.jsx)(i.strong,{children:"Market Impact and Depth Charts"})}),"\n",(0,s.jsxs)(i.p,{children:["Large market orders can ",(0,s.jsx)(i.strong,{children:"move prices"})," due to insufficient liquidity. Traders analyze ",(0,s.jsx)(i.strong,{children:"depth charts"})," to assess liquidity:"]}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"Thicker books (higher depth):"})," More liquidity, less price impact."]}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.strong,{children:"Thinner books (lower depth):"})," Higher volatility and price slippage."]}),"\n"]}),"\n",(0,s.jsx)(i.h1,{id:"resources",children:"Resources"}),"\n",(0,s.jsx)(i.p,{children:(0,s.jsx)(i.a,{href:"https://www.machow.ski/posts/2021-07-18-introduction-to-limit-order-books/",children:"https://www.machow.ski/posts/2021-07-18-introduction-to-limit-order-books/"})}),"\n",(0,s.jsx)(i.p,{children:(0,s.jsx)(i.a,{href:"https://arxiv.org/html/2402.17359v1",children:"https://arxiv.org/html/2402.17359v1"})})]})}function h(e={}){const{wrapper:i}={...(0,t.R)(),...e.components};return i?(0,s.jsx)(i,{...e,children:(0,s.jsx)(c,{...e})}):c(e)}},50831:(e,i,r)=>{r.d(i,{R:()=>d,x:()=>l});var n=r(94344);const s={},t=n.createContext(s);function d(e){const i=n.useContext(t);return n.useMemo(function(){return"function"==typeof e?e(i):{...i,...e}},[i,e])}function l(e){let i;return i=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:d(e.components),n.createElement(t.Provider,{value:i},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.