
Order Types
An exchange is a service that provides two basic operations:- Limit Order: “I want to buy (or sell) a specific amount of an asset at a set price (or better) sometime in the future.”

- Guarantees: The execution price (you’ll get your specified price or better).
- Doesn’t Guarantee: Execution timing or if the order will be filled.
- Market Order says: “I want to buy (or sell) a specific amount of an asset right now at the best available price.”

- Guarantees: Immediate execution.
- Doesn’t Guarantee: The exact price
Order Book and Trades

- User A places a buy limit order for 1 BTC at 96,500 USDT.
- This is a bid (a limit order to buy).
- The order book now looks like this:
Price (USDT) Amount (BTC) 96,500 (Bid) 1 BTC
- User B places a market sell order for 0.5 BTC.
- The exchange matches this with User A’s bid.
- Trade: User B sells 0.5 BTC to User A at 96,500 USDT.
- Updated order book:
Price (USDT) Amount (BTC) 96,500 (Bid) 0.5 BTC
- User C places a sell limit order for 5 BTC at 96,600 USDT.
- This is an ask (a limit order to sell).
- Note: Bids must be below the lowest ask (96,600), and asks must be above the highest bid (96,500), unless they’re meant to match immediately.
- Updated order book:
Price (USDT) Amount (BTC) 96,600 (Ask) 5 BTC 96,500 (Bid) 0.5 BTC
- More users add orders, creating a deeper order book:
Price (USDT) Amount (BTC) 96,700 (Ask) 2 BTC 96,600 (Ask) 5 BTC 96,500 (Bid) 0.5 BTC 96,400 (Bid) 3 BTC - User D places a market buy order for 6 BTC.
- The order is filled from the lowest asks first:
- 5 BTC at 96,600 USDT = 5 × 96,600 = 483,000 USDT.
- 1 BTC at 96,700 USDT = 1 × 96,700 = 96,700 USDT.
- Total Cost: 483,000 + 96,700 = 579,700 USDT.
- Updated order book:
Price (USDT) Amount (BTC) 96,700 (Ask) 1 BTC 96,500 (Bid) 0.5 BTC 96,400 (Bid) 3 BTC
- The order is filled from the lowest asks first:
- Trades are recorded with timestamps for transparency:
- Trade 1: 5 BTC at 96,600 USDT.
- Trade 2: 1 BTC at 96,700 USDT.
