← Back to Learn
I BeginnerWeek 2 • Lesson 5Duration: 35 min

MKT Market Microstructure

The hidden costs that make or break strategies

Learning Objectives

  • Understand bid-ask spreads, order books, and how prices form
  • See how slippage and market impact eat into real performance
  • Quantify execution costs and figure out if they kill your edge
  • Know which timeframe-asset combos actually work for systematic trading

Explain Like I'm 5

When you buy something at a store, there's one price tag. In financial markets, there are always two prices: what buyers will pay (bid) and what sellers want (ask). The gap between them is a cost you pay on every trade. Understanding this cost tells you which strategies work in practice versus only on paper.

Think of It This Way

The order book is like a farmers' market. Sellers display their asking prices on one side, buyers show what they'll pay on the other. The "market price" is where the last deal happened. A busy market has tight spreads (lots of competition). A quiet market has wide spreads and higher costs.

1Bid, Ask, and the Spread

Every tradeable instrument has two prices at all times: Bid: The highest price someone is willing to pay right now. Ask (Offer): The lowest price someone is willing to sell for. Spread = Ask − Bid. Market buy orders fill at the ask. Market sell orders fill at the bid. The spread is the cost of getting into a position. Spreads vary a lot by instrument: • Major forex (EUR/USD): 0.1–0.5 pips • Minor forex: 1–3 pips • Gold (XAU/USD): 2–5 pips • Major indices: 0.25–1.0 points • Crypto: all over the place, 1–50+ basis points Institutional systems track the spread-to-ATR ratio as an input feature. When spreads widen (usually during news or thin liquidity), signal quality drops and trade costs spike. Reference: Harris, L. (2003). "Trading and Exchanges." Oxford University Press.

Typical Spread Cost by Asset Class (% of ATR)

2Slippage and Market Impact

Slippage is the difference between the price you expected and the price you actually got. It happens because: • The market moved between your decision and your execution • Large orders eat through multiple order book levels • Price gaps during volatile events For standard-lot forex, slippage is usually 0.1–0.5 pips under normal conditions. During major news, it can jump past 5 pips. Backtesting rule: Every backtest needs realistic slippage estimates. A strategy that only works with zero slippage doesn't actually work. Professional teams add 0.5–1.0 standard deviations of historical slippage as a safety margin.

3Timeframe Selection and Strategy Viability

Microstructure determines which strategies can actually work at which frequencies: High Frequency (sub-second): Needs co-location, sub-millisecond execution, tiny per-trade edges. Transaction costs dominate. Not viable for most people. Medium Frequency (M15–H1): The practical sweet spot for ML-based trading. Generates ~600 trades/year (enough for statistical significance) while keeping costs as a small fraction of your edge. Low Frequency (D1–W1): Bigger per-trade edge, fewer opportunities. Spread costs don't matter much relative to expected profit, but limited sample sizes make it hard to prove your edge is real. The test that matters: Your expected R per trade has to clear total execution costs by a comfortable margin. If your edge is +0.10R but costs are 0.05R, your real edge is only 0.05R — fragile and likely to disappear. Reference: Kissell, R. (2013). "The Science of Algorithmic Trading." Academic Press.

Edge vs Cost by Trading Frequency

Key Formulas

Spread Cost in R-Multiples

Converts spread from pips to R-multiples. A 1-pip spread with a 50-pip stop = 0.02R per trade. Over thousands of trades, that adds up fast.

Net Edge After Costs

Your true edge is gross expected value minus all execution costs. If E_net ≤ 0, the strategy is a backtest artifact that will lose money live.

Hands-On Code

Quantifying Execution Cost Impact

python
import numpy as np

# --- Execution Cost Analysis ---
gross_edge_r     = 0.25      # Gross edge per trade (R)
spread_pips      = 0.3       # Typical EUR/USD spread
avg_stop_pips    = 45        # Average stop-loss distance
slippage_pips    = 0.2       # Conservative estimate
commission_r     = 0.005     # Commission as fraction of R

# Convert to R-multiples
spread_r   = spread_pips / avg_stop_pips
slippage_r = slippage_pips / avg_stop_pips
total_cost = spread_r + slippage_r + commission_r
net_edge   = gross_edge_r - total_cost

print("=== Execution Cost Breakdown ===")
print(f"Gross E[R]:    {gross_edge_r:+.4f}R")
print(f"Spread:       -{spread_r:.4f}R")
print(f"Slippage:     -{slippage_r:.4f}R")
print(f"Commission:   -{commission_r:.4f}R")
print(f"Total cost:   -{total_cost:.4f}R")
print(f"Net E[R]:      {net_edge:+.4f}R")
print(f"Cost / Edge:   {total_cost/gross_edge_r*100:.1f}%")

# Annual impact
n_trades = 600
print(f"\nAnnual cost drag: {total_cost * n_trades:.1f}R")

This converts all execution costs into R-multiples and shows how much they eat into your edge. Many strategies that look great in frictionless backtests become losers with realistic costs. Always compute net edge.

Knowledge Check

Q1.When you place a market buy order, at which price are you filled?

Q2.Why is M15–H1 considered the sweet spot for ML-based trading?

Assignment

Research current spreads for 5 instruments across different asset classes. For each, compute the spread cost in R assuming a stop loss of 1.5× ATR(14). Rank instruments by cost efficiency. Which ones offer the best structure for systematic trading? Document your methodology and findings.