mysi Find

Calculator in Markets and quant

Execution cost of a stock order

Estimates the impact and spread cost of one stock order by the Almgren et al. (2005) model, with fill time.

In short

Formulaσ = daily_vol_pct × 100, in bps; rate = participation_pct ÷ 100permanentBps = 0.314 × σ × (order_size ÷ adv) × inverse_turnover^(1/4)temporaryBps = 0.142 × σ × rate^(3/5)realizedImpactBps = permanentBps ÷ 2 + temporaryBps; halfSpreadBps = spread_bps ÷ 2totalBps = realizedImpactBps + halfSpreadBpsnotionalUsd = order_size × ref_price; totalDollars = totalBps ÷ 10000 × notionalUsddurationMinutes = order_size ÷ (rate × adv ÷ 390); durationTradingDays = durationMinutes ÷ 390timingRiskBps = σ × √(durationMinutes ÷ 390)latencyDriftBps = σ × √(latency_ms ÷ (390 × 60000))
UnitsShares, bps, percent, ms, dollars in; bps, dollars, minutes, days out. A session is 390 minutes (NYSE, 9:30–16:00).
Defaults(ranges) order_size 50000 (1–1e12), adv 5000000 (1–1e12), spread_bps 8 (0–10000), daily_vol_pct 2 (0.01–100), participation_pct 10 (0.01–100), latency_ms 150 (0–3600000), ref_price 100 (0.0001–1e9), inverse_turnover 263 (0.01–1e6; IBM in the paper's Table 3).
Worked examplethe defaults. σ = 200 bps. permanentBps = 0.314 × 200 × 0.01 × 4.0271 = 2.529temporaryBps = 0.142 × 200 × 0.1^0.6 = 7.134totalBps = 1.2645 + 7.1338 + 4 = 12.398totalDollars = 12.398÷10000 × 5000000 = 6199.128durationMinutes = 50000 ÷ 1282.05 = 39timingRiskBps = 200 × √0.1 = 63.246

By hand: yes. A small model got these answers from the formulas above, without running code.

Say this to your agent

Use https://mysi.dev/execution-simulator/ to estimate the cost of buying 50,000 shares at $100, 5M ADV, 2% vol, 8 bps spread, 10% POV.

Nothing to install, no key, no settings. An agent that can open web pages and run Python opens the page, runs the tested code in its own sandbox and gives you the answer.

The code

Copy this into your Python tool. Run execution_simulator_check() first, then call execution_simulator() with your numbers. Give the answer with the cite line.

"""Execution cost of a stock order: estimates the impact and spread cost of one stock order
with the model and coefficients of Almgren, Thum, Hauptmann and Li (2005), plus fill time
and 1-sigma risks.
Inputs: order_size (shares, 1 or more, default 50000), adv (average daily volume in shares,
1 or more, default 5000000), spread_bps (full quoted spread, 0 to 10000, default 8),
daily_vol_pct (daily volatility in percent, 0.01 to 100, default 2), participation_pct
(share of market volume taken while working, 0.01 to 100, default 10), latency_ms (mean
order-to-market latency, 0 to 3600000, default 150), ref_price (mid price, 0.0001 to 1e9,
default 100), inverse_turnover (shares outstanding / adv, 0.01 to 1e6, default 263).
Returns: permanentBps, temporaryBps, realizedImpactBps, halfSpreadBps, totalBps, totalDollars,
notionalUsd, durationMinutes, durationTradingDays, timingRiskBps, latencyDriftBps.
mysi, Execution cost of a stock order, mysi.dev/execution-simulator, version 1,
changed 2026-12-04. MIT.
"""
import math

_EXECUTION_SIMULATOR_GAMMA = 0.314  # permanent impact, Almgren et al. 2005, section 4.3
_EXECUTION_SIMULATOR_ETA = 0.142    # temporary impact, Almgren et al. 2005, section 4.3
_EXECUTION_SIMULATOR_SESSION = 390  # minutes in a regular NYSE session, 9:30 to 16:00


def _execution_simulator_num(name, value, low, high):
    if isinstance(value, bool) or not isinstance(value, (int, float)) or not low <= value <= high:
        raise ValueError(f"{name} must be a number from {low} to {high}")
    return float(value)


def execution_simulator(order_size=50000, adv=5000000, spread_bps=8, daily_vol_pct=2,
                        participation_pct=10, latency_ms=150, ref_price=100,
                        inverse_turnover=263):
    num = _execution_simulator_num
    x = num("order_size", order_size, 1, 1e12)
    v = num("adv", adv, 1, 1e12)
    spread = num("spread_bps", spread_bps, 0, 10000)
    sigma_bps = num("daily_vol_pct", daily_vol_pct, 0.01, 100) * 100
    rate = num("participation_pct", participation_pct, 0.01, 100) / 100
    latency = num("latency_ms", latency_ms, 0, 3600000)
    price = num("ref_price", ref_price, 0.0001, 1e9)
    turnover = num("inverse_turnover", inverse_turnover, 0.01, 1e6)
    session = _EXECUTION_SIMULATOR_SESSION
    permanent = _EXECUTION_SIMULATOR_GAMMA * sigma_bps * (x / v) * turnover ** 0.25
    temporary = _EXECUTION_SIMULATOR_ETA * sigma_bps * rate ** 0.6
    realized = permanent / 2 + temporary
    total = realized + spread / 2
    minutes = x / (rate * v / session)
    return {
        "permanentBps": permanent,
        "temporaryBps": temporary,
        "realizedImpactBps": realized,
        "halfSpreadBps": spread / 2,
        "totalBps": total,
        "totalDollars": total / 10000 * x * price,
        "notionalUsd": x * price,
        "durationMinutes": minutes,
        "durationTradingDays": minutes / session,
        "timingRiskBps": sigma_bps * math.sqrt(minutes / session),
        "latencyDriftBps": sigma_bps * math.sqrt(latency / (session * 60000)),
    }


EXECUTION_SIMULATOR_CASES = [
    ({"order_size": 656100, "adv": 6561000, "spread_bps": 0, "daily_vol_pct": 1.57,
      "participation_pct": 100, "inverse_turnover": 263},
     {"permanentBps": 19.8526, "temporaryBps": 22.2940, "realizedImpactBps": 32.2203}),
    ({"order_size": 192900, "adv": 1929000, "spread_bps": 0, "daily_vol_pct": 2.26,
      "participation_pct": 20, "inverse_turnover": 87},
     {"permanentBps": 21.6729, "temporaryBps": 12.2184, "realizedImpactBps": 23.0549}),
    ({"order_size": 50000, "adv": 5000000, "spread_bps": 8, "daily_vol_pct": 2,
      "participation_pct": 10, "latency_ms": 150, "ref_price": 100, "inverse_turnover": 263},
     {"totalBps": 12.3983, "durationMinutes": 39.0, "timingRiskBps": 63.2456}),
]


def execution_simulator_check(tolerance=1e-3):
    for given, want in EXECUTION_SIMULATOR_CASES:
        got = execution_simulator(**given)
        for name, value in want.items():
            close = abs(got[name] - value) <= tolerance * max(1, abs(value))
            assert close, (name, got[name], value)
    return "ok"


if __name__ == "__main__":
    import json, sys
    execution_simulator_check()
    given = dict(a.split("=", 1) for a in sys.argv[1:] if "=" in a)
    js = lambda v: v.lstrip("-")[:1].isdigit() or v[:1] in '[{".' or v in ("true", "false", "null")
    given = {k: json.loads(v) if js(v) else v for k, v in given.items()}
    if given:
        print(json.dumps(execution_simulator(**given)))
Raw file

More test values

What goes inWhat comes outWhere the answer is from
order_size 656100, adv 6561000, spread_bps 0, daily_vol_pct 1.57, participation_pct 50, inverse_turnover 263permanentBps 20, temporaryBps 15, realizedImpactBps 25Almgren, Thum, Hauptmann and Li, Direct estimation of equity market impact, Risk 18(7), 2005, Table 3: a purchase of 10% of average daily volume; T = 0.1, 0.2, 0.5 days is a participation of 100%, 50%, 20%. Values in bps rounded to whole numbers
order_size 656100, adv 6561000, spread_bps 0, daily_vol_pct 1.57, participation_pct 20, inverse_turnover 263permanentBps 20, temporaryBps 8, realizedImpactBps 18Almgren, Thum, Hauptmann and Li, Direct estimation of equity market impact, Risk 18(7), 2005, Table 3: a purchase of 10% of average daily volume; T = 0.1, 0.2, 0.5 days is a participation of 100%, 50%, 20%. Values in bps rounded to whole numbers
order_size 192900, adv 1929000, spread_bps 0, daily_vol_pct 2.26, participation_pct 100, inverse_turnover 87permanentBps 22, temporaryBps 32, realizedImpactBps 43Almgren, Thum, Hauptmann and Li, Direct estimation of equity market impact, Risk 18(7), 2005, Table 3: a purchase of 10% of average daily volume; T = 0.1, 0.2, 0.5 days is a participation of 100%, 50%, 20%. Values in bps rounded to whole numbers
order_size 192900, adv 1929000, spread_bps 0, daily_vol_pct 2.26, participation_pct 50, inverse_turnover 87permanentBps 22, temporaryBps 21, realizedImpactBps 32Almgren, Thum, Hauptmann and Li, Direct estimation of equity market impact, Risk 18(7), 2005, Table 3: a purchase of 10% of average daily volume; T = 0.1, 0.2, 0.5 days is a participation of 100%, 50%, 20%. Values in bps rounded to whole numbers

An average-cost estimate for liquid US large caps, not a quote or investment advice.

What it takes

InputMeaningDefaultAllowed
order_sizeOrder size in shares500001 to 1,000,000,000,000
advAverage daily volume in shares50000001 to 1,000,000,000,000
spread_bpsFull quoted bid-ask spread in basis points; half is charged80 to 10,000
daily_vol_pctDaily return volatility in percent (2 = 2% a day)20.01 to 100
participation_pctShare of market volume the order takes while working, in percent100.01 to 100
latency_msMean order-to-market latency in milliseconds1500 to 3,600,000
ref_priceReference (mid) price in dollars, converts bps to dollars1000.0001 to 1,000,000,000
inverse_turnoverShares outstanding divided by average daily volume (263 is IBM in the paper)2630.01 to 1,000,000

What it returns

OutputMeaning
permanentBpsPermanent price impact, bps: the post-trade move, half of which is paid
temporaryBpsTemporary impact from the trading rate, bps
realizedImpactBpsImpact cost paid: permanent ÷ 2 + temporary, bps
halfSpreadBpsHalf the quoted spread, bps
totalBps, totalDollarsExpected cost of the order, in bps and in dollars
notionalUsdOrder value in dollars
durationMinutes, durationTradingDaysTime to fill at the participation rate, in minutes and in 390-minute sessions
timingRiskBpsOne-standard-deviation price move over the execution window, bps
latencyDriftBpsOne-standard-deviation price move during the mean latency, bps

Where the method comes from

Almgren, Thum, Hauptmann and Li (2005) fitted a market-impact model on several hundred thousand US large-cap orders executed by Citigroup. Permanent impact, the price move that stays after the order, is linear in the order's share of daily volume and grows with the fourth root of inverse turnover (shares outstanding over daily volume). Temporary impact depends on the trading rate to the power 3/5. The order pays half the permanent impact plus the temporary impact; half the quoted spread is added here. Both scale with daily volatility, and the two coefficients, 0.314 and 0.142, are the paper's. The paper's Table 3 is reproduced by the cases.

Duration assumes trading at a constant share of a 390-minute session, and timing and latency risk are one-standard-deviation random-walk moves over that time. The model describes average costs for liquid US large caps; single orders vary widely around it, and it does not model an order book, queue position or partial fills.

Sources

Tested

Tested 4 Dec 2026: claude-haiku-5-5 was right on 0 of 3 questions without this page and 3 of 3 with it; claude-fable-5-2 was right on 3 of 3 questions without this page, so it was not tested with it.

Changes

Cite as: mysi, Execution cost of a stock order, mysi.dev/execution-simulator, version 1, changed 2026-12-04. Code MIT.