Advertisement IC Markets

Average spread is a poor guide, median spread is better

Real-time market analysis, live trade entries, order flow commentary, and daily setups for the London, New York, and Asian session overlaps.
Post Reply
Fairman
Posts: 7554
Joined: Tue Jul 21, 2026 7:11 am
Location: Abuja

Average spread is a poor guide, median spread is better

Post by Fairman »

Average spread is a poor guide, median spread is better

Brokers advertise average spreads, and the figure is dominated by outliers. A few moments of 10 pip spreads at rollover lift the average noticeably, yet those moments do not matter if no trading happens then. Alternatively, a broker may show a low average computed only over liquid hours.

For scalpers, the median spread across the actual trading hours is far more representative. It shows what the typical entry costs, ignoring rare spikes. Then the tail, such as the 95th or 99th percentile, shows how bad things get.

Both numbers matter. A broker with a median of 0.2 and a 99th percentile of 3.0 is very different from one with a median of 0.4 and a 99th percentile of 0.9. The first looks cheaper but delivers occasional painful fills. The second is steadier.

Collect tick data for the traded window and compute the full distribution. A histogram makes differences between brokers instantly visible.

Then decide whether tight and spiky or slightly wider and steady suits the strategy better.

Which spread statistic has proved most useful when comparing brokers?
It’s Fairman :geek:
Recommended broker for automated trading & scalping IC Markets
Amanhasnoname
Posts: 2602
Joined: Fri Oct 30, 2026 9:45 am

Re: Average spread is a poor guide, median spread is better

Post by Amanhasnoname »

The advertised average was the number that used to fool me. I pulled six London weeks of ticks from two brokers on the same EURUSD hours, seven until eleven in the morning. Broker A posted an average of eighteen hundredths of a pip, helped by a few dead overnight prints. During my window the median sat at twenty-two hundredths and the ninety-fifth percentile at one point four pips. Broker B advertised thirty-one hundredths because rollover was included; its median in my hours was nineteen hundredths and the ninety-fifth percentile only fifty-five.

I trade the typical entry, so the median of my actual session is the figure I trust first. The tail tells me whether a news burst will wreck a working stop. The average mixes those two stories and hides which broker I would rather sit with at eight o'clock.

For my style the steadier book won, even though its advertised average looked worse. I would rather pay a couple of extra hundredths every morning than eat a one-pip surprise a few times a month.
PTScalper
Site Admin
Posts: 7923
Joined: Mon Jul 20, 2026 1:28 pm

Re: Average spread is a poor guide, median spread is better

Post by PTScalper »

Fairman wrote: Mon Nov 02, 2026 11:43 pm Average spread is a poor guide, median spread is better

Brokers advertise average spreads, and the figure is dominated by outliers. A few moments of 10 pip spreads at rollover lift the average noticeably, yet those moments do not matter if no trading happens then. Alternatively, a broker may show a low average computed only over liquid hours.

For scalpers, the median spread across the actual trading hours is far more representative. It shows what the typical entry costs, ignoring rare spikes. Then the tail, such as the 95th or 99th percentile, shows how bad things get.

Both numbers matter. A broker with a median of 0.2 and a 99th percentile of 3.0 is very different from one with a median of 0.4 and a 99th percentile of 0.9. The first looks cheaper but delivers occasional painful fills. The second is steadier.

Collect tick data for the traded window and compute the full distribution. A histogram makes differences between brokers instantly visible.

Then decide whether tight and spiky or slightly wider and steady suits the strategy better.

Which spread statistic has proved most useful when comparing brokers?
Hi Fairman,

regarding mean vs. median and tail percentiles, but there is a third dimension that makes even a 0.0–0.1 pip median spread misleading on its own: the available liquidity sitting at the best bid and ask for that quoted price.

A standard tick chart or spread histogram only records Level 1 price—it tells you nothing about Level 1 volume. Seeing a 0.0 pip spread on EUR/USD or a tight quote on Gold is meaningless if there is only 0.5 or 1 standard lot resting at the top of the book. The moment you fire a 5, 10, or 20-lot market order, you wipe out that paper-thin top-of-book quote and immediately walk up or down the order book into Level 2 and Level 3 pricing.

In practice, this creates a huge gap between quoted spread and executable spread:

Thin & Tight vs. Deep & Steady: Broker A might show a 0.0 pip median spread because one aggressive liquidity provider (LP) constantly posts tiny 50k–100k clips at the touch. Broker B might show a steady 0.3 pip median spread, but backs that price with 30 to 50 lots of real institutional depth. For a 0.1-lot trader, Broker A is cheaper. For anyone scaling into serious lot sizes, Broker B actually delivers the lower all-in fill cost.

Phantom Liquidity and "Last-Look" Flicker: On many aggregated ECN feeds, those razor-thin 0.0 pip ticks only exist for a few milliseconds before flickering back out. Because many LPs operate on "last-look" execution, passive tick collectors capture the tight quote, making the broker's spread histogram look phenomenal—yet when a live order actually hits the matching engine, the quote vanishes or rejects, resulting in asymmetric negative slippage.

Market Impact During Volatility: During fast momentum breaks, top-of-book depth evaporates first. A broker's 95th percentile spread might only widen from 0.2 to 0.8 pips on the chart, while the depth at that 0.8 pip quote drops by 80%, turning what looks like a manageable spread into a multi-pip slippage event on real size.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 7923
Joined: Mon Jul 20, 2026 1:28 pm

Re: Average spread is a poor guide, median spread is better

Post by PTScalper »

To answer your question directly, the metric that has proved most useful in practice is Volume-Weighted Effective Spread (VWES) for your exact target clip size—and, where Level 2 / DOM depth isn't exposed by the feed, Realized All-In Execution Cost (Half-Spread + Commission + Live Fill Slippage) logged directly from live trade telemetry.

A passive tick histogram tells you what a broker advertises to a 0.01-lot observer; tracking effective cost at your actual position size tells you what it really costs to get in and out when money is on the line.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 7923
Joined: Mon Jul 20, 2026 1:28 pm

Re: Average spread is a poor guide, median spread is better

Post by PTScalper »

This Python module walks both sides of a Level 2 (Depth of Market) order book snapshot to compute the Volume-Weighted Effective Spread (VWES) for any target lot size, alongside one-sided effective spreads and book-sweep slippage beyond Level 1.

Code: Select all

from dataclasses import dataclass
from statistics import median
from typing import Iterable, Optional


@dataclass(frozen=True)
class BookLevel:
    """Single price tier in a Level 2 order book."""
    price: float
    volume_lots: float


@dataclass(frozen=True)
class OrderBookSnapshot:
    """Point-in-time Level 2 bid/ask depth snapshot."""
    timestamp: str
    bids: list[BookLevel]
    asks: list[BookLevel]


@dataclass(frozen=True)
class SpreadMetrics:
    """Execution cost breakdown for a specific target clip size."""
    lot_size: float
    top_of_book_pips: float
    vw_effective_spread_pips: float
    buy_effective_pips: float
    sell_effective_pips: float
    book_slippage_pips: float
    bid_levels_swept: int
    ask_levels_swept: int


def walk_book(levels: Iterable[BookLevel], target_lots: float, is_bid: bool) -> Optional[tuple[float, int]]:
    """
    Walks sorted order book tiers until `target_lots` is filled.
    Returns (vwap_price, levels_consumed), or None if total book depth is insufficient.
    """
    if target_lots <= 0:
        raise ValueError("target_lots must be positive.")

    # Bids sort highest-to-lowest; asks sort lowest-to-highest
    sorted_levels = sorted(levels, key=lambda x: x.price, reverse=is_bid)

    remaining = target_lots
    weighted_notional = 0.0
    levels_consumed = 0

    for level in sorted_levels:
        if level.volume_lots <= 0:
            continue

        fill_qty = min(remaining, level.volume_lots)
        weighted_notional += fill_qty * level.price
        remaining -= fill_qty
        levels_consumed += 1

        if remaining <= 1e-12:
            return (weighted_notional / target_lots), levels_consumed

    return None  # Insufficient liquidity in the visible book


def calculate_vw_spread(
    snapshot: OrderBookSnapshot,
    lot_size: float,
    pip_size: float = 0.0001,
) -> Optional[SpreadMetrics]:
    """
    Computes volume-weighted effective spread and slippage vs. Level 1 for `lot_size`.
    """
    if not snapshot.bids or not snapshot.asks:
        return None

    best_bid = max(level.price for level in snapshot.bids)
    best_ask = min(level.price for level in snapshot.asks)
    mid_price = (best_bid + best_ask) / 2.0
    l1_spread_pips = (best_ask - best_bid) / pip_size

    bid_fill = walk_book(snapshot.bids, lot_size, is_bid=True)
    ask_fill = walk_book(snapshot.asks, lot_size, is_bid=False)

    if bid_fill is None or ask_fill is None:
        return None

    vwap_bid, bid_levels = bid_fill
    vwap_ask, ask_levels = ask_fill

    # Round-trip book sweep spread for size Q
    vw_spread_pips = (vwap_ask - vwap_bid) / pip_size

    # Standard microstructure effective spread: 2 * |execution_price - midpoint|
    buy_effective_pips = (2.0 * (vwap_ask - mid_price)) / pip_size
    sell_effective_pips = (2.0 * (mid_price - vwap_bid)) / pip_size

    # Extra spread incurred from walking past Level 1
    book_slippage_pips = vw_spread_pips - l1_spread_pips

    return SpreadMetrics(
        lot_size=lot_size,
        top_of_book_pips=round(l1_spread_pips, 3),
        vw_effective_spread_pips=round(vw_spread_pips, 3),
        buy_effective_pips=round(buy_effective_pips, 3),
        sell_effective_pips=round(sell_effective_pips, 3),
        book_slippage_pips=round(book_slippage_pips, 3),
        bid_levels_swept=bid_levels,
        ask_levels_swept=ask_levels,
    )


def summarize_series(
    snapshots: list[OrderBookSnapshot],
    lot_size: float,
    pip_size: float = 0.0001,
) -> dict[str, float]:
    """
    Aggregates median, 95th percentile, and rejection/partial-fill rate across many snapshots.
    """
    vw_spreads: list[float] = []
    insufficient_count = 0

    for snap in snapshots:
        metrics = calculate_vw_spread(snap, lot_size, pip_size)
        if metrics is None:
            insufficient_count += 1
        else:
            vw_spreads.append(metrics.vw_effective_spread_pips)

    if not vw_spreads:
        return {"valid_ticks": 0, "insufficient_liquidity_pct": 100.0}

    vw_spreads.sort()
    p95_idx = min(int(0.95 * len(vw_spreads)), len(vw_spreads) - 1)

    return {
        "valid_ticks": len(vw_spreads),
        "median_vwes_pips": round(median(vw_spreads), 3),
        "p95_vwes_pips": round(vw_spreads[p95_idx], 3),
        "insufficient_liquidity_pct": round((insufficient_count / len(snapshots)) * 100.0, 2),
    }


if __name__ == "__main__":
    # Broker A: 0.0 pip top-of-book, but paper-thin L1/L2 depth
    broker_a_thin = OrderBookSnapshot(
        timestamp="2026-11-17T14:30:00.120Z",
        bids=[
            BookLevel(1.08500, 0.5),
            BookLevel(1.08496, 1.5),
            BookLevel(1.08490, 4.0),
            BookLevel(1.08480, 10.0),
            BookLevel(1.08465, 20.0),
        ],
        asks=[
            BookLevel(1.08500, 0.5),
            BookLevel(1.08504, 1.5),
            BookLevel(1.08510, 4.0),
            BookLevel(1.08520, 10.0),
            BookLevel(1.08535, 20.0),
        ],
    )

    # Broker B: 0.3 pip top-of-book, backed by institutional L1 depth
    broker_b_deep = OrderBookSnapshot(
        timestamp="2026-11-17T14:30:00.120Z",
        bids=[
            BookLevel(1.084985, 15.0),
            BookLevel(1.084975, 25.0),
            BookLevel(1.084960, 40.0),
        ],
        asks=[
            BookLevel(1.085015, 15.0),
            BookLevel(1.085025, 25.0),
            BookLevel(1.085040, 40.0),
        ],
    )

    test_lots = [0.1, 1.0, 5.0, 10.0, 25.0]

    for name, book in [("Broker A (Thin 0.0 L1)", broker_a_thin), ("Broker B (Deep 0.3 L1)", broker_b_deep)]:
        print(f"\n=== {name} ===")
        print(f"{'Lots':>6} | {'L1 Spr':>7} | {'VWES':>7} | {'Sweep Slip':>10} | {'Levels (B/A)':>12}")
        print("-" * 54)
        for lots in test_lots:
            res = calculate_vw_spread(book, lots, pip_size=0.0001)
            if res is None:
                print(f"{lots:6.1f} | {'N/A':>7} | {'INSUFFICIENT DEPTH':>32}")
            else:
                levels_str = f"{res.bid_levels_swept}/{res.ask_levels_swept}"
                print(
                    f"{res.lot_size:6.1f} | "
                    f"{res.top_of_book_pips:7.2f} | "
                    f"{res.vw_effective_spread_pips:7.2f} | "
                    f"{res.book_slippage_pips:10.2f} | "
                    f"{levels_str:>12}"
                )
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 7923
Joined: Mon Jul 20, 2026 1:28 pm

Re: Average spread is a poor guide, median spread is better

Post by PTScalper »

Key Implementation Details

Separate One-Sided Effective Spreads (buy_effective_pips vs. sell_effective_pips): Order books rarely thin out symmetrically before news or around liquidity sweeps. Computing $2 \times \vert{}P_{\text{VWAP}} - P_{\text{mid}}\vert{}$ per side reveals when one side of the book is hollow even though the combined round-trip spread still looks reasonable.

Explicit Liquidity Exhaustion (None return): If a target order size exceeds the total resting volume in the visible book, walk_book returns None rather than dividing by a partial fill—allowing summarize_series to report an insufficient_liquidity_pct tail metric alongside the median and 95th percentile VWES.

Instrument Agnostic: Pass pip_size=0.01 for JPY pairs or Gold (XAU/USD), or pip_size=1.0 for index points, while keeping volume_lots in whatever unit your DOM feed emits (lots, contracts, or base currency units).
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
FXS Prop Desk
Posts: 1835
Joined: Wed Oct 07, 2026 9:52 am

Re: Average spread is a poor guide, median spread is better

Post by FXS Prop Desk »

Fairman wrote: Average spread is a poor guide, median spread is better Brokers advertise average spreads, and the figure is dominated by outliers.
Asking for spread percentiles by hour, rather than one figure, gets closest to the truth. If a broker cannot provide them, logging a week of quotes during the hours actually traded gives the median and the tail that matter for a specific strategy.
FXS Official Team | The Idea Lab & Strategy
Fairman
Posts: 7554
Joined: Tue Jul 21, 2026 7:11 am
Location: Abuja

Re: Average spread is a poor guide, median spread is better

Post by Fairman »

FXS Prop Desk wrote: Thu Nov 26, 2026 7:19 pmIf a broker cannot provide them, logging a week of quotes during the hours actually traded gives the median and the tail that matter for a specific strategy.
Logging my own quotes for the hours I actually trade is where I'd start, and it's cheap to do. I'd keep the sample to the same window I scalp, say the London open, and look at the median and the 95th percentile side by side. The median tells me what a normal entry costs. The tail tells me how often a stop gets filled worse than planned, and that matters more to me than the headline figure. If the 95th percentile is five times the median, then on the bad days the median isn't the cost of that ticket at all. I'd also split the log by hour, because a broker that looks tight from 07:00 to 11:00 can be wide at 13:30, when I'm not trading anyway. One week is a small sample, so I'd treat it as a first look and repeat it before changing anything. Asking support for percentiles by hour is worth doing too, but I'd run my own log either way and compare the two.
It’s Fairman :geek:
Post Reply