A strategy chooses desired exposure; execution decides the price, timing and certainty with which you obtain it. The same signal can be profitable with patient limits and unprofitable with repeated market orders. Treat execution as a measurable part of the strategy, not plumbing after the decision.
The book, spread and marketable price
The best bid is the highest resting buy; the best ask is the lowest resting sell. Their difference is the spread. A buy priced at or above the ask is marketable and consumes liquidity. A buy below the ask rests until a seller reaches it—unless it is cancelled first. “Market” means execute against available orders, not “fill at the last traded price.”
Core order instructions
| Instruction | Guarantees | Does not guarantee | Typical use |
|---|---|---|---|
| Market | Immediate attempt | Price or complete fill in a broken market | Urgent risk reduction |
| Limit | No worse than limit price | Any fill | Price-controlled entry/exit |
| Stop-market | Becomes marketable after trigger | Trigger-to-fill price | Protection when certainty matters |
| Stop-limit | Limit after trigger | Exit during a gap | Controlled price with accepted non-fill risk |
| Post-only | Must rest as maker or cancel | Fill | Passive quoting and maker control |
Time in force: GTC, IOC and FOK
- GTC remains until filled or cancelled.
- IOC fills immediately as much as possible and cancels the remainder.
- FOK requires the full quantity immediately or cancels everything.
IOC is useful when a bot accepts partial liquidity inside a price cap but refuses to leave a stale order. FOK is stricter and often fills less. Exchange names and combinations differ, so verify exact product documentation and test the smallest permitted order.
Calculate execution cost from the decision price
Record the mid-price or best executable quote when the strategy decided, then compare it with volume-weighted average fill. For a buy, slippage bps = (fill ÷ decision price − 1) × 10,000. Add fees and, for positions held across settlements, funding or borrow.
Example: the decision ask is 100.00; 40% fills at 100.02 and 60% at 100.10. Average fill is 100.068, or 6.8 bps above the decision ask. A 5 bps taker fee makes entry cost 11.8 bps before the exit. A strategy expecting 8 bps has already lost its statistical edge.
Partial fills, cancel races and uncertain state
An order acknowledgement only proves that a request was accepted for processing. A timeout does not prove rejection; retrying blindly can duplicate exposure. Use a unique client order ID, then query the order and fills. Cancellation can race with a match, so reconcile final filled quantity before sending the replacement.
Desired position, submitted orders, exchange open orders, fills and actual position are separate states. A reliable system continuously reconciles them. When state is unknown, fail closed: stop increasing risk until visibility is restored.
Execution policy by objective
- Entry with weak urgency: post-only or patient limit, bounded by signal lifetime.
- Entry with a price cap: marketable limit or IOC, never an unlimited sweep.
- Routine profit exit: reduce-only limit, replaced only under an explicit repricing rule.
- Risk stop: exchange-side trigger where available, with position and protection monitoring.
- Emergency flatten: reduce-only marketable order with maximum slippage and retry policy.
Primary reference
The official CCXT manual documents common order types, time-in-force values, order books, client IDs, precision and rate limits across exchanges. Its unified model is a starting vocabulary; exchange-specific parameters and actual fills remain the source of truth.